Fix story reactions

This commit is contained in:
Ilya Laktyushin 2023-06-15 02:20:46 +04:00
parent 1a80c230c4
commit 0882817bed
4 changed files with 59 additions and 29 deletions

View File

@ -7004,7 +7004,8 @@ public final class EmojiPagerContentComponent: Component {
topicTitle: String? = nil,
topicColor: Int32? = nil,
hasSearch: Bool = true,
forceHasPremium: Bool = false
forceHasPremium: Bool = false,
premiumIfSavedMessages: Bool = true
) -> Signal<EmojiPagerContentComponent, NoError> {
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
let isPremiumDisabled = premiumConfiguration.isPremiumDisabled
@ -7071,7 +7072,7 @@ public final class EmojiPagerContentComponent: Component {
let emojiItems: Signal<EmojiPagerContentComponent, NoError> = combineLatest(
context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: orderedItemListCollectionIds, namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000),
forceHasPremium ? .single(true) : hasPremium(context: context, chatPeerId: chatPeerId, premiumIfSavedMessages: true),
forceHasPremium ? .single(true) : hasPremium(context: context, chatPeerId: chatPeerId, premiumIfSavedMessages: premiumIfSavedMessages),
context.account.viewTracker.featuredEmojiPacks(),
availableReactions,
searchCategories,

View File

@ -1897,11 +1897,17 @@ public final class MediaEditorScreen: ViewController {
self.controller?.present(tooltipController, in: .current)
}
private weak var muteTooltip: ViewController?
func presentMutedTooltip() {
guard let sourceView = self.componentHost.findTaggedView(tag: muteButtonTag) else {
return
}
if let muteTooltip = self.muteTooltip {
muteTooltip.dismiss()
self.muteTooltip = nil
}
let isMuted = self.mediaEditor?.values.videoIsMuted ?? false
let parentFrame = self.view.convert(self.bounds, to: nil)
@ -1911,6 +1917,7 @@ public final class MediaEditorScreen: ViewController {
let tooltipController = TooltipScreen(account: self.context.account, sharedContext: self.context.sharedContext, text: isMuted ? "The story will have no sound." : "The story will have sound." , location: .point(location, .top), displayDuration: .default, inset: 16.0, shouldDismissOnTouch: { _ in
return .ignore
})
self.muteTooltip = tooltipController
self.controller?.present(tooltipController, in: .current)
}

View File

@ -1820,7 +1820,8 @@ public final class StoryItemSetContainerComponent: Component {
areUnicodeEmojiEnabled: false,
areCustomEmojiEnabled: true,
chatPeerId: component.context.account.peerId,
selectedItems: Set()
selectedItems: Set(),
premiumIfSavedMessages: false
)
},
isExpandedUpdated: { [weak self] transition in
@ -1896,43 +1897,63 @@ public final class StoryItemSetContainerComponent: Component {
self.state?.updated(transition: Transition(animation: .curve(duration: 0.25, curve: .easeInOut)))
if let centerAnimation = reaction.centerAnimation {
/*let file = centerAnimation
let file = centerAnimation
var text = "."
loop: for attribute in file.attributes {
switch attribute {
case let .CustomEmoji(_, _, displayText, _):
text = displayText
break loop
default:
break
var text = ""
var messageAttributes: [MessageAttribute] = []
var inlineStickers: [MediaId : Media] = [:]
switch reaction.value {
case let .builtin(textValue):
text = textValue
case .custom:
loop: for attribute in file.attributes {
switch attribute {
case let .CustomEmoji(_, _, displayText, _):
text = displayText
messageAttributes = [
TextEntitiesMessageAttribute(entities: [MessageTextEntity(range: 0 ..< 1, type: .CustomEmoji(stickerPack: nil, fileId: centerAnimation.fileId.id))])
]
inlineStickers = [centerAnimation.fileId: centerAnimation]
break loop
default:
break
}
}
}*/
}
let message: EnqueueMessage = .message(
text: "",
attributes: [
//TextEntitiesMessageAttribute(entities: [MessageTextEntity(range: 0 ..< 1, type: .CustomEmoji(stickerPack: nil, fileId: centerAnimation.fileId.id))])
],
inlineStickers: [:],//[centerAnimation.fileId: centerAnimation],
mediaReference: AnyMediaReference.standalone(media: reaction.activateAnimation),
text: text,
attributes: messageAttributes,
inlineStickers: inlineStickers,
mediaReference: nil,
replyToMessageId: nil,
replyToStoryId: StoryId(peerId: component.slice.peer.id, id: component.slice.item.storyItem.id),
localGroupingKey: nil,
correlationId: nil,
bubbleUpEmojiOrStickersets: []
)
let _ = enqueueMessages(account: component.context.account, peerId: component.slice.peer.id, messages: [message]).start()
let context = component.context
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: component.theme)
component.presentController(UndoOverlayController(
presentationData: presentationData,
content: .sticker(context: component.context, file: centerAnimation, loop: false, title: nil, text: "Reaction Sent.", undoText: "View in Chat", customAction: {
}),
elevatedLayout: false,
animateInAsReplacement: false,
action: { _ in return false }
))
let presentController = component.presentController
let controller = component.controller
let peer = component.slice.peer
let _ = (enqueueMessages(account: context.account, peerId: peer.id, messages: [message])
|> deliverOnMainQueue).start(next: { messageIds in
presentController(UndoOverlayController(
presentationData: presentationData,
content: .sticker(context: context, file: centerAnimation, loop: false, title: nil, text: "Reaction Sent.", undoText: "View in Chat", customAction: {
if let messageId = messageIds.first, let messageId, let navigationController = controller()?.navigationController as? NavigationController {
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peer), subject: .message(id: .id(messageId), highlight: false, timecode: nil)))
}
}),
elevatedLayout: false,
animateInAsReplacement: false,
action: { _ in return false }
))
})
}
})
}

View File

@ -404,7 +404,8 @@ final class StoryItemSetViewListComponent: Component {
self.visibleItems[item.peer.id] = visibleItem
}
let dateText = humanReadableStringForTimestamp(strings: component.strings, dateTimeFormat: PresentationDateTimeFormat(), timestamp: item.timestamp, alwaysShowTime: true, allowYesterday: true, format: HumanReadableStringFormat(
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
let dateText = humanReadableStringForTimestamp(strings: component.strings, dateTimeFormat: presentationData.dateTimeFormat, timestamp: item.timestamp, alwaysShowTime: true, allowYesterday: true, format: HumanReadableStringFormat(
dateFormatString: { value in
return PresentationStrings.FormattedString(string: component.strings.Chat_MessageSeenTimestamp_Date(value).string, ranges: [])
},