fix: Restore chat attachments after reload
Wait for persisted attachment metadata before serving or advertising files so reconnecting peers can load images and downloads reliably. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+13
-3
@@ -61,8 +61,11 @@ export class AttachmentManagerService {
|
||||
void this.persistence.initFromDatabase().then(async () => {
|
||||
if (this.watchedRoomId) {
|
||||
await this.restoreLocalAttachmentsForRoom(this.watchedRoomId);
|
||||
await this.announceHostedAttachments();
|
||||
}
|
||||
|
||||
// Announce regardless of the current route - a reloaded uploader
|
||||
// sitting on the dashboard still hosts its persisted files.
|
||||
await this.announceHostedAttachments();
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -88,12 +91,19 @@ export class AttachmentManagerService {
|
||||
|
||||
this.webrtc.onPeerConnected.subscribe(() => {
|
||||
if (this.watchedRoomId) {
|
||||
void this.restoreLocalAttachmentsForRoom(this.watchedRoomId).then(async () => {
|
||||
const watchedRoomId = this.watchedRoomId;
|
||||
|
||||
void this.restoreLocalAttachmentsForRoom(watchedRoomId).then(async () => {
|
||||
await this.announceHostedAttachments();
|
||||
});
|
||||
|
||||
void this.requestAutoDownloadsForRoom(this.watchedRoomId);
|
||||
void this.requestAutoDownloadsForRoom(watchedRoomId);
|
||||
return;
|
||||
}
|
||||
|
||||
// No room open (e.g. reloaded onto the dashboard) - still announce
|
||||
// persisted files so peers relearn this device hosts them.
|
||||
void this.announceHostedAttachments();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user