From f5718e36562abf30b472ac170a7e9667f77f8e40 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Mon, 8 Jun 2026 22:42:37 -0700 Subject: [PATCH] fix(chat): restore channel assets when leaving shared chat When a shared chat session ended, the participants' merged emotes and badges stayed in the channel asset maps, so the other streamer's emote set and badges kept showing (#522). Only the enter transition was handled. Detect the leave transition (was shared, no longer shared) and reset: clear the loaded-participant tracking and re-run getAssets(), which replaces the channel emote/badge maps with this channel's own assets. Guarded on having actually loaded shared assets so a flapping source-room-id tag can't cause redundant refetches. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../channel/chat/stores/chat_assets_store.dart | 12 ++++++++++++ lib/screens/channel/chat/stores/chat_store.dart | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/screens/channel/chat/stores/chat_assets_store.dart b/lib/screens/channel/chat/stores/chat_assets_store.dart index c1ec05f7..2efd626c 100644 --- a/lib/screens/channel/chat/stores/chat_assets_store.dart +++ b/lib/screens/channel/chat/stores/chat_assets_store.dart @@ -290,6 +290,18 @@ abstract class ChatAssetsStoreBase with Store { await Future.wait(futures); } + /// Whether any shared chat participant assets have been merged in. + bool get hasLoadedSharedChatAssets => _loadedSharedChannelIds.isNotEmpty; + + /// Clears tracking of merged shared chat participant assets so that leaving + /// and later re-entering a shared chat session re-fetches cleanly. The caller + /// must re-fetch this channel's own assets afterwards (which replaces the + /// merged emote/badge maps). Must run within a MobX action. + void resetSharedChatAssets() { + _loadedSharedChannelIds.clear(); + sharedSevenTvSetIds.clear(); + } + /// Load and cache shared chat participants for a broadcaster. /// Returns the list of new participant broadcaster IDs (deduped). @action diff --git a/lib/screens/channel/chat/stores/chat_store.dart b/lib/screens/channel/chat/stores/chat_store.dart index ccc93d6c..4ed851ea 100644 --- a/lib/screens/channel/chat/stores/chat_store.dart +++ b/lib/screens/channel/chat/stores/chat_store.dart @@ -611,6 +611,16 @@ abstract class ChatStoreBase with Store { showFFZEmotes: settings.showFFZEmotes, showFFZBadges: settings.showFFZBadges, ); + } else if (wasShared && + !_isInSharedChatMode && + assetsStore.hasLoadedSharedChatAssets) { + // On leaving shared chat, drop the participants' merged emotes and + // badges and restore just this channel's assets — otherwise the + // other streamer's emote set and badges linger (#522). Guarded on + // having actually loaded shared assets so a flapping tag can't + // trigger redundant refetches. + assetsStore.resetSharedChatAssets(); + getAssets(); } messageBuffer.add(parsedIRCMessage); break;