Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for persistent superchats #79

Merged
merged 47 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2a69054
rework css for pinned message to allow sticky
KentoNishi May 24, 2022
90b978d
add a sticky bar with chips
KentoNishi May 27, 2022
3260a63
parse ticker actions instead
KentoNishi May 29, 2022
fa4a341
progress so far
KentoNishi May 30, 2022
547b5bf
timed superchat appearance
KentoNishi May 30, 2022
bfcce23
superchat ticking progress
KentoNishi May 30, 2022
b1bce68
expand tickers
KentoNishi May 30, 2022
419622e
changes to types
KentoNishi May 30, 2022
5ecec4c
disallow duplicates
KentoNishi May 30, 2022
9db9f09
removed some extra css
KentoNishi May 30, 2022
703a4bf
fix: use smelte dark instead of location dark for stickybar
r2dev2 May 31, 2022
c2b5799
start showing supas immediately on load
KentoNishi Jun 2, 2022
1e8fc0e
Merge branch 'sticky-superchats' of github.com:LiveTL/HyperChat into …
KentoNishi Jun 2, 2022
add3ef2
use fullDurationSec
KentoNishi Jun 2, 2022
1fb0181
add touch and horizontal scrollwheel support
KentoNishi Jun 2, 2022
43dc929
clearer close button
KentoNishi Jun 2, 2022
ea164e3
only update stickySuperchats if items in discard
KentoNishi Jun 2, 2022
7fa40f3
Merge branch 'master' into sticky-superchats
KentoNishi Jun 4, 2022
8a2a0f0
fix small forceTLColor bug
KentoNishi Jun 7, 2022
7f4ee1b
fix disappearing bar
KentoNishi Jun 8, 2022
45503b7
safeguard possibly null runs prop
KentoNishi Jun 8, 2022
a1d6d62
remove messageId prop
KentoNishi Jun 8, 2022
3834d2d
truncate long names
KentoNishi Jun 8, 2022
9757f74
enableStickySuperchatBar setting
KentoNishi Jun 10, 2022
fc8c551
WIP liveChatTickerSponsorItemRenderer
KentoNishi Jun 10, 2022
a2d8b90
parse membership items in parseTickerAction
KentoNishi Jun 10, 2022
e8c1b35
partially implemented sticky bar for members
KentoNishi Jun 11, 2022
f354919
display member items on the bar
KentoNishi Jun 11, 2022
e870f44
expand membership chips on click
KentoNishi Jun 11, 2022
95137bd
thin scrollbars everywhere
KentoNishi Jun 11, 2022
7297a34
5-second leniency for sticky bar
KentoNishi Jun 11, 2022
7b6a084
pixel-perfect vertical centering cuz im a nerd
KentoNishi Jun 11, 2022
adad8e8
evenly padded superchat dialog
KentoNishi Jun 11, 2022
e0759c2
fixed some padding
KentoNishi Jun 11, 2022
1d863b1
fixed bugs + overlapped absolute items
KentoNishi Jun 14, 2022
7759590
workaround for ff
KentoNishi Jun 14, 2022
b6d7852
run superchat bar on 500ms tick
KentoNishi Jun 14, 2022
45efba1
some visual stuff
KentoNishi Jun 14, 2022
1d4a4fc
take ur uncustomizable scrollbar, ff users
KentoNishi Jun 14, 2022
9780564
w-full
KentoNishi Jun 14, 2022
5687d21
remove transition
KentoNishi Jun 14, 2022
77ff141
open, dispatch('resize')
KentoNishi Jun 15, 2022
cd9d63d
changelog
KentoNishi Jun 15, 2022
bae8f36
slightly shorter changelog
KentoNishi Jun 15, 2022
7048db6
forgot to SET stickySuperchats
KentoNishi Jun 15, 2022
ba7bc8d
Un-absolute sticky bar
ChrRubin Jun 16, 2022
ddfeacf
update changelog
KentoNishi Jun 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions src/components/Hyperchat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
$showProfileIcons, $showUsernames, $showTimestamps, $showUserBadges
);

const containerClass = 'h-screen w-screen text-black dark:text-white dark:bg-black dark:bg-opacity-25';
const containerClass = 'h-screen w-screen text-black dark:text-white dark:bg-black dark:bg-opacity-25 flex flex-col';

const isSuperchat = (action: Chat.MessageAction) => (action.message.superChat || action.message.superSticker);
const isMembership = (action: Chat.MessageAction) => (action.message.membership);
Expand All @@ -294,16 +294,34 @@
$stickySuperchats = [];
};
$: if (!$enableStickySuperchatBar) clearStickySuperchats();

let topBarSize = 0;
let topBar: HTMLDivElement | undefined;
const topBarResized = () => {
setTimeout(() => {
if (topBar) {
topBarSize = topBar.clientHeight;
}
}, 350);
};
$: $enableStickySuperchatBar, pinned, topBarResized();
</script>

<ReportBanDialog />
<SuperchatViewDialog />

<svelte:window on:resize={scrollToBottom} on:load={onLoad} />
<svelte:window on:resize={() => {
scrollToBottom();
topBarResized();
}} on:load={onLoad} />

<div class={containerClass} style="font-size: 13px">
<div class="absolute w-full h-full flex justify-end flex-col">
{#if $enableStickySuperchatBar}
<StickyBar />
{/if}
<div class="w-full min-h-0 flex justify-end flex-col relative">
<div bind:this={div} on:scroll={checkAtBottom} class="content overflow-y-scroll">
<div style="height: {topBarSize}px;" />
{#each messageActions as action (action.message.messageId)}
<div
class="{isWelcome(action) ? '' : 'flex'} hover-highlight p-1.5 w-full block"
Expand All @@ -327,25 +345,22 @@
</div>
{/each}
</div>
</div>
<div class="absolute top-0 w-full">
{#if $enableStickySuperchatBar}
<StickyBar />
{/if}
{#if pinned}
<div class="mx-2 mt-2">
<PinnedMessage pinned={pinned} />
<div class="absolute top-0 w-full" bind:this={topBar}>
<div class="mx-1.5 mt-1.5">
<PinnedMessage pinned={pinned} on:resize={topBarResized} />
</div>
</div>
{/if}
{#if !isAtBottom}
<div
class="absolute left-1/2 transform -translate-x-1/2 bottom-0 pb-1"
transition:fade={{ duration: 150 }}
>
<Button icon="arrow_downward" on:click={scrollToBottom} small />
</div>
{/if}
</div>
{#if !isAtBottom}
<div
class="absolute left-1/2 transform -translate-x-1/2 bottom-0 pb-1"
transition:fade={{ duration: 150 }}
>
<Button icon="arrow_downward" on:click={scrollToBottom} small />
</div>
{/if}
</div>

<style>
Expand Down
4 changes: 4 additions & 0 deletions src/components/PinnedMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import Tooltip from './common/Tooltip.svelte';
import Icon from 'smelte/src/components/Icon';
import { Theme } from '../ts/chat-constants';
import { createEventDispatcher } from 'svelte';

export let pinned: Ytc.ParsedPinned;

Expand All @@ -18,6 +19,9 @@
dismissed = false;
shorten = false;
}

const dispatch = createEventDispatcher();
$: dismissed, shorten, dispatch('resize');
</script>

{#if !dismissed}
Expand Down
56 changes: 44 additions & 12 deletions src/components/StickyBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import dark from 'smelte/src/dark';
import { stickySuperchats, currentProgress } from '../ts/storage';
import TimedItem from './TimedItem.svelte';
import { onDestroy, onMount } from 'svelte';

const isDark = dark();
let scrollableElem: HTMLDivElement;
Expand All @@ -12,25 +13,46 @@
scrollableElem.scrollBy(e.deltaY + e.deltaX, 0);
});
}
$: $stickySuperchats = $stickySuperchats.filter(sc => {
return $currentProgress === null ||
((sc.showtime / 1000 - 5 <= $currentProgress) && (sc.showtime / 1000 + sc.tickerDuration) >= $currentProgress);

let interval: number | undefined;

onMount(() => {
interval = window.setInterval(() => {
$stickySuperchats = $stickySuperchats.filter(sc => {
return $currentProgress === null || (
(sc.showtime / 1000 - 5 <= $currentProgress) &&
(sc.showtime / 1000 + sc.tickerDuration) >= $currentProgress
);
});
}, 500);
});

onDestroy(() => {
if (interval) {
clearInterval(interval);
}
});

$: open = Boolean($stickySuperchats.length);
</script>

{#if $stickySuperchats.length}
<div class="w-full overflow-y-hidden scroll-on-hover" bind:this={scrollableElem}>
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
{#if open}
<div
class="w-full overflow-y-hidden overflow-x-scroll scroll-on-hover items-start flex-none"
style="--scrollbar-bg-color: #{$isDark ? '202020' : 'ffffff'};"
bind:this={scrollableElem}
>
<div
class="flex items-center"
class="flex items-center h-9 enlarge-on-ff"
style="
height: 40px;
width: fit-content;
min-width: 100%;
background-color: #{$isDark ? '202020' : 'ffffff'}
background-color: var(--scrollbar-bg-color);
"
>
{#each $stickySuperchats as sc (sc.messageId)}
<span class="mx-0.5">
<span class="mx-0.5 h-8 mt-1">
<TimedItem
item={sc}
chip
Expand All @@ -43,10 +65,20 @@
{/if}

<style>
.scroll-on-hover::-webkit-scrollbar {
width: 4px;
height: 4px;
}
.scroll-on-hover::-webkit-scrollbar-track {
background: var(--scrollbar-bg-color);
}
.scroll-on-hover {
overflow-x: hidden;
scrollbar-color: #888 var(--scrollbar-bg-color);
}
.scroll-on-hover:hover {
overflow-x: auto;
@supports (-moz-appearance:none) {
.enlarge-on-ff {
height: 2.5rem;
padding-top: 0.25rem;
}
}
</style>
20 changes: 15 additions & 5 deletions src/components/changelog/Changelog.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<ul class="list-disc list-inside">
<strong>On today's KFP menu:</strong>
<li class="ml-3.5">
You can now block and report users!
It took months to reverse-engineer this feature. Enjoy!
Sticky superchats are finally supported!
Tickers for superchats and membership joins/milestones
will be visible at the top of the screen (like in default YTC).
The bar can also be disabled in the settings menu.
</li>
<li class="ml-3.5">
Superchats and membership messages now properly display
profile pictures if enabled.
</li>
<li class="ml-3.5">
Fixed issues with the settings menu not opening
properly on select devices
</li>
<li class="ml-3.5">
Fixed occasional freezing issues
</li>
</ul>
<ul class="list-disc list-inside">
<strong>What's still cooking in the usual room:</strong>
<li class="ml-3.5">
Sticky superchats
</li>
<li class="ml-3.5">
Updated screenshots, store listing, and trailer video
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "HyperChat by LiveTL",
"homepage_url": "https://livetl.app/en/hyperchat/",
"description": "YouTube chat, but it's fast and sleek!",
"version": "2.5.6",
"version": "2.6.0",
"permissions": [
"storage"
],
Expand Down
4 changes: 1 addition & 3 deletions src/scripts/chat-background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
} else if (request.type === 'createPopup') {
chrome.windows.create({
url: request.url,
type: 'popup',
height: 420,
width: 690
type: 'popup'
}, () => {});
Comment on lines 429 to 432
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We sure we wanna remove the width/height? The defaults seems a tad large.

image

}
});