2020-08-27 13:46:34 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
import "./congrats-base.css";
|
2020-08-27 13:46:34 +02:00
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
import { ModuleName, setupI18n } from "../lib/i18n";
|
|
|
|
import { checkNightMode } from "../lib/nightmode";
|
|
|
|
import { empty, scheduler } from "../lib/proto";
|
2021-03-21 13:47:52 +01:00
|
|
|
import CongratsPage from "./CongratsPage.svelte";
|
|
|
|
|
2022-01-16 06:05:35 +01:00
|
|
|
const i18n = setupI18n({ modules: [ModuleName.SCHEDULING] });
|
|
|
|
|
|
|
|
export async function setupCongrats(): Promise<CongratsPage> {
|
2020-08-27 13:46:34 +02:00
|
|
|
checkNightMode();
|
2022-01-16 06:05:35 +01:00
|
|
|
await i18n;
|
|
|
|
|
2022-02-17 07:28:48 +01:00
|
|
|
const customMountPoint = document.getElementById("congrats");
|
2022-01-21 12:32:39 +01:00
|
|
|
const info = await scheduler.congratsInfo(empty);
|
2021-08-02 08:05:18 +02:00
|
|
|
const page = new CongratsPage({
|
2022-02-17 07:28:48 +01:00
|
|
|
// use #congrats if it exists, otherwise entire body
|
|
|
|
target: customMountPoint ?? document.body,
|
2021-03-26 11:23:43 +01:00
|
|
|
props: { info },
|
2020-08-27 13:46:34 +02:00
|
|
|
});
|
2022-01-16 06:05:35 +01:00
|
|
|
|
2022-02-17 07:28:48 +01:00
|
|
|
// refresh automatically if a custom area not provided
|
|
|
|
if (!customMountPoint) {
|
|
|
|
setInterval(async () => {
|
|
|
|
const info = await scheduler.congratsInfo(empty);
|
|
|
|
page.$set({ info });
|
|
|
|
}, 60000);
|
|
|
|
}
|
2022-01-16 06:05:35 +01:00
|
|
|
|
|
|
|
return page;
|
2020-08-27 13:46:34 +02:00
|
|
|
}
|
2022-01-16 06:05:35 +01:00
|
|
|
|
|
|
|
setupCongrats();
|