From fea017bbd7337604a48efe040fdf852ae28ce98e Mon Sep 17 00:00:00 2001 From: Aden Linday Date: Thu, 29 Oct 2026 09:44:12 +1030 Subject: [PATCH] feat: add TOS popup and new update vid --- .../pages/settings/sections/advanced.svelte | 9 +- src/resources/update-video.webm | Bin 1078262 -> 1644314 bytes .../Openers/OpenTermsOfServicePopup.test.ts | 79 +++++ .../utils/Openers/OpenTermsOfServicePopup.ts | 291 ++++++++++++++++++ src/seqta/utils/Openers/StartupPopupQueue.ts | 19 +- .../utils/ensureSyncableStorageDefaults.ts | 1 + src/seqta/utils/listeners/SettingsState.ts | 1 + src/types/storage.ts | 2 + 8 files changed, 397 insertions(+), 5 deletions(-) create mode 100644 src/seqta/utils/Openers/OpenTermsOfServicePopup.test.ts create mode 100644 src/seqta/utils/Openers/OpenTermsOfServicePopup.ts diff --git a/src/interface/pages/settings/sections/advanced.svelte b/src/interface/pages/settings/sections/advanced.svelte index 5264a841..a51f3e21 100644 --- a/src/interface/pages/settings/sections/advanced.svelte +++ b/src/interface/pages/settings/sections/advanced.svelte @@ -2,7 +2,7 @@ import Switch from "@/interface/components/Switch.svelte"; import Button from "@/interface/components/Button.svelte"; import { settingsState } from "@/seqta/utils/listeners/SettingsState"; - import { showPrivacyNotification } from "@/seqta/utils/Openers/OpenPrivacyNotification"; + import { openTermsOfServicePopup } from "@/seqta/utils/Openers/OpenTermsOfServicePopup"; import { showThemeOfTheMonthPopupNow } from "@/seqta/utils/Openers/OpenThemeOfTheMonthPopup"; import { closeExtensionPopup } from "@/seqta/utils/Closers/closeExtensionPopup"; import { getSnapshotForUpload } from "@/seqta/utils/cloudSettingsSync"; @@ -139,19 +139,20 @@
-

Show Privacy Notification

+

Show Terms of Service

- Show the privacy notification popup on next page load + Show the terms of service acceptance popup (same as startup queue)

+ +
+ `).firstChild as HTMLElement; + + body.append(intro, scrollContent, actions); + + const isDark = settingsState.DarkMode; + + openPopup({ + header, + content: [body], + containerClass: "whatsnewContainer--scrollBody whatsnewContainer--compact", + backgroundClass: isDark + ? "bsplus-tos-overlay bsplus-tos-overlay--dark" + : "bsplus-tos-overlay", + hideCloseButton: true, + closeOnBackdrop: false, + closeOnEscape: false, + animateSelector: ".bsplus-tos-body > *", + afterClose: onDismissed, + actions: [ + { + id: "bsplus-tos-accept", + onClick: () => { + markTermsOfServiceAccepted(settingsState, terms.last_updated); + void closePopup(); + }, + }, + { + id: "bsplus-tos-decline", + onClick: () => { + void closePopup(); + }, + }, + ], + onReady: ({ container }) => { + container.setAttribute("role", "dialog"); + container.setAttribute("aria-modal", "true"); + container.setAttribute("aria-labelledby", "bsplus-tos-title"); + const title = container.querySelector(".whatsnewHeader h1"); + if (title) title.id = "bsplus-tos-title"; + }, + }); +} diff --git a/src/seqta/utils/Openers/StartupPopupQueue.ts b/src/seqta/utils/Openers/StartupPopupQueue.ts index 4635e5a3..dd39e864 100644 --- a/src/seqta/utils/Openers/StartupPopupQueue.ts +++ b/src/seqta/utils/Openers/StartupPopupQueue.ts @@ -11,6 +11,11 @@ import { shouldShowCoursesAssessmentsFixPopup, } from "./OpenCoursesAssessmentsFixPopup"; import { syncApiBaseToBackground } from "../DevApiBase"; +import { + fetchPrivacyTerms, + openTermsOfServicePopup, + shouldShowTermsOfServicePopup, +} from "./OpenTermsOfServicePopup"; type QueueStep = (goNext: () => void) => void; @@ -18,7 +23,8 @@ type QueueStep = (goNext: () => void) => void; * Runs startup modals in order: What's New (if the extension just updated), * Courses/Assessments fix notice (only if features are off), * Theme of the Month (when the user hasn't dismissed this calendar month), - * then feedback reply notifications for pending submissions. + * feedback reply notifications for pending submissions, then terms of service + * acceptance (always last). */ export async function runStartupPopupQueue() { // Make sure the background script knows about any dev-mode API override @@ -50,6 +56,17 @@ export async function runStartupPopupQueue() { steps.push(feedbackReplyStep); } + steps.push((goNext) => { + void (async () => { + const privacyTerms = await fetchPrivacyTerms(); + if (!shouldShowTermsOfServicePopup(settingsState, privacyTerms)) { + goNext(); + return; + } + await openTermsOfServicePopup(goNext, { terms: privacyTerms }); + })(); + }); + function runNext() { const step = steps.shift(); if (step) step(runNext); diff --git a/src/seqta/utils/ensureSyncableStorageDefaults.ts b/src/seqta/utils/ensureSyncableStorageDefaults.ts index 0423b064..90eddc56 100644 --- a/src/seqta/utils/ensureSyncableStorageDefaults.ts +++ b/src/seqta/utils/ensureSyncableStorageDefaults.ts @@ -24,6 +24,7 @@ const OPTIONAL_UNSET_MEANS_DEFAULT_KEYS = [ "selectedFont", "privacyStatementShown", "privacyStatementLastUpdated", + "termsOfServiceLastAccepted", "bsCloudAutoSyncAnnouncementShown", "coursesAssessmentsFixPopupShown", "themeOfTheMonthDismissedMonth", diff --git a/src/seqta/utils/listeners/SettingsState.ts b/src/seqta/utils/listeners/SettingsState.ts index 965698e8..aef6aa44 100644 --- a/src/seqta/utils/listeners/SettingsState.ts +++ b/src/seqta/utils/listeners/SettingsState.ts @@ -35,6 +35,7 @@ const SETTINGS_STORAGE_KEYS = [ "mockNotices", "hideSensitiveContent", "privacyStatementLastUpdated", + "termsOfServiceLastAccepted", "themeOfTheMonthDismissedMonth", "themeOfTheMonthLastSeenId", ...PLUGIN_SETTINGS_KEYS, diff --git a/src/types/storage.ts b/src/types/storage.ts index a1b8fb68..e0b353fe 100644 --- a/src/types/storage.ts +++ b/src/types/storage.ts @@ -36,6 +36,8 @@ export interface SettingsState { justupdated?: boolean; privacyStatementShown?: boolean; privacyStatementLastUpdated?: string; + /** ISO timestamp from `/api/privacy` `last_updated` when the user accepted ToS. */ + termsOfServiceLastAccepted?: string; /** One-time announcement: BS Cloud automatic settings sync (last in startup popup queue). */ bsCloudAutoSyncAnnouncementShown?: boolean; /** One-time notice when BetterSEQTA features are off after the Courses/Assessments fix. */