Skip to content

Commit b6d374b

Browse files
committed
feat(twitch): load emote sets from shared channels
1 parent 4b2e208 commit b6d374b

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/app/chat/ChatData.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { v4 as uuidv4 } from "uuid";
1515
const { target } = useWorker();
1616
const ctx = useChannelContext();
1717
const channelID = toRef(ctx, "id");
18+
const peerChannelIDs = toRef(ctx, "peerChannelIds");
1819
const messages = useChatMessages(ctx);
1920
const emotes = useChatEmotes(ctx);
2021
const { providers } = useStore();
@@ -24,12 +25,12 @@ const channelSets = useLiveQuery(
2425
() =>
2526
db.channels
2627
.where("id")
27-
.equals(ctx.id)
28-
.first()
29-
.then((c) => c?.set_ids ?? []),
28+
.anyOf([ctx.id, ...ctx.peerChannelIds])
29+
.toArray()
30+
.then((res) => res.flatMap((c) => c?.set_ids ?? [])),
3031
undefined,
3132
{
32-
reactives: [channelID],
33+
reactives: [channelID, peerChannelIDs],
3334
},
3435
);
3536

src/composable/channel/useChannelContext.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class ChannelContext implements CurrentChannel {
1313
id = "";
1414
username = "";
1515
displayName = "";
16+
peerChannelIds: string[] = [];
1617
user?: SevenTV.User;
1718
loaded = false;
1819
setsFetched = false;
@@ -56,6 +57,10 @@ export class ChannelContext implements CurrentChannel {
5657
return true;
5758
}
5859

60+
setPeerChannelIds(ids: string[] | MapIterator<string>) {
61+
this.peerChannelIds = [...ids];
62+
}
63+
5964
leave(): void {
6065
this.active = false;
6166

src/site/twitch.tv/modules/chat/ChatController.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ watch(
298298
sharedChannels.set(channelID, useChannelContext(channelID, true));
299299
}
300300
}
301+
302+
// Update host channel context
303+
ctx.setPeerChannelIds(sharedChannels.keys());
301304
},
302305
});
303306
},

0 commit comments

Comments
 (0)