aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/messages.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-07 08:23:42 -0700
committerAdam Soltys <[email protected]>2026-10-07 08:23:42 -0700
commitf5450cd46cf752a843205ff51e6d12cf0da4dac8 (patch)
treea97c181918412c06e3546921f0ca4c99fd87d6db /src/features/messages.js
parentfdb044b44019d45bf8f849a4cf64a56efbc54ada (diff)
downloadcoinosv3-f5450cd46cf752a843205ff51e6d12cf0da4dac8.tar.gz
coinosv3-f5450cd46cf752a843205ff51e6d12cf0da4dac8.zip
Communities: a room rebuilt with fresher keys folds its channels again
When our own community list came back with a channel key the local copy lacked (every community we create: its list entry carries the keys), the room was torn down to be rebuilt with them, but the wraps it had already opened stayed in seenWraps. The rebuilt room's subscription then skipped the relay replay, so its Control fold held only editions newer than the rebuild: a second channel showed up as the only one (no picker; general gone from the fold), and the guestbook lost its joins. Each room now remembers the wrap ids it opened and hands them back when it is rebuilt. chat-layout-test reaches Messages through the bottom nav. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/features/messages.js')
-rw-r--r--src/features/messages.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 9745717..02a19b4 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -1178,6 +1178,10 @@ export function messagesFeature(ctx) {
folded: null,
controlEntries: [],
guestEntries: [],
+ // the wraps this room opened: a room rebuilt with fresher keys hands
+ // them back to seenWraps, or its new subscription would skip the
+ // replay and fold without them
+ wrapIds: new Set(),
members: new Map(),
byChannel: new Map(),
edits: new Map(),
@@ -1253,6 +1257,7 @@ export function messagesFeature(ctx) {
subscribeOn(room.relays, { kinds: [1059], authors: [room.control.pk], limit: 500 }, (wrap) => {
if (seenWraps.has(wrap.id)) return;
seenWraps.add(wrap.id);
+ room.wrapIds.add(wrap.id);
openWrapBg(wrap, room.control, (opened) => {
if (!opened || opened.rumor.kind !== 3308) return;
room.controlEntries.push(opened);
@@ -1262,6 +1267,7 @@ export function messagesFeature(ctx) {
subscribeOn(room.relays, { kinds: [1059], authors: [room.guestbook.pk], limit: 500 }, (wrap) => {
if (seenWraps.has(wrap.id)) return;
seenWraps.add(wrap.id);
+ room.wrapIds.add(wrap.id);
openWrapBg(wrap, room.guestbook, (opened) => {
if (!opened) return;
room.guestEntries.push(opened);
@@ -1288,6 +1294,7 @@ export function messagesFeature(ctx) {
const u = subscribeOn(room.relays, { kinds: [1059, 21059], authors: [stream.pk], limit: 200 }, (wrap) => {
if (seenWraps.has(wrap.id)) return;
seenWraps.add(wrap.id);
+ room.wrapIds.add(wrap.id);
openWrapBg(wrap, stream, (opened) => {
if (!opened) return;
onChat(room, id, opened);
@@ -2508,7 +2515,11 @@ export function messagesFeature(ctx) {
if (!newer && !fill) continue;
Object.assign(have, jmSubset(jm), { name: have.name || jm.name, relays: have.relays && have.relays.length ? have.relays : jm.relays });
const stale = rooms.get(have.community_id); // rebuilt with the new keys on next open
- if (stale) { for (const u of stale.unsubs || []) { try { u(); } catch {} } rooms.delete(have.community_id); }
+ if (stale) {
+ for (const u of stale.unsubs || []) { try { u(); } catch {} }
+ for (const id of stale.wrapIds || []) seenWraps.delete(id);
+ rooms.delete(have.community_id);
+ }
changed = true;
continue;
}