wip
This commit is contained in:
parent
406b2fde1d
commit
8e3bc01632
|
@ -12,16 +12,18 @@ final class WrapperChat: ObservableObject {
|
|||
}
|
||||
|
||||
let contact: Contact
|
||||
let account: Account
|
||||
|
||||
private let xmpp: MLXMPPManager
|
||||
private let db: DataLayer
|
||||
private let monalContact: MLContact
|
||||
private var notificationObservers: [AnyObject] = []
|
||||
|
||||
init?(with: Contact) {
|
||||
init?(with: Contact, account: Account) {
|
||||
contact = with
|
||||
xmpp = MLXMPPManager.sharedInstance()
|
||||
db = DataLayer.sharedInstance()
|
||||
self.account = account
|
||||
|
||||
guard
|
||||
let monalContact = db.contactList()
|
||||
|
@ -36,9 +38,10 @@ final class WrapperChat: ObservableObject {
|
|||
NotificationCenter.default.post(name: Notification.Name(kMonalNewMessageNotice), object: nil)
|
||||
}
|
||||
|
||||
init?(with: Chat) {
|
||||
init?(with: Chat, account: Account) {
|
||||
xmpp = MLXMPPManager.sharedInstance()
|
||||
db = DataLayer.sharedInstance()
|
||||
self.account = account
|
||||
|
||||
guard
|
||||
let monalContact = db.contactList()
|
||||
|
@ -73,21 +76,6 @@ final class WrapperChat: ObservableObject {
|
|||
// return chatModel
|
||||
}
|
||||
|
||||
// init(account: Account, contact: Contact, db: DataLayer, xmpp: MLXMPPManager) {
|
||||
// self.contact = contact
|
||||
// self.account = account
|
||||
// self.db = db
|
||||
// self.xmpp = xmpp
|
||||
//
|
||||
// monalContact = db.contactList().first { $0.accountID.intValue == contact.ownerId && $0.contactJid == contact.contactJid }!
|
||||
// isOmemoEnabled = monalContact.isEncrypted
|
||||
//
|
||||
// subscribe()
|
||||
// NotificationCenter.default.post(name: Notification.Name(kMonalNewMessageNotice), object: nil)
|
||||
//
|
||||
// //
|
||||
// }
|
||||
|
||||
deinit {
|
||||
notificationObservers.forEach { NotificationCenter.default.removeObserver($0) }
|
||||
}
|
||||
|
@ -102,9 +90,7 @@ final class WrapperChat: ObservableObject {
|
|||
to: contact.contactJid,
|
||||
forAccount: monalContact.accountID,
|
||||
withMessage: text,
|
||||
|
||||
// MARK: WARNING!
|
||||
actuallyFrom: "testmon3@test.anal.company",
|
||||
actuallyFrom: account.jid,
|
||||
withId: newMessageId,
|
||||
encrypted: monalContact.isEncrypted,
|
||||
messageType: kMessageTypeText,
|
||||
|
|
|
@ -57,11 +57,13 @@ extension WrapperXMPP {
|
|||
}
|
||||
|
||||
func chat(with: Contact) -> WrapperChat? {
|
||||
WrapperChat(with: with)
|
||||
guard let account = accounts.first(where: { $0.id == with.ownerId }) else { return nil }
|
||||
return WrapperChat(with: with, account: account)
|
||||
}
|
||||
|
||||
func chat(with: Chat) -> WrapperChat? {
|
||||
WrapperChat(with: with)
|
||||
guard let account = accounts.first(where: { $0.id == with.accountId }) else { return nil }
|
||||
return WrapperChat(with: with, account: account)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue