mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various improvements
This commit is contained in:
@@ -1149,7 +1149,7 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
if let previewItem = self.previewItem, let itemFile = previewItem.item.itemFile {
|
||||
if let previewItem = self.previewItem, let itemFile = previewItem.item.displayFile {
|
||||
let previewScreenView: ComponentView<Empty>
|
||||
var previewScreenTransition = transition
|
||||
if let current = self.previewScreenView {
|
||||
@@ -1190,58 +1190,66 @@ public final class EmojiStatusSelectionController: ViewController {
|
||||
return
|
||||
}
|
||||
|
||||
if let result = result, let previewItem = strongSelf.previewItem {
|
||||
var emojiString: String?
|
||||
if let itemFile = previewItem.item.itemFile {
|
||||
attributeLoop: for attribute in itemFile.attributes {
|
||||
switch attribute {
|
||||
case let .CustomEmoji(_, _, alt, _):
|
||||
emojiString = alt
|
||||
break attributeLoop
|
||||
default:
|
||||
break
|
||||
}
|
||||
if let result, let previewItem = strongSelf.previewItem {
|
||||
let expirationDate: Int32? = result.timestamp
|
||||
if let itemGift = previewItem.item.itemGift {
|
||||
let _ = (strongSelf.context.engine.accountData.setStarGiftStatus(starGift: itemGift, expirationDate: expirationDate)
|
||||
|> deliverOnMainQueue).start()
|
||||
|
||||
if let destinationView = strongSelf.controller?.destinationItemView() {
|
||||
strongSelf.animateOutToStatus(item: previewItem.item, sourceLayer: result.sourceView.layer, customEffectFile: nil, destinationView: destinationView, fromBackground: true)
|
||||
}
|
||||
}
|
||||
|
||||
let context = strongSelf.context
|
||||
let _ = (context.engine.stickers.availableReactions()
|
||||
|> take(1)
|
||||
|> mapToSignal { availableReactions -> Signal<String?, NoError> in
|
||||
guard let emojiString = emojiString, let availableReactions = availableReactions else {
|
||||
return .single(nil)
|
||||
}
|
||||
for reaction in availableReactions.reactions {
|
||||
if case let .builtin(value) = reaction.value, value == emojiString {
|
||||
if let aroundAnimation = reaction.aroundAnimation {
|
||||
return context.account.postbox.mediaBox.resourceData(aroundAnimation.resource)
|
||||
|> take(1)
|
||||
|> map { data -> String? in
|
||||
if data.complete {
|
||||
return data.path
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return .single(nil)
|
||||
} else {
|
||||
var emojiString: String?
|
||||
if let itemFile = previewItem.item.itemFile {
|
||||
attributeLoop: for attribute in itemFile.attributes {
|
||||
switch attribute {
|
||||
case let .CustomEmoji(_, _, alt, _):
|
||||
emojiString = alt
|
||||
break attributeLoop
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return .single(nil)
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { filePath in
|
||||
guard let strongSelf = self, let previewItem = strongSelf.previewItem, let destinationView = strongSelf.controller?.destinationItemView() else {
|
||||
return
|
||||
|
||||
let context = strongSelf.context
|
||||
let _ = (context.engine.stickers.availableReactions()
|
||||
|> take(1)
|
||||
|> mapToSignal { availableReactions -> Signal<String?, NoError> in
|
||||
guard let emojiString = emojiString, let availableReactions = availableReactions else {
|
||||
return .single(nil)
|
||||
}
|
||||
for reaction in availableReactions.reactions {
|
||||
if case let .builtin(value) = reaction.value, value == emojiString {
|
||||
if let aroundAnimation = reaction.aroundAnimation {
|
||||
return context.account.postbox.mediaBox.resourceData(aroundAnimation.resource)
|
||||
|> take(1)
|
||||
|> map { data -> String? in
|
||||
if data.complete {
|
||||
return data.path
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return .single(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
return .single(nil)
|
||||
}
|
||||
|
||||
let expirationDate: Int32? = result.timestamp
|
||||
|
||||
let _ = (strongSelf.context.engine.accountData.setEmojiStatus(file: previewItem.item.itemFile, expirationDate: expirationDate)
|
||||
|> deliverOnMainQueue).start()
|
||||
|
||||
strongSelf.animateOutToStatus(item: previewItem.item, sourceLayer: result.sourceView.layer, customEffectFile: filePath, destinationView: destinationView, fromBackground: true)
|
||||
})
|
||||
|> deliverOnMainQueue).start(next: { filePath in
|
||||
guard let strongSelf = self, let previewItem = strongSelf.previewItem, let destinationView = strongSelf.controller?.destinationItemView() else {
|
||||
return
|
||||
}
|
||||
|
||||
let _ = (strongSelf.context.engine.accountData.setEmojiStatus(file: previewItem.item.itemFile, expirationDate: expirationDate)
|
||||
|> deliverOnMainQueue).start()
|
||||
|
||||
strongSelf.animateOutToStatus(item: previewItem.item, sourceLayer: result.sourceView.layer, customEffectFile: filePath, destinationView: destinationView, fromBackground: true)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
strongSelf.dismissedPreviewItem = strongSelf.previewItem
|
||||
strongSelf.previewItem = nil
|
||||
@@ -1551,3 +1559,15 @@ private func generateParabollicMotionKeyframes(from sourcePoint: CGPoint, to tar
|
||||
|
||||
return keyframes
|
||||
}
|
||||
|
||||
extension EmojiPagerContentComponent.Item {
|
||||
var displayFile: TelegramMediaFile? {
|
||||
if let file = self.itemFile {
|
||||
return file
|
||||
} else if let gift = self.itemGift {
|
||||
return gift.itemFile
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user