Add pull to refresh feature in DMs

Closes: https://github.com/damus-io/damus/issues/3352
Changelog-Added: Added a pull to refresh feature on DMs that allows users to resync DMs with their relays
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2026-01-16 17:25:16 -08:00
parent ce461b58e6
commit 96fb909d83
6 changed files with 91 additions and 10 deletions

View File

@@ -270,7 +270,7 @@ final class RelayConnection: ObservableObject {
}
return
}
print("failed to decode event \(messageString)")
print("\(self.relay_url): failed to decode event \(messageString)")
case .data(let messageData):
if let messageString = String(data: messageData, encoding: .utf8) {
await receive(message: .string(messageString))
@@ -299,7 +299,7 @@ final class RelayConnection: ObservableObject {
throw NegentropySyncError.notSupported
}
}
let timeout = timeout ?? .seconds(5)
let timeout = timeout ?? .seconds(3)
let frameSizeLimit = 60_000 // Copied from rust-nostr project: Default frame limit is 128k. Halve that (hex encoding) and subtract a bit (JSON msg overhead)
try? negentropyVector.seal() // Error handling note: We do not care if it throws an `alreadySealed` error. As long as it is sealed in the end it is fine
let negentropyClient = try Negentropy(storage: negentropyVector, frameSizeLimit: frameSizeLimit)

View File

@@ -661,10 +661,12 @@ class RelayPool {
}
}
catch {
if let negentropyError = error as? RelayConnection.NegentropySyncError,
case .notSupported = negentropyError,
ignoreUnsupportedRelays {
if ignoreUnsupportedRelays {
// Do not throw error, ignore the relays that do not support negentropy
// Note: Some relays such as wss://nos.lol/v2 advertise negentropy but throw an error such as `["NOTICE","ERROR: bad msg: negentropy disabled"]`
// Therefore, realistically, we cannot rely on what the relay advertises and
// we have to suppress those errors if we want to ignore unsupported relays to avoid the whole multi-relay negentropy syncing operation to fail
Log.error("Error while negentropy streaming: %s", for: .networking, error.localizedDescription)
}
else {
throw error