Skip to content

Commit

Permalink
Merge pull request #153 from FlaminSarge/autocollapse
Browse files Browse the repository at this point in the history
Auto-collapse Chat Summary banner after bannerTimeoutMs
  • Loading branch information
KentoNishi authored Dec 22, 2024
2 parents 50464dc + 1947f8f commit d1909e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/ChatSummary.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,24 @@
let dismissed = false;
let shorten = false;
let autoHideTimeout: NodeJS.Timeout | null = null;
const classes = 'rounded inline-flex flex-col overflow-visible ' +
'bg-secondary-900 p-2 w-full text-white z-10 shadow';
const onShorten = () => { shorten = !shorten; };
const onShorten = () => {
shorten = !shorten;
if (autoHideTimeout) {
clearTimeout(autoHideTimeout);
autoHideTimeout = null;
}
};
$: if (summary) {
dismissed = false;
shorten = false;
if (summary.showtime) {
autoHideTimeout = setTimeout(() => { shorten = true; }, summary.showtime);
}
}
const dispatch = createEventDispatcher();
Expand Down
2 changes: 1 addition & 1 deletion src/ts/chat-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const parseChatSummary = (renderer: Ytc.AddChatItem, isEphemeral: boolean, banne
message: splitRuns[2],
},
id: baseRenderer.liveChatSummaryId,
showtime: isEphemeral ? (bannerTimeoutMs / 1000) : 0,
showtime: isEphemeral ? bannerTimeoutMs : 0,
};
return item;
}
Expand Down

0 comments on commit d1909e0

Please sign in to comment.