mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Improve paid media upload and editing
This commit is contained in:
parent
4d63e3c74c
commit
a545eac99e
@ -976,6 +976,10 @@ public final class StoreMessage {
|
||||
}
|
||||
}
|
||||
|
||||
public func withUpdatedMedia(_ media: [Media]) -> StoreMessage {
|
||||
return StoreMessage(id: self.id, globallyUniqueId: self.globallyUniqueId, groupingKey: self.groupingKey, threadId: self.threadId, timestamp: self.timestamp, flags: self.flags, tags: self.tags, globalTags: self.globalTags, localTags: self.localTags, forwardInfo: self.forwardInfo, authorId: self.authorId, text: self.text, attributes: self.attributes, media: media)
|
||||
}
|
||||
|
||||
public func withUpdatedAttributes(_ attributes: [MessageAttribute]) -> StoreMessage {
|
||||
return StoreMessage(id: self.id, globallyUniqueId: self.globallyUniqueId, groupingKey: self.groupingKey, threadId: self.threadId, timestamp: self.timestamp, flags: self.flags, tags: self.tags, globalTags: self.globalTags, localTags: self.localTags, forwardInfo: self.forwardInfo, authorId: self.authorId, text: self.text, attributes: attributes, media: self.media)
|
||||
}
|
||||
|
@ -236,7 +236,13 @@ private func requestEditMessageInternal(accountPeerId: PeerId, postbox: Postbox,
|
||||
} else {
|
||||
updatedFlags.remove(.Incoming)
|
||||
}
|
||||
return .update(message.withUpdatedLocalTags(updatedLocalTags).withUpdatedFlags(updatedFlags))
|
||||
|
||||
var updatedMedia = message.media
|
||||
if let previousPaidContent = previousMessage.media.first(where: { $0 is TelegramMediaPaidContent }) as? TelegramMediaPaidContent, case .full = previousPaidContent.extendedMedia.first {
|
||||
updatedMedia = previousMessage.media
|
||||
}
|
||||
|
||||
return .update(message.withUpdatedLocalTags(updatedLocalTags).withUpdatedFlags(updatedFlags).withUpdatedMedia(updatedMedia))
|
||||
})
|
||||
}
|
||||
default:
|
||||
|
@ -3885,7 +3885,13 @@ func replayFinalState(
|
||||
if let message = locallyRenderedMessage(message: message, peers: peers) {
|
||||
generatedEvent = reactionGeneratedEvent(previousMessage.reactionsAttribute, message.reactionsAttribute, message: message, transaction: transaction)
|
||||
}
|
||||
return .update(message.withUpdatedLocalTags(updatedLocalTags).withUpdatedFlags(updatedFlags).withUpdatedAttributes(updatedAttributes))
|
||||
|
||||
var updatedMedia = message.media
|
||||
if let previousPaidContent = previousMessage.media.first(where: { $0 is TelegramMediaPaidContent }) as? TelegramMediaPaidContent, case .full = previousPaidContent.extendedMedia.first {
|
||||
updatedMedia = previousMessage.media
|
||||
}
|
||||
|
||||
return .update(message.withUpdatedLocalTags(updatedLocalTags).withUpdatedFlags(updatedFlags).withUpdatedAttributes(updatedAttributes).withUpdatedMedia(updatedMedia))
|
||||
})
|
||||
if let generatedEvent = generatedEvent {
|
||||
addedReactionEvents.append(generatedEvent)
|
||||
|
@ -47,6 +47,12 @@ func applyMediaResourceChanges(from: Media, to: Media, postbox: Postbox, force:
|
||||
if (force || fromFile.size == toFile.size || fromFile.resource.size == toFile.resource.size) && fromFile.mimeType == toFile.mimeType {
|
||||
copyOrMoveResourceData(from: fromFile.resource, to: toFile.resource, mediaBox: postbox.mediaBox)
|
||||
}
|
||||
} else if let fromPaidContent = from as? TelegramMediaPaidContent, let toPaidContent = to as? TelegramMediaPaidContent {
|
||||
for (fromMedia, toMedia) in zip(fromPaidContent.extendedMedia, toPaidContent.extendedMedia) {
|
||||
if case let .full(fullFromMedia) = fromMedia, case let .full(fullToMedia) = toMedia {
|
||||
applyMediaResourceChanges(from: fullFromMedia, to: fullToMedia, postbox: postbox, force: force)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,6 +266,9 @@ private extension StarsContext.State.Transaction {
|
||||
if (apiFlags & (1 << 3)) != 0 {
|
||||
flags.insert(.isRefund)
|
||||
}
|
||||
if (apiFlags & (1 << 4)) != 0 {
|
||||
flags.insert(.isPending)
|
||||
}
|
||||
if (apiFlags & (1 << 6)) != 0 {
|
||||
flags.insert(.isFailed)
|
||||
}
|
||||
@ -591,8 +594,8 @@ private final class StarsTransactionsContextImpl {
|
||||
var updatedState = self._state
|
||||
updatedState.isLoading = true
|
||||
self.updateState(updatedState)
|
||||
|
||||
self.disposable.set((_internal_requestStarsState(account: self.account, peerId: self.peerId, mode: self.mode, offset: nextOffset, limit: 10)
|
||||
|
||||
self.disposable.set((_internal_requestStarsState(account: self.account, peerId: self.peerId, mode: self.mode, offset: nextOffset, limit: self.nextOffset == "" ? 25 : 50)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||
guard let self else {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user