Skip to content

Commit 2e53aa4

Browse files
author
Isaac
committed
Locally update star amount on sent
1 parent 2fd6f40 commit 2e53aa4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

submodules/TelegramCore/Sources/State/PendingMessageManager.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,15 @@ public final class PendingMessageManager {
18631863
}
18641864

18651865
private func applySentMessage(postbox: Postbox, stateManager: AccountStateManager, message: Message, content: PendingMessageUploadedContentAndReuploadInfo, result: Api.Updates) -> Signal<Void, NoError> {
1866+
if let channel = message.peers[message.id.peerId] as? TelegramChannel, channel.isMonoForum {
1867+
for attribute in message.attributes {
1868+
if let attribute = attribute as? PaidStarsMessageAttribute {
1869+
stateManager.starsContext?.add(balance: StarsAmount(value: -attribute.stars.value, nanos: (attribute.stars.value == 0 && attribute.stars.nanos != 0 ? -1 : 1) * attribute.stars.nanos))
1870+
break
1871+
}
1872+
}
1873+
}
1874+
18661875
var apiMessage: Api.Message?
18671876
for resultMessage in result.messages {
18681877
let targetNamespace: MessageId.Namespace
@@ -1919,6 +1928,15 @@ public final class PendingMessageManager {
19191928
private func applySentGroupMessages(postbox: Postbox, stateManager: AccountStateManager, messages: [Message], result: Api.Updates) -> Signal<Void, NoError> {
19201929
var namespace = Namespaces.Message.Cloud
19211930
if let message = messages.first {
1931+
if let channel = message.peers[message.id.peerId] as? TelegramChannel, channel.isMonoForum {
1932+
for attribute in message.attributes {
1933+
if let attribute = attribute as? PaidStarsMessageAttribute {
1934+
stateManager.starsContext?.add(balance: StarsAmount(value: -attribute.stars.value, nanos: (attribute.stars.value == 0 && attribute.stars.nanos != 0 ? -1 : 1) * attribute.stars.nanos))
1935+
break
1936+
}
1937+
}
1938+
}
1939+
19221940
if message.id.namespace == Namespaces.Message.QuickReplyLocal {
19231941
namespace = Namespaces.Message.QuickReplyCloud
19241942
} else if let apiMessage = result.messages.first, message.scheduleTime != nil && message.scheduleTime == apiMessage.timestamp {

0 commit comments

Comments
 (0)