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