From f7062a03fe53ccd8a86f5ef596b69fddb5421574 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 8 Jul 2023 20:09:40 +0000 Subject: [PATCH] Show popups at client init --- packages/client/src/init.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index 1c68b87c9..1b85ef9c6 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -36,7 +36,7 @@ import { version, ui, lang, host } from "@/config"; import { applyTheme } from "@/scripts/theme"; import { isDeviceDarkmode } from "@/scripts/is-device-darkmode"; import { i18n } from "@/i18n"; -import { confirm, alert, post, popup, toast } from "@/os"; +import { confirm, alert, post, popup, toast, api } from "@/os"; import { stream } from "@/stream"; import * as sound from "@/scripts/sound"; import { $i, refreshAccount, login, updateAccount, signout } from "@/account"; @@ -272,6 +272,25 @@ function checkForSplash() { } } + if ($i) { + api("announcements", { withUnreads: true }) + .then((announcements) => { + console.log(announcements); + announcements.forEach((announcement) => { + if (announcement.showPopup && announcement.isRead === false) + popup( + defineAsyncComponent( + () => import("@/components/MkAnnouncement.vue"), + ), + { announcement: announcement }, + {}, + "closed", + ); + }); + }) + .catch((err) => console.log(err)); + } + // NOTE: この処理は必ず↑のクライアント更新時処理より後に来ること(テーマ再構築のため) watch( defaultStore.reactiveState.darkMode,