Files
Luma/Sources/Shared/XMPP/LumaRoomStore.swift
T
wt 69195efd36
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s
Update LumaRoomStore.swift
2026-08-10 17:31:35 +07:00

56 lines
1.4 KiB
Swift

import Foundation
import Martin
final class LumaRoomStore: RoomStore {
typealias Room = RoomBase
private let dispatcher = QueueDispatcher(label: "LumaRoomStore")
private var roomsByJID: [BareJID: RoomBase] = [:]
func rooms(for context: Context) -> [RoomBase] {
dispatcher.sync {
Array(roomsByJID.values)
}
}
func room(for context: Context, with jid: BareJID) -> RoomBase? {
dispatcher.sync {
roomsByJID[jid]
}
}
func createRoom(
for context: Context,
with jid: BareJID,
nickname: String,
password: String?
) -> ConversationCreateResult<RoomBase> {
dispatcher.sync {
if let room = roomsByJID[jid] {
return .found(room)
}
let room = RoomBase(
context: context,
jid: jid,
nickname: nickname,
password: password,
dispatcher: dispatcher
)
roomsByJID[jid] = room
return .created(room)
}
}
func close(room: RoomBase) -> Bool {
dispatcher.sync {
guard roomsByJID[room.jid] === room else { return false }
roomsByJID.removeValue(forKey: room.jid)
return true
}
}
func initialize(context: Context) {}
func deinitialize(context: Context) {}
}