fix duplicated message shown in open groups

This commit is contained in:
Ryan ZHAO 2020-08-12 15:35:19 +10:00
parent d7ae441ee5
commit 417afbbcb9

View file

@ -8,6 +8,7 @@ public final class PublicChatPoller : NSObject {
private var pollForModeratorsTimer: Timer? = nil
private var pollForDisplayNamesTimer: Timer? = nil
private var hasStarted = false
private var isPolling = false
// MARK: Settings
private let pollForNewMessagesInterval: TimeInterval = 4
@ -54,9 +55,12 @@ public final class PublicChatPoller : NSObject {
}
public func pollForNewMessages() -> Promise<Void> {
guard !self.isPolling else { return Promise.value(()) }
self.isPolling = true
let publicChat = self.publicChat
let userPublicKey = getUserHexEncodedPublicKey()
return PublicChatAPI.getMessages(for: publicChat.channel, on: publicChat.server).done(on: DispatchQueue.global(qos: .default)) { messages in
self.isPolling = false
let uniquePublicKeys = Set(messages.map { $0.senderPublicKey })
func proceed() {
let storage = OWSPrimaryStorage.shared()