From 208568c66226042067b7d56d0e60807642f489a8 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Tue, 27 Dec 2022 16:47:05 +0700 Subject: [PATCH] Quick docs for livestream since they're more internal. --- client/livestreams.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/livestreams.js b/client/livestreams.js index a5ce12d..08d088a 100644 --- a/client/livestreams.js +++ b/client/livestreams.js @@ -1,11 +1,18 @@ +/* + Mostly just code used in the `client/pages/Live.svelte` and `client/pages/LiveIndex.svelte` + to list and report the available livestreams. It does some caching and normalizes how the + streams are loaded. + */ import api from "$/client/api.js"; import { user } from "$/client/stores.js"; import { get as get_store} from "svelte/store"; let livestreams = {}; +/* Reset the cache. */ export const reset_cache = () => livestreams = {}; +/* Load the available streams and cache them. */ export const load_past_streams = async () => { if(!livestreams.index) { const [status, data] = await api.get("/api/livestream"); @@ -20,6 +27,10 @@ export const load_past_streams = async () => { return livestreams.index; } +/* + Load a specific stream, with `cached` set to false it will bypass + the cache when loading it. + */ export const load_stream = async (livestream_id, cached=true) => { if(!cached || !livestreams[livestream_id]) { const [status, data] = await api.get("/api/livestream", {livestream_id}); @@ -34,6 +45,10 @@ export const load_stream = async (livestream_id, cached=true) => { return livestreams[livestream_id]; } +/* + Changes the state of the given stream, which is an administrator only + operation that moves it through the visual states. + */ export const change_stream = async (livestream_id) => { if(get_store(user).admin) { const [status, data] = await api.post("/api/livestream", { livestream_id});