fix: fix engage not always applying

This commit is contained in:
2026-04-10 21:21:19 +09:30
parent 39d0b60024
commit 2e9a643a8c
+27 -8
View File
@@ -6,6 +6,7 @@ import { convertTo12HourFormat } from "@/seqta/utils/convertTo12HourFormat";
import debounce from "@/seqta/utils/debounce"; import debounce from "@/seqta/utils/debounce";
import { settingsState } from "@/seqta/utils/listeners/SettingsState"; import { settingsState } from "@/seqta/utils/listeners/SettingsState";
import stringToHTML from "@/seqta/utils/stringToHTML"; import stringToHTML from "@/seqta/utils/stringToHTML";
import { waitForElm } from "@/seqta/utils/waitForElm";
import { getMockNotices } from "@/seqta/ui/dev/hideSensitiveContent"; import { getMockNotices } from "@/seqta/ui/dev/hideSensitiveContent";
import { import {
type EngageParentChild, type EngageParentChild,
@@ -717,17 +718,30 @@ function showEngageTimetableError(message: string): void {
</div>`; </div>`;
} }
function showEngageNoticesSectionError(message: string): void {
const noticeContainer = document.getElementById(ENGAGE_NOTICE_CONTAINER_ID);
if (!noticeContainer) return;
noticeContainer.classList.remove("loading");
noticeContainer.innerHTML = `
<div class="day-empty">
<img src="${browser.runtime.getURL(LogoLight)}" alt="" />
<p>${message}</p>
</div>`;
}
/** SEQTA Engage parent home: child timetable (today view) using parent APIs. */ /** SEQTA Engage parent home: child timetable (today view) using parent APIs. */
export async function loadEngageHomePage(allowRetry = true): Promise<void> { export async function loadEngageHomePage(): Promise<void> {
updateEngageHomeMenuActive(true); updateEngageHomeMenuActive(true);
document.title = "Home ― SEQTA Engage"; document.title = "Home ― SEQTA Engage";
const main = document.getElementById("main"); let main: HTMLElement;
if (!main) { try {
if (allowRetry) { /* Engage mounts `#main` after React hydrates; a single rAF often loses the race on cold load. */
await new Promise<void>((r) => requestAnimationFrame(() => r())); main = (await waitForElm("#main", true, 100, 200)) as HTMLElement;
return loadEngageHomePage(false); } catch {
} console.warn(
"[BetterSEQTA+] Engage home: timed out waiting for #main (shell not ready).",
);
return; return;
} }
@@ -773,6 +787,7 @@ export async function loadEngageHomePage(allowRetry = true): Promise<void> {
console.error( console.error(
"[BetterSEQTA+] Engage home: parsed markup had no root element (check DOMPurify / stringToHTML).", "[BetterSEQTA+] Engage home: parsed markup had no root element (check DOMPurify / stringToHTML).",
); );
return;
} }
bindEngageTimetableUi(); bindEngageTimetableUi();
@@ -794,7 +809,11 @@ export async function loadEngageHomePage(allowRetry = true): Promise<void> {
return; return;
} }
if (!select) return; if (!select) {
showEngageTimetableError("Could not initialize the home view.");
showEngageNoticesSectionError("Could not initialize notices.");
return;
}
if (children.length === 0) { if (children.length === 0) {
select.disabled = true; select.disabled = true;