session-ios/SessionUtilitiesKit/General/Set+Utilities.swift
Morgan Pretty 3f362a71f3 Fixed a couple of QA issues
Forced the user config feature to be on (for testing)
Fixed a bug where triggering the 'Delete for everyone' functionality would incorrectly try to delete from the recipient swarm (not possible)
Fixed a bug where the 'profileNamePublisher' could only be set once resulting in potential issues if you try to restore different accounts within the same session
Re-added the limit to the number of reactions to display before collapsing to make it consistent with the designs and other platforms
Updated the SnodeAPI to ensure that when it retries it will actually select a new snode
2023-05-23 09:42:10 +10:00

40 lines
1 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
public extension Set {
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
}
mutating func popRandomElement() -> Element? {
guard let value: Element = randomElement() else { return nil }
self.remove(value)
return value
}
}