a proof of concept realtime collaborative todo list
0

Configure Feed

Select the types of activity you want to include in your feed.

replicate to pds when being added as an editor

+13 -8
+13 -8
list.js
··· 438 438 // restarts the live subscription so future edits from them stream in too. 439 439 async onEditorsChanged(nextDids) { 440 440 const added = nextDids.filter((did) => !this.dids.includes(did)); 441 - if (added.length === 0) return; 442 441 this.dids = nextDids; 443 442 444 - await this.fetchDidsData(added); 443 + // Our own did is already in `this.dids` even as a read-only viewer, so 444 + // `added` can be empty when we're the one newly granted editor access. 445 + // Always replicate (it no-ops if canEdit() is still false) and only 446 + // refetch/resubscribe when there's actually a new did to pull in. 447 + if (added.length > 0) { 448 + await this.fetchDidsData(added); 445 449 446 - if (this.unsubscribe) this.unsubscribe(); 447 - this.unsubscribe = await subscribe({ 448 - dids: nextDids, 449 - collections: [LIST_NSID, ITEM_NSID, TOMBSTONE_NSID], 450 - onCommit: this.onCommit, 451 - }); 450 + if (this.unsubscribe) this.unsubscribe(); 451 + this.unsubscribe = await subscribe({ 452 + dids: nextDids, 453 + collections: [LIST_NSID, ITEM_NSID, TOMBSTONE_NSID], 454 + onCommit: this.onCommit, 455 + }); 456 + } 452 457 453 458 await this.replicateAll(); 454 459 }