mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: cumulative video indexing
This commit is contained in:
1 parent
eb7fc62e00
commit
c281e9b66f
3 files changed
+71
-31
No files matched your search
@@ -9,7 +9,7 @@ export function Videos() {
|
||||
const isFullScreen = useFullScreen();
|
||||
const tank = useDuel((state) => state.protagonist!.tank);
|
||||
const awaitedVideoDefinitions = use(videoDefinitions);
|
||||
const videos = awaitedVideoDefinitions[tank.id] ?? [];
|
||||
const videos = awaitedVideoDefinitions[tank.id].videos ?? [];
|
||||
|
||||
if (isFullScreen) return null;
|
||||
|
||||
|
||||
@@ -1,18 +1,30 @@
|
||||
import { asset } from './asset';
|
||||
|
||||
export interface VideoDefinitions {
|
||||
[id: number]: {
|
||||
videos: string[];
|
||||
lastUpdated: number;
|
||||
};
|
||||
}
|
||||
|
||||
export const videoDefinitions = fetch(asset('definitions/videos.csv'))
|
||||
.then((response) => response.text())
|
||||
.then((text) =>
|
||||
text
|
||||
.split('\n')
|
||||
.map((line) => {
|
||||
const [idString, ...videos] = line.split(',');
|
||||
const [idString, lastUpdatedString, ...videos] = line.split(',');
|
||||
const id = Number(idString);
|
||||
return { id, videos };
|
||||
const lastUpdated = Number(lastUpdatedString);
|
||||
return { id, videos, lastUpdated };
|
||||
})
|
||||
.filter(({ videos }) => videos.length > 0)
|
||||
.reduce<Record<number, string[]>>((accumulator, { id, videos }) => {
|
||||
accumulator[id] = videos;
|
||||
.reduce<VideoDefinitions>((accumulator, { id, videos, lastUpdated }) => {
|
||||
accumulator[id] = {
|
||||
videos,
|
||||
lastUpdated,
|
||||
};
|
||||
|
||||
return accumulator;
|
||||
}, {}),
|
||||
);
|
||||
Reference in new issue
Block a user