This commit is contained in:
fmodf 2024-07-23 18:05:19 +02:00
parent 822c4fe749
commit 86745dc87d
3 changed files with 11 additions and 17 deletions

View file

@ -5,7 +5,7 @@ import SwiftUI
let isConsoleLoggingEnabled = false
#if DEBUG
let prefixLength = 200
let prefixLength = 400
func loggerMiddleware() -> Middleware<AppState, AppAction> {
{ state, action in
let timeStr = dateFormatter.string(from: Date())

View file

@ -81,6 +81,12 @@ extension Message {
let from = martinMessage.from?.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
var msg = Message(
id: martinMessage.id ?? UUID().uuidString,
@ -92,7 +98,7 @@ extension Message {
subject: martinMessage.subject,
thread: martinMessage.thread,
oobUrl: martinMessage.oob,
date: Date(),
date: date,
pending: false,
sentError: false,
attachmentType: nil,

View file

@ -80,23 +80,11 @@ final class XMPPService: ObservableObject {
})
.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
.sink(receiveValue: { [weak self] archived in
self?.clientMessagesPublisher.send((client, archived.message))
// print("MAM archived message: \(archived.message)")
// guard let conversation = MessageEventHandler.conversationKey(for: archived.message, on: account) else {
// return
// }
// DBChatHistoryStore.instance.append(for: conversation, message: archived.message, source: .archive(source: archived.source, version: archived.query.version, messageId: archived.messageId, timestamp: archived.timestamp))
let message = archived.message
message.attribute("archived_date", newValue: "\(archived.timestamp.timeIntervalSince1970)")
self?.clientMessagesPublisher.send((client, message))
})
.store(in: &clientMessagesCancellables)