Skip to content

Commit

Permalink
Move init to video-information
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasReumann committed Aug 22, 2023
1 parent ff4aa8b commit 8b29afe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion web/template/components/chat.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{$userId = .IndexData.TUMLiveContext.User.ID}}
{{end}}
<article
x-data="interaction.videoInteractionContext({{$stream.ID}}, {ID: {{$userId}}, name: '{{$userName}}', isAdmin: {{$isAdmin}}})"
x-data="interaction.videoInteractionContext({ID: {{$userId}}, name: '{{$userName}}', isAdmin: {{$isAdmin}}})"
class="h-full">
<template x-if="isChat()">
<article
Expand Down
2 changes: 1 addition & 1 deletion web/template/watch.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<div id="watchPageMainWrapper">
<input type="hidden" id="description" value="{{.Description}}">
<input type="hidden" id="streamID" value="{{$stream.Model.ID}}">
<div x-data="interaction.videoInformationContext();"
<div x-data="interaction.videoInformationContext({{$stream.ID}});"
class="flex flex-wrap shadow border bg-white dark:bg-secondary dark:shadow-0 dark:border-0">
<div id="watchWrapper"
x-data="{ 'chatEnabled': {{and $course.ChatEnabled $stream.ChatEnabled}} }"
Expand Down
4 changes: 3 additions & 1 deletion web/ts/components/video-information.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { AlpineComponent } from "./alpine-component";
import { SocketConnections } from "../api/chat-ws";
import { ToggleableElement } from "../utilities/ToggleableElement";
import { RealtimeFacade } from "../utilities/ws";

const CUTOFFLENGTH = 256;

export function videoInformationContext(): AlpineComponent {
export function videoInformationContext(streamId: number): AlpineComponent {
// TODO: REST
const descriptionEl = document.getElementById("description") as HTMLInputElement;
return {
Expand All @@ -15,6 +16,7 @@ export function videoInformationContext(): AlpineComponent {
showFullDescription: new ToggleableElement(),

init() {
SocketConnections.ws = new RealtimeFacade("chat/" + streamId);
Promise.all([this.initWebsocket()]);
},

Expand Down
3 changes: 1 addition & 2 deletions web/ts/components/video-interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ enum InteractionType {
Polls,
}

export function videoInteractionContext(streamId: number, user: User) {
export function videoInteractionContext(user: User) {
return {
type: InteractionType.Chat,
user: user as User,

init() {
SocketConnections.ws = new RealtimeFacade("chat/" + streamId);
SocketConnections.ws.subscribe();
},

Expand Down

0 comments on commit 8b29afe

Please sign in to comment.