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

fix(twitch): sidebar stream thumbnails #972

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG-nightly.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**The changes listed here are not assigned to an official release**.

- Reinstated animated avatars
- Fixed an issue with non-English names not displaying sidebar preview image on hover

### 3.0.16.1000

Expand Down
13 changes: 6 additions & 7 deletions src/site/twitch.tv/modules/sidebar-previews/SidebarCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const props = defineProps<{
instance: HookedInstance<Twitch.SidebarCardComponent>;
}>();

const SIDEBAR_PREVIEW_FALLBACK = "https://vod-secure.twitch.tv/_404/404_processing_320x180.png";

const showPreviews = useConfig<boolean>("ui.sidebar_previews");

const tooltipContent = ref<ReactExtended.ReactRuntimeElement>();
Expand Down Expand Up @@ -70,20 +72,17 @@ function patchTooltip(tooltip: ReactExtended.ReactRuntimeElement, vnode: ReactEx
props: {
className: "seventv-sidebar-tooltip-preview",
style: {
backgroundImage: getThumbnail(tooltip.props.channelDisplayName?.toLowerCase() ?? "???"),
backgroundImage: getThumbnail(tooltip.props.streamPreviewImage ?? SIDEBAR_PREVIEW_FALLBACK),
},
},
});

return vnode;
}

function getThumbnail(channel: string) {
let url = `https://static-cdn.jtvnw.net/previews-ttv/live_user_${channel}-190x107.jpg`;

url += `?${Math.floor(Date.now() / 300000)}`;

return `url("${url}")`;
function getThumbnail(previewURL: string) {
const url = previewURL.concat(`?${Math.floor(Date.now() / 300000)}`);
return `url(${url})`;
}

onUnmounted(() => {
Expand Down