Skip to content

Commit 61e4b13

Browse files
igorovhgemini-code-assist[bot]Copilot
authored
feat: add chatters to stream manager (#155)
* feat: add chatters to stream manager * Apply suggestions from code review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: igor <37638480+igorovh@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 2bec984 commit 61e4b13

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

src/platforms/twitch/modules/chatters/chatters.module.tsx

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ export default class ChattersModule extends TwitchModule {
3636
validateUrl: ChattersModule.URL_CONFIG,
3737
once: true,
3838
},
39+
{
40+
type: "selector",
41+
selectors: [".sunlight-live-indicator"],
42+
callback: this.createTotalChattersComponent.bind(this),
43+
key: "chatters-stream-manager",
44+
validateUrl: (url) => url.includes("/stream-manager"),
45+
useParent: true,
46+
once: true,
47+
},
3948
{
4049
type: "selector",
4150
selectors: [".ffz-stat-text.tw-stat__value"],
@@ -95,7 +104,7 @@ export default class ChattersModule extends TwitchModule {
95104
);
96105
}
97106

98-
private async createTotalChattersComponent(elements: Element[]) {
107+
private async createTotalChattersComponent(elements: Element[], key: string) {
99108
if (!(await this.isModuleEnabled())) return;
100109
const wrappers = this.commonUtils().createEmptyElements(this.getId(), elements, "span");
101110

@@ -111,7 +120,11 @@ export default class ChattersModule extends TwitchModule {
111120
}
112121
position="right"
113122
>
114-
<ChattersComponent click={this.refreshChatters.bind(this)} counter={this.totalChattersCounter} />
123+
<ChattersComponent
124+
click={this.refreshChatters.bind(this)}
125+
counter={this.totalChattersCounter}
126+
isStreamManager={key === "chatters-stream-manager"}
127+
/>
115128
</TooltipComponent>,
116129
element,
117130
);
@@ -264,17 +277,29 @@ const Wrapper = styled.span`
264277
}
265278
`;
266279

280+
const StreamManagerWrapper = styled(Wrapper)`
281+
background-color: #ff8280;
282+
font-size: 11px;
283+
padding: 3px;
284+
border-radius: 4px;
285+
color: #000;
286+
margin-left: 8px;
287+
`;
288+
267289
const formatChatters = (chatters: number) =>
268290
Math.abs(chatters) < 10000 ? chatters.toString() : chatters.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
269291

270292
const ChattersComponent = ({
271293
click,
272294
counter,
295+
isStreamManager,
273296
}: {
274297
counter: Signal<number>;
275298
click: () => void;
276-
}) => (
277-
<Wrapper onClick={click}>
278-
({counter.value === ChattersModule.LOADING_VALUE ? "Loading..." : formatChatters(counter.value)})
279-
</Wrapper>
280-
);
299+
isStreamManager?: boolean;
300+
}) => {
301+
const chatters = counter.value === ChattersModule.LOADING_VALUE ? "Loading..." : formatChatters(counter.value);
302+
const Container = isStreamManager ? StreamManagerWrapper : Wrapper;
303+
304+
return <Container onClick={click}>{isStreamManager ? `CHATTERS: ${chatters}` : `(${chatters})`}</Container>;
305+
};

0 commit comments

Comments
 (0)