Bug fixes
This commit is contained in:
@ -31,6 +31,47 @@ class PDSViewModel: ObservableObject {
|
||||
pdsService.inviteCodes
|
||||
}
|
||||
|
||||
// Add listeners for PDSService changes
|
||||
init() {
|
||||
// Subscribe to PDSService objectWillChange events
|
||||
pdsService.objectWillChange.sink { [weak self] _ in
|
||||
// Forward the change notification to our own objectWillChange
|
||||
DispatchQueue.main.async {
|
||||
self?.objectWillChange.send()
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
// Storage for cancellables
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
// Method to manually refresh UI data
|
||||
func refreshUI() {
|
||||
DispatchQueue.main.async {
|
||||
self.objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh invite codes with UI update
|
||||
func refreshInviteCodes() async {
|
||||
await pdsService.fetchInviteCodes()
|
||||
refreshUI()
|
||||
}
|
||||
|
||||
// Refresh users with UI update
|
||||
func refreshUsers() async {
|
||||
await pdsService.fetchUsers()
|
||||
refreshUI()
|
||||
}
|
||||
|
||||
// Disable invite code with guaranteed UI update
|
||||
func disableInviteCode(_ code: String) async -> Bool {
|
||||
let result = await pdsService.disableInviteCode(code)
|
||||
refreshUI()
|
||||
return result
|
||||
}
|
||||
|
||||
func login(serverURL: String, username: String, password: String) async {
|
||||
print("PDSViewModel: login called")
|
||||
if let credentials = PDSCredentials(serverURL: serverURL, username: username, password: password) {
|
||||
|
Reference in New Issue
Block a user