This is the template project that's checked out and configured when you run the bando-up command from ljsthw-bandolier. This is where the code really lives.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
bandolier-template/client/livestreams.js

45 lines
1.1 KiB

import api from "$/client/api.js";
import { user } from "$/client/stores.js";
import { get as get_store} from "svelte/store";
let livestreams = {};
export const reset_cache = () => livestreams = {};
export const load_past_streams = async () => {
if(!livestreams.index) {
const [status, data] = await api.get("/api/livestream");
if(status === 200) {
livestreams.index = data.sort((a, b) => b.id - a.id);
} else {
console.error("Invalid response", status, data);
}
}
return livestreams.index;
}
export const load_stream = async (livestream_id, cached=true) => {
if(!cached || !livestreams[livestream_id]) {
const [status, data] = await api.get("/api/livestream", {livestream_id});
if(status === 200) {
livestreams[livestream_id] = data;
} else {
console.error("Invalid response", status, data);
}
}
return livestreams[livestream_id];
}
export const change_stream = async (livestream_id) => {
if(get_store(user).admin) {
const [status, data] = await api.post("/api/livestream", { livestream_id});
return status;
} else {
return 401;
}
}