Skip to content

Commit

Permalink
pinned streamer name and user id
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 1, 2024
1 parent 0421868 commit 9b3deea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions modules/relay/src/main/JsonView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ final class JsonView(
.add("pinned" -> pinned.map: (id, name, image) =>
Json
.obj(
"id" -> id,
"name" -> name
"userId" -> id,
"name" -> name
)
.add("image" -> image.map(id => picfitUrl.thumbnail(id, 1200, 675)))),
study = studyData.study,
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/src/study/relay/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface RelayData {
group?: RelayGroup;
isSubscribed?: boolean; // undefined if anon
videoUrls?: [string, string];
pinned?: { id: string; name: string; image?: string };
pinned?: { userId: string; name: string; image?: string };
}

export interface RelayGame {
Expand Down
15 changes: 6 additions & 9 deletions ui/analyse/src/study/relay/relayCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export default class RelayCtrl {
setInterval(() => this.redraw(true), 1000);

if (data.videoUrls) videoPlayerOnWindowResize(this.redraw);
if (data.pinned && this.pinStreamer()) this.streams.push([data.pinned.id, data.pinned.name]);
if (data.pinned && this.pinStreamer()) this.streams.push([data.pinned.userId, data.pinned.name]);

site.pubsub.on('socket.in.crowd', d => {
const s = (d.streams as [string, string][]) ?? [];
if (this.pinStreamer()) s.unshift([data.pinned!.id, data.pinned!.name]);
if (this.pinStreamer()) s.unshift([data.pinned!.userId, data.pinned!.name]);
if (!s) return;
if (this.streams.length === s.length && this.streams.every(([id], i) => id === s[i][0])) return;
this.streams = s;
Expand Down Expand Up @@ -105,13 +105,10 @@ export default class RelayCtrl {

isStreamer = () => this.streams.some(([id]) => id === document.body.dataset.user);

pinStreamer = () => {
return (
!this.currentRound().finished &&
Date.now() > this.currentRound().startsAt! - 1000 * 3600 &&
this.data.pinned != undefined
);
};
pinStreamer = () =>
!this.currentRound().finished &&
Date.now() > this.currentRound().startsAt! - 1000 * 3600 &&
this.data.pinned != undefined;

hidePinnedImage = () => {
site.storage.set(`relay.hide-image.${this.id}`, 'true');
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/src/study/relay/relayView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function renderPinnedImage(relay: RelayCtrl) {
attrs: { src: relay.data.pinned.image, style: 'cursor: pointer;' },
hook: bind('click', () => {
const url = new URL(location.href);
url.searchParams.set('embed', relay.data.pinned!.id);
url.searchParams.set('embed', relay.data.pinned!.userId);
window.location.replace(url);
}),
});
Expand Down

0 comments on commit 9b3deea

Please sign in to comment.