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

Remove hardcoded stream-id #1130

Merged
merged 3 commits into from
Aug 22, 2023
Merged
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
2 changes: 1 addition & 1 deletion web/template/popup-chat.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<link href="/static/assets/css-dist/home.css?v={{if .IndexData.VersionTag}}{{.IndexData.VersionTag}}{{else}}development{{end}}"
rel="stylesheet">
</head>
<body class="bg-white dark:bg-secondary h-screen">
<body class="bg-white dark:bg-secondary h-screen" x-data="interaction.popupContext({{$stream.ID}})">
{{template "chat-component" .}}
</body>
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
2 changes: 1 addition & 1 deletion web/ts/api/chat-ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enum ChatMessageType {
}

export abstract class SocketConnections {
static ws: RealtimeFacade = new RealtimeFacade("chat/12845");
static ws: RealtimeFacade;
}

export type NewChatMessage = {
Expand Down
11 changes: 11 additions & 0 deletions web/ts/components/popup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { AlpineComponent } from "./alpine-component";
import { RealtimeFacade } from "../utilities/ws";
import { SocketConnections } from "../api/chat-ws";

export function popupContext(streamId: number): AlpineComponent {
return {
init() {
SocketConnections.ws = new RealtimeFacade("chat/" + streamId);
},
} as AlpineComponent;
}
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
1 change: 1 addition & 0 deletions web/ts/components/video-interaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AlpineComponent } from "./alpine-component";
import { User } from "../api/users";
import { SocketConnections } from "../api/chat-ws";
import { RealtimeFacade } from "../utilities/ws";

enum InteractionType {
Chat,
Expand Down
1 change: 1 addition & 0 deletions web/ts/entry/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "../components/chat-prompt";
export * from "../components/poll";
export * from "../components/emoji-picker";
export * from "../components/video-information";
export * from "../components/popup";
Loading