wip
This commit is contained in:
parent
02801e46b4
commit
e6b3d856a7
|
@ -45,16 +45,30 @@ struct MessageAttr: View {
|
||||||
.foregroundColor(.Material.Shape.separator)
|
.foregroundColor(.Material.Shape.separator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// message state commented for now
|
switch message.status {
|
||||||
// if message.status == .error {
|
case .sent:
|
||||||
// Image(systemName: "exclamationmark.circle")
|
Image(systemName: "checkmark")
|
||||||
// .font(.body3)
|
.font(.body3)
|
||||||
// .foregroundColor(.Rainbow.red500)
|
.foregroundColor(.Material.Shape.separator)
|
||||||
// } else if message.status == .pending {
|
|
||||||
// Image(systemName: "clock")
|
case .delivered:
|
||||||
// .font(.body3)
|
HStack {
|
||||||
// .foregroundColor(.Material.Shape.separator)
|
Image(systemName: "checkmark")
|
||||||
// }
|
.font(.body3)
|
||||||
|
.foregroundColor(.Material.Shape.separator)
|
||||||
|
Image(systemName: "checkmark")
|
||||||
|
.font(.body3)
|
||||||
|
.foregroundColor(.Material.Shape.separator)
|
||||||
|
}
|
||||||
|
|
||||||
|
case .error:
|
||||||
|
Image(systemName: "exclamationmark.circle")
|
||||||
|
.font(.body3)
|
||||||
|
.foregroundColor(.Rainbow.red500)
|
||||||
|
|
||||||
|
default:
|
||||||
|
EmptyView()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import monalxmpp
|
import monalxmpp
|
||||||
|
|
||||||
|
enum MessageStatus {
|
||||||
|
case pending
|
||||||
|
case sent
|
||||||
|
case delivered
|
||||||
|
case error
|
||||||
|
case inbound
|
||||||
|
}
|
||||||
|
|
||||||
struct Message: Identifiable {
|
struct Message: Identifiable {
|
||||||
let accountId: Int
|
let accountId: Int
|
||||||
let participantJid: String
|
let participantJid: String
|
||||||
|
@ -10,6 +18,7 @@ struct Message: Identifiable {
|
||||||
let body: String
|
let body: String
|
||||||
let isInbound: Bool
|
let isInbound: Bool
|
||||||
let encrypted: Bool
|
let encrypted: Bool
|
||||||
|
let status: MessageStatus
|
||||||
|
|
||||||
var id: String {
|
var id: String {
|
||||||
"\(accountId)|\(dbId)"
|
"\(accountId)|\(dbId)"
|
||||||
|
@ -25,5 +34,19 @@ struct Message: Identifiable {
|
||||||
body = obj.messageText
|
body = obj.messageText
|
||||||
isInbound = obj.inbound
|
isInbound = obj.inbound
|
||||||
encrypted = obj.encrypted
|
encrypted = obj.encrypted
|
||||||
|
|
||||||
|
if !obj.inbound {
|
||||||
|
if obj.hasBeenSent {
|
||||||
|
status = .sent
|
||||||
|
} else if obj.hasBeenReceived {
|
||||||
|
status = .delivered
|
||||||
|
} else if !obj.errorType.isEmpty {
|
||||||
|
status = .error
|
||||||
|
} else {
|
||||||
|
status = .pending
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
status = .inbound
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ final class WrapperChat: ObservableObject {
|
||||||
acc.setMAMQueryMostRecentFor(monalContact, before: lastStanzaId) { [weak self] msgs, _ in
|
acc.setMAMQueryMostRecentFor(monalContact, before: lastStanzaId) { [weak self] msgs, _ in
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
||||||
self?.mamRequestInProgress = false
|
self?.mamRequestInProgress = false
|
||||||
print(msgs)
|
print(msgs ?? [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,8 @@ private extension WrapperChat {
|
||||||
func subscribe() {
|
func subscribe() {
|
||||||
let notificationNames = [
|
let notificationNames = [
|
||||||
kMonalNewMessageNotice,
|
kMonalNewMessageNotice,
|
||||||
kMonalHistoryMessagesNotice
|
kMonalHistoryMessagesNotice,
|
||||||
|
kMonalMessageDisplayedNotice
|
||||||
]
|
]
|
||||||
notificationObservers = notificationNames.map { name in
|
notificationObservers = notificationNames.map { name in
|
||||||
NotificationCenter.default.addObserver(forName: Notification.Name(name), object: nil, queue: .main) { [weak self] notification in
|
NotificationCenter.default.addObserver(forName: Notification.Name(name), object: nil, queue: .main) { [weak self] notification in
|
||||||
|
@ -132,10 +133,13 @@ private extension WrapperChat {
|
||||||
}
|
}
|
||||||
|
|
||||||
func processEvent(notification: Notification) {
|
func processEvent(notification: Notification) {
|
||||||
switch notification.name.rawValue {
|
if let mlMessage = notification.userInfo?["message"] {
|
||||||
default:
|
print("AAAAAAAAAA", mlMessage)
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
// switch notification.name.rawValue {
|
||||||
|
// default:
|
||||||
|
// break
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadMessages() {
|
func reloadMessages() {
|
||||||
|
|
Loading…
Reference in a new issue