Site done

This commit is contained in:
nemunaire 2022-04-17 11:45:09 +02:00
commit cca01dc055
11 changed files with 293 additions and 8 deletions

27
src/stores/videos.js Normal file
View file

@ -0,0 +1,27 @@
import { writable } from 'svelte/store';
function createVideosStore() {
const { subscribe, set, update } = writable({videos: [], idx_videos: {}, loading: true});
return {
subscribe,
update: async (res_videos, cb=null) => {
if (res_videos.status === 200) {
const videos = await res_videos.json();
const idx_videos = {};
for (const v of videos) {
idx_videos[v.id] = v;
}
update((t) => (Object.assign(t, {videos, idx_videos, loading: false})));
if (cb) {
cb(videos);
}
}
},
};
}
export const videos = createVideosStore();