Ensure device links are always up to date

pull/63/head
Niels Andriesse 6 years ago
parent f25421ce83
commit 431fd15d5a

@ -83,8 +83,13 @@ public final class LokiLongPoller : NSObject {
return LokiAPI.getRawMessages(from: target, usingLongPolling: true).then(on: DispatchQueue.global()) { [weak self] rawResponse -> Promise<Void> in
guard let strongSelf = self, !strongSelf.hasStopped else { return Promise.value(()) }
let messages = LokiAPI.parseRawMessagesResponse(rawResponse, from: target)
let hexEncodedPublicKeys = Set(messages.compactMap { $0.source })
let promises = hexEncodedPublicKeys.map { LokiAPI.getDestinations(for: $0) }
return when(resolved: promises).then(on: DispatchQueue.global()) { _ -> Promise<Void> in
guard let strongSelf = self, !strongSelf.hasStopped else { return Promise.value(()) }
strongSelf.onMessagesReceived(messages)
return strongSelf.longPoll(target, seal: seal)
}
}
}
}

@ -1474,8 +1474,6 @@ NS_ASSUME_NONNULL_BEGIN
}
} else {
// TODO: Do we need to fetch the device mapping here?
// Loki: A message from a secondary device should appear as if it came from the primary device; the underlying
// friend request logic, however, should still be specific to the secondary device.

Loading…
Cancel
Save