1234567891011121314151617181920212223242526272829303132 |
- //
- // ChatListStore.swift
- // Chat
- //
- // Created by Sergey Tarasov on 25.07.2022.
- //
- import Foundation
- import XMPPFramework
- import XMPPFrameworkSwift
- final class ChatListStore: NSObject, ObservableObject {
- @Published var users: [User] = []
- var nicknames: [String] {
- return users.map({ $0.nickname.isEmpty ? $0.id : $0.nickname })
- }
- override init() {
- super.init()
- }
- public func fetchChatList() {
- let xmppUsers = XMPPController.shared.xmppRosterStorage.sortedUsersByAvailabilityName() as? [XMPPUser]
- guard let users = xmppUsers?.compactMap({
- User(id: $0.jid.bare, nickname: $0.nickname.isEmpty ? $0.jid.bare : $0.nickname)
- }) else {
- return
- }
- self.users = users
- }
- }
|