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) <noreply@anthropic.com>
This commit is contained in:
Tommy Chow 2026-06-08 22:42:37 -07:00
parent 29c4f74ef5
commit f5718e3656
2 changed files with 22 additions and 0 deletions

View file

@ -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

View file

@ -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;