mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
• Moved settings into libSession • Added new observation mechanism for libSession changes (driven via async/await) • Updated settings screen to update based on observing changes to libSession data • Updated home screen "State" to update based on observing libSession changes • Removed a number of database functions for data which is entirely retrievable via libSession
31 lines
1007 B
Swift
31 lines
1007 B
Swift
// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
public extension AsyncSequence where Element: Equatable {
|
|
func removeDuplicates() -> AsyncThrowingStream<Element, Error> {
|
|
return AsyncThrowingStream { continuation in
|
|
let task = Task {
|
|
var previousElement: Element? = nil
|
|
|
|
do {
|
|
for try await element in self {
|
|
if Task.isCancelled { break }
|
|
|
|
if element != previousElement {
|
|
continuation.yield(element)
|
|
previousElement = element
|
|
}
|
|
}
|
|
|
|
continuation.finish()
|
|
} catch {
|
|
continuation.finish(throwing: error)
|
|
}
|
|
}
|
|
|
|
continuation.onTermination = { @Sendable _ in
|
|
task.cancel()
|
|
}
|
|
}
|
|
}
|
|
}
|