mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Separate failed message events between main and scheduled
This commit is contained in:
parent
a79447e430
commit
51a7348db6
2 changed files with 73 additions and 53 deletions
|
|
@ -117,7 +117,7 @@ public struct PeerPendingMessageDelivered {
|
|||
|
||||
private final class PeerPendingMessagesSummaryContext {
|
||||
var messageDeliveredSubscribers = Bag<([PeerPendingMessageDelivered]) -> Void>()
|
||||
var messageFailedSubscribers = Bag<(PendingMessageFailureReason) -> Void>()
|
||||
var messageFailedSubscribers = Bag<(MessageId.Namespace, PendingMessageFailureReason) -> Void>()
|
||||
var newTopicEvents = Bag<(PendingMessageManager.NewTopicEvent) -> Void>()
|
||||
|
||||
var isEmpty: Bool {
|
||||
|
|
@ -1413,7 +1413,7 @@ public final class PendingMessageManager {
|
|||
|
||||
if let context = strongSelf.peerSummaryContexts[message.id.peerId] {
|
||||
for subscriber in context.messageFailedSubscribers.copyItems() {
|
||||
subscriber(failureReason)
|
||||
subscriber(message.id.namespace, failureReason)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2029,7 +2029,7 @@ public final class PendingMessageManager {
|
|||
|
||||
if let context = strongSelf.peerSummaryContexts[message.id.peerId] {
|
||||
for subscriber in context.messageFailedSubscribers.copyItems() {
|
||||
subscriber(failureReason)
|
||||
subscriber(message.id.namespace, failureReason)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2232,7 +2232,7 @@ public final class PendingMessageManager {
|
|||
}
|
||||
}
|
||||
|
||||
public func failedMessageEvents(peerId: PeerId) -> Signal<PendingMessageFailureReason, NoError> {
|
||||
public func failedMessageEvents(peerId: PeerId, isScheduled: Bool) -> Signal<PendingMessageFailureReason, NoError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
|
|
@ -2245,8 +2245,16 @@ public final class PendingMessageManager {
|
|||
self.peerSummaryContexts[peerId] = summaryContext
|
||||
}
|
||||
|
||||
let index = summaryContext.messageFailedSubscribers.add({ reason in
|
||||
subscriber.putNext(reason)
|
||||
let index = summaryContext.messageFailedSubscribers.add({ namespace, reason in
|
||||
if isScheduled {
|
||||
if Namespaces.Message.allScheduled.contains(namespace) {
|
||||
subscriber.putNext(reason)
|
||||
}
|
||||
} else {
|
||||
if !Namespaces.Message.allScheduled.contains(namespace) {
|
||||
subscriber.putNext(reason)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
disposable.set(ActionDisposable {
|
||||
|
|
|
|||
|
|
@ -5123,56 +5123,68 @@ extension ChatControllerImpl {
|
|||
}
|
||||
}
|
||||
}))
|
||||
|
||||
let isScheduledMessages: Bool
|
||||
if case .scheduledMessages = self.presentationInterfaceState.subject {
|
||||
isScheduledMessages = true
|
||||
} else {
|
||||
isScheduledMessages = false
|
||||
}
|
||||
|
||||
self.failedMessageEventsDisposable.set((self.context.account.pendingMessageManager.failedMessageEvents(peerId: peerId)
|
||||
self.failedMessageEventsDisposable.set((self.context.account.pendingMessageManager.failedMessageEvents(peerId: peerId, isScheduled: isScheduledMessages)
|
||||
|> deliverOnMainQueue).startStrict(next: { [weak self] reason in
|
||||
if let strongSelf = self, strongSelf.currentFailedMessagesAlertController == nil {
|
||||
let text: String
|
||||
var title: String?
|
||||
let moreInfo: Bool
|
||||
switch reason {
|
||||
case .flood:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorFlood
|
||||
moreInfo = true
|
||||
case .sendingTooFast:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFast
|
||||
title = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFastTitle
|
||||
moreInfo = false
|
||||
case .publicBan:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorGroupRestricted
|
||||
moreInfo = true
|
||||
case .mediaRestricted:
|
||||
text = strongSelf.restrictedSendingContentsText()
|
||||
moreInfo = false
|
||||
case .slowmodeActive:
|
||||
text = strongSelf.presentationData.strings.Chat_SlowmodeSendError
|
||||
moreInfo = false
|
||||
case .tooMuchScheduled:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooMuchScheduled
|
||||
moreInfo = false
|
||||
case .voiceMessagesForbidden:
|
||||
strongSelf.interfaceInteraction?.displayRestrictedInfo(.premiumVoiceMessages, .alert)
|
||||
return
|
||||
case .nonPremiumMessagesForbidden:
|
||||
if let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer {
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorNonPremiumForbidden(EnginePeer(peer).compactDisplayTitle).string
|
||||
moreInfo = false
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
let actions: [TextAlertAction]
|
||||
if moreInfo {
|
||||
actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Generic_ErrorMoreInfo, action: {
|
||||
self?.openPeerMention("spambot", navigation: .chat(textInputState: nil, subject: nil, peekData: nil))
|
||||
}), TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]
|
||||
} else {
|
||||
actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]
|
||||
}
|
||||
let controller = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: title, text: text, actions: actions)
|
||||
strongSelf.currentFailedMessagesAlertController = controller
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
guard strongSelf.currentFailedMessagesAlertController == nil else {
|
||||
return
|
||||
}
|
||||
|
||||
let text: String
|
||||
var title: String?
|
||||
let moreInfo: Bool
|
||||
switch reason {
|
||||
case .flood:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorFlood
|
||||
moreInfo = true
|
||||
case .sendingTooFast:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFast
|
||||
title = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFastTitle
|
||||
moreInfo = false
|
||||
case .publicBan:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorGroupRestricted
|
||||
moreInfo = true
|
||||
case .mediaRestricted:
|
||||
text = strongSelf.restrictedSendingContentsText()
|
||||
moreInfo = false
|
||||
case .slowmodeActive:
|
||||
text = strongSelf.presentationData.strings.Chat_SlowmodeSendError
|
||||
moreInfo = false
|
||||
case .tooMuchScheduled:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooMuchScheduled
|
||||
moreInfo = false
|
||||
case .voiceMessagesForbidden:
|
||||
strongSelf.interfaceInteraction?.displayRestrictedInfo(.premiumVoiceMessages, .alert)
|
||||
return
|
||||
case .nonPremiumMessagesForbidden:
|
||||
if let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer {
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorNonPremiumForbidden(EnginePeer(peer).compactDisplayTitle).string
|
||||
moreInfo = false
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
let actions: [TextAlertAction]
|
||||
if moreInfo {
|
||||
actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Generic_ErrorMoreInfo, action: {
|
||||
self?.openPeerMention("spambot", navigation: .chat(textInputState: nil, subject: nil, peekData: nil))
|
||||
}), TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]
|
||||
} else {
|
||||
actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]
|
||||
}
|
||||
let controller = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: title, text: text, actions: actions)
|
||||
strongSelf.currentFailedMessagesAlertController = controller
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
}))
|
||||
|
||||
self.sentPeerMediaMessageEventsDisposable.dispose()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue