wip
This commit is contained in:
parent
822c4fe749
commit
86745dc87d
|
@ -5,7 +5,7 @@ import SwiftUI
|
||||||
let isConsoleLoggingEnabled = false
|
let isConsoleLoggingEnabled = false
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
let prefixLength = 200
|
let prefixLength = 400
|
||||||
func loggerMiddleware() -> Middleware<AppState, AppAction> {
|
func loggerMiddleware() -> Middleware<AppState, AppAction> {
|
||||||
{ state, action in
|
{ state, action in
|
||||||
let timeStr = dateFormatter.string(from: Date())
|
let timeStr = dateFormatter.string(from: Date())
|
||||||
|
|
|
@ -81,6 +81,12 @@ extension Message {
|
||||||
let from = martinMessage.from?.bareJid.stringValue ?? ""
|
let from = martinMessage.from?.bareJid.stringValue ?? ""
|
||||||
let to = martinMessage.to?.bareJid.stringValue
|
let to = martinMessage.to?.bareJid.stringValue
|
||||||
|
|
||||||
|
// Extract date or set current
|
||||||
|
var date = Date()
|
||||||
|
if let timestampStr = martinMessage.attribute("archived_date"), let timeInterval = TimeInterval(timestampStr) {
|
||||||
|
date = Date(timeIntervalSince1970: timeInterval)
|
||||||
|
}
|
||||||
|
|
||||||
// Msg
|
// Msg
|
||||||
var msg = Message(
|
var msg = Message(
|
||||||
id: martinMessage.id ?? UUID().uuidString,
|
id: martinMessage.id ?? UUID().uuidString,
|
||||||
|
@ -92,7 +98,7 @@ extension Message {
|
||||||
subject: martinMessage.subject,
|
subject: martinMessage.subject,
|
||||||
thread: martinMessage.thread,
|
thread: martinMessage.thread,
|
||||||
oobUrl: martinMessage.oob,
|
oobUrl: martinMessage.oob,
|
||||||
date: Date(),
|
date: date,
|
||||||
pending: false,
|
pending: false,
|
||||||
sentError: false,
|
sentError: false,
|
||||||
attachmentType: nil,
|
attachmentType: nil,
|
||||||
|
|
|
@ -80,23 +80,11 @@ final class XMPPService: ObservableObject {
|
||||||
})
|
})
|
||||||
.store(in: &clientMessagesCancellables)
|
.store(in: &clientMessagesCancellables)
|
||||||
|
|
||||||
// MAM
|
|
||||||
// client.module(.mam).$availableVersions.sink(receiveValue: { [weak client] versions in
|
|
||||||
// guard !versions.isEmpty, let client = client else {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// print("MAM available versions: \(versions)")
|
|
||||||
// // MessageEventHandler.syncMessagesScheduled(for: client)
|
|
||||||
// }).store(in: &clientMessagesCancellables)
|
|
||||||
|
|
||||||
client.module(.mam).archivedMessagesPublisher
|
client.module(.mam).archivedMessagesPublisher
|
||||||
.sink(receiveValue: { [weak self] archived in
|
.sink(receiveValue: { [weak self] archived in
|
||||||
self?.clientMessagesPublisher.send((client, archived.message))
|
let message = archived.message
|
||||||
// print("MAM archived message: \(archived.message)")
|
message.attribute("archived_date", newValue: "\(archived.timestamp.timeIntervalSince1970)")
|
||||||
// guard let conversation = MessageEventHandler.conversationKey(for: archived.message, on: account) else {
|
self?.clientMessagesPublisher.send((client, message))
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// DBChatHistoryStore.instance.append(for: conversation, message: archived.message, source: .archive(source: archived.source, version: archived.query.version, messageId: archived.messageId, timestamp: archived.timestamp))
|
|
||||||
})
|
})
|
||||||
.store(in: &clientMessagesCancellables)
|
.store(in: &clientMessagesCancellables)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue