mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
fix: fix engage not always applying
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user