Key per-channel storage by PSK-derived channel ID

Channel messages, settings, region, order and images were persisted by
radio slot index, so a slot reused for a different channel inherited the
old channel's history and settings (#359).

- Channel.storageId: first 8 bytes of SHA-256("meshcore-channel:" + psk).
- All per-channel stores key by channel ID; in-memory state stays by slot.
- The connector keeps a slot -> channel ID map, diffs it against the saved
  map on every channel sync and reloads slots whose channel changed.
- Queued channel frames wait until this session's map is confirmed.
- One-shot per-radio migration from slot keys, using the cached channel
  list the legacy data was written under; rerun-safe if interrupted.
- Deleting a channel clears its data; a channel removed elsewhere keeps its
  history and gets it back when re-added. A PSK edit keeps its place in
  the custom order.
- Slots sharing a PSK share history and settings.
- Image entries record their channel ID; a slot change resets that slot's
  in-progress reassembly.
This commit is contained in:
zjs81 committed 2026-10-11 17:52:59 -07:00
1 parent d30744aa31
commit 679116ed03
24 files changed
+1794 -340

No files matched your search

+6 -6
View File
@@ -1514,6 +1514,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
try {
await store.registerOutgoing(
channelIndex: widget.channel.index,
channelId: widget.channel.storageId,
// The same 16 bits the chunk header carries, so the entry keys the
// same way an inbound one would.
senderPrefix: senderPrefix,
@@ -1629,10 +1630,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
}
final images = store == null
? const <ReceivedImageEntry>[]
: [
for (final entry in store.entries)
if (entry.channelIndex == widget.channel.index) entry,
];
: store.entriesForChannel(widget.channel.storageId);
final layout = _TranscriptLayout.build(
messages: messages,
images: images,
@@ -2339,9 +2337,11 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
context.read<MeshCoreConnector>().clearMessagesForChannel(
widget.channel.index,
);
final channelId = widget.channel.storageId;
if (channelId == null) return;
try {
await context.read<ReceivedImageStore>().deleteImagesForChannel(
widget.channel.index,
await context.read<ReceivedImageStore>().deleteImagesForChannelId(
channelId,
);
} on ProviderNotFoundException {
return;