mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 02:25:20 +00:00
* Refactor app runtime and view model architecture * Move app ownership into stores and coordinators * Fix smoke test environment injection * Stabilize fragmentation package tests * Fix coordinator build warnings * Clean up chat view model warnings * Fix Nostr relay startup coalescing --------- Co-authored-by: jack <jackjackbits@users.noreply.github.com>
52 lines
1.3 KiB
Swift
52 lines
1.3 KiB
Swift
import Combine
|
|
import Foundation
|
|
|
|
@MainActor
|
|
final class LocationPresenceStore: ObservableObject {
|
|
@Published private(set) var currentGeohash: String?
|
|
@Published private(set) var geoNicknames: [String: String] = [:]
|
|
@Published private(set) var teleportedGeo: Set<String> = []
|
|
|
|
func setCurrentGeohash(_ geohash: String?) {
|
|
currentGeohash = geohash?.lowercased()
|
|
}
|
|
|
|
func setNickname(_ nickname: String, for pubkeyHex: String) {
|
|
geoNicknames[pubkeyHex.lowercased()] = nickname
|
|
}
|
|
|
|
func replaceGeoNicknames(_ nicknames: [String: String]) {
|
|
geoNicknames = Dictionary(
|
|
uniqueKeysWithValues: nicknames.map { key, value in
|
|
(key.lowercased(), value)
|
|
}
|
|
)
|
|
}
|
|
|
|
func clearGeoNicknames() {
|
|
geoNicknames.removeAll()
|
|
}
|
|
|
|
func markTeleported(_ pubkeyHex: String) {
|
|
teleportedGeo.insert(pubkeyHex.lowercased())
|
|
}
|
|
|
|
func clearTeleported(_ pubkeyHex: String) {
|
|
teleportedGeo.remove(pubkeyHex.lowercased())
|
|
}
|
|
|
|
func replaceTeleportedGeo(_ pubkeys: Set<String>) {
|
|
teleportedGeo = Set(pubkeys.map { $0.lowercased() })
|
|
}
|
|
|
|
func clearTeleportedGeo() {
|
|
teleportedGeo.removeAll()
|
|
}
|
|
|
|
func reset() {
|
|
currentGeohash = nil
|
|
geoNicknames.removeAll()
|
|
teleportedGeo.removeAll()
|
|
}
|
|
}
|