mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
Got a number of the GroupUpdate messages working properly Updated the DisplayPictureDownloadJob to support OpenGroup room images Updated the Poller to process messages by namespace (sorted) and added support for synchronous handling of messages Reworked the ProfileManager to be a more reusable DisplayPictureManager Cleaned up the conversion from milliseconds to TimeInterval (which is documented as seconds) for clarity Fixed a read/write crash due to the SnodeAPI cache setup Fixed an issue where dependencies could incorrectly overwrite each other when based on protocols
59 lines
1.6 KiB
Swift
59 lines
1.6 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
public extension Set {
|
|
mutating func insert(contentsOf value: Set<Element>?) {
|
|
guard let value: Set<Element> = value else { return }
|
|
|
|
value.forEach { self.insert($0) }
|
|
}
|
|
|
|
func inserting(_ value: Element?) -> Set<Element> {
|
|
guard let value: Element = value else { return self }
|
|
|
|
var updatedSet: Set<Element> = self
|
|
updatedSet.insert(value)
|
|
|
|
return updatedSet
|
|
}
|
|
|
|
func inserting(contentsOf value: Set<Element>?) -> Set<Element> {
|
|
guard let value: Set<Element> = value else { return self }
|
|
|
|
var updatedSet: Set<Element> = self
|
|
value.forEach { updatedSet.insert($0) }
|
|
|
|
return updatedSet
|
|
}
|
|
|
|
func removing(_ value: Element?) -> Set<Element> {
|
|
guard let value: Element = value else { return self }
|
|
|
|
var updatedSet: Set<Element> = self
|
|
updatedSet.remove(value)
|
|
|
|
return updatedSet
|
|
}
|
|
|
|
func removing(contentsOf value: Set<Element>?) -> Set<Element> {
|
|
guard let value: Set<Element> = value else { return self }
|
|
|
|
var updatedSet: Set<Element> = self
|
|
value.forEach { updatedSet.remove($0) }
|
|
|
|
return updatedSet
|
|
}
|
|
|
|
mutating func popRandomElement() -> Element? {
|
|
guard let value: Element = randomElement() else { return nil }
|
|
|
|
self.remove(value)
|
|
return value
|
|
}
|
|
|
|
func chunked(by chunkSize: Int) -> [Set<Element>] {
|
|
return Array(self).chunked(by: chunkSize).map { Set($0) }
|
|
}
|
|
}
|