Release 0.8.0

This commit is contained in:
hnzio committed 2026-10-27 14:57:17 +01:00
1 parent 21c0de7dd9
commit 07f2c4607b
47 files changed
+5314 -2303

No files matched your search

+32 -1
View File
@@ -1,7 +1,38 @@
import { redirect } from '@sveltejs/kit';
import { hasUsers } from '#lib/server/auth.js';
import { listPieces } from '#lib/server/content.js';
import { getPieceUsageContexts, getShow, listShows } from '#lib/server/shows.js';
export function load({ locals }) {
if (!hasUsers()) redirect(307, '/setup');
redirect(307, locals.user ? '/fundus' : '/login');
if (!locals.user) redirect(307, '/login');
const now = new Date().toISOString();
const activeShows = listShows(['draft', 'ready', 'live']);
const orderedShows = [...activeShows].sort((left, right) => {
if (left.status === 'live' && right.status !== 'live') return -1;
if (right.status === 'live' && left.status !== 'live') return 1;
if (left.startsAtUtc && right.startsAtUtc) {
const leftPast = left.startsAtUtc < now;
const rightPast = right.startsAtUtc < now;
if (leftPast !== rightPast) return leftPast ? 1 : -1;
return leftPast
? right.startsAtUtc.localeCompare(left.startsAtUtc)
: left.startsAtUtc.localeCompare(right.startsAtUtc);
}
return left.startsAtUtc ? -1 : right.startsAtUtc ? 1 : 0;
});
const nextShowSummary = orderedShows[0] ?? null;
const nextShow = nextShowSummary ? getShow(nextShowSummary.id) : null;
const pieceCandidates = listPieces({ statuses: ['preparing', 'ready'] });
const contexts = getPieceUsageContexts(pieceCandidates.map((piece) => piece.id));
const currentPieces = pieceCandidates
.filter((piece) => !(contexts[piece.id]?.sentHistory.length > 0) || piece.isFavorite)
.slice(0, 6);
return {
nextShow,
currentPieces,
upcomingShows: orderedShows.filter((show) => show.id !== nextShowSummary?.id).slice(0, 4)
};
}