Repository navigation
Commit bfbaf5e
fix(unread): make removeChannel and clearAll fully transactional + boundary tests
removeChannel and clearAll in useObservedUnreadPersistence now own all
mutation of the shared observed refs — the parent (useUnreadChannels)
no longer touches latestByChannelRef or observedUnreadEventsByChannelRef
directly on the clear/mark-all-read paths.
Before this change, markChannelRead deleted from both refs before calling
the fenced removeChannel(), and markAllChannelsRead reset both refs to
empty Maps before calling the fenced clearAll(). A stale scope-A callback
could therefore corrupt scope B's in-memory badges before the scope fence
rejected the call.
Both owner operations now validate the captured scope first, then mutate
refs, then write to storage — stale scope invocations are complete no-ops.
Adds useUnreadChannels.test.mjs: five boundary tests that mount the full
production hook with QueryClientProvider, covering:
- markChannelRead happy path (clears channel from refs + storage)
- markChannelRead topLevelOnly=true (leaves refs intact)
- markChannelRead stale scope-A callback (B refs and storage untouched)
- markAllChannelsRead happy path (clears entire bucket)
- markAllChannelsRead stale scope-A callback (B refs and storage untouched)
Also rewrites the A→B late-timer test in useObservedUnreadPersistence
to accurately describe what it proves (synchronous flush invariant), and
fixes a vacuous removeChannelAndPersistCurrent API stability assertion.
Co-authored-by: Will Pfleger <[email protected]>
Signed-off-by: Will Pfleger <[email protected]>1 parent 2fa9a05 commit bfbaf5e
4 files changed
Lines changed: 501 additions & 40 deletions
File tree
- desktop/src/features/channels
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
698 | 698 | | |
699 | 699 | | |
700 | 700 | | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
705 | 708 | | |
706 | | - | |
707 | | - | |
708 | | - | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
709 | 714 | | |
710 | 715 | | |
711 | 716 | | |
| |||
736 | 741 | | |
737 | 742 | | |
738 | 743 | | |
739 | | - | |
| 744 | + | |
740 | 745 | | |
741 | 746 | | |
742 | 747 | | |
743 | 748 | | |
744 | 749 | | |
745 | 750 | | |
746 | 751 | | |
747 | | - | |
748 | | - | |
| 752 | + | |
749 | 753 | | |
750 | 754 | | |
751 | | - | |
752 | | - | |
753 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
754 | 759 | | |
755 | 760 | | |
756 | 761 | | |
757 | | - | |
758 | | - | |
| 762 | + | |
759 | 763 | | |
760 | 764 | | |
761 | 765 | | |
762 | | - | |
| 766 | + | |
763 | 767 | | |
764 | 768 | | |
765 | | - | |
| 769 | + | |
766 | 770 | | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
773 | 775 | | |
774 | | - | |
| 776 | + | |
775 | 777 | | |
776 | 778 | | |
777 | 779 | | |
| |||
938 | 940 | | |
939 | 941 | | |
940 | 942 | | |
941 | | - | |
| 943 | + | |
942 | 944 | | |
943 | 945 | | |
944 | 946 | | |
| |||
956 | 958 | | |
957 | 959 | | |
958 | 960 | | |
959 | | - | |
960 | | - | |
961 | | - | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
962 | 964 | | |
963 | 965 | | |
964 | 966 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| 177 | + | |
| 178 | + | |
176 | 179 | | |
177 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
178 | 187 | | |
179 | 188 | | |
180 | 189 | | |
| |||
0 commit comments