fix duplicated message shown in open groups

pull/246/head
Ryan ZHAO 5 years ago
parent d7ae441ee5
commit 417afbbcb9

@ -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()

Loading…
Cancel
Save