Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ interface Preview {
}

interface GetPreferencesResponse {
notifications_disabled: boolean;
individual_preference: EventPreferences;
preview: Preview;
templates: TemplateVariables;
Expand Down
33 changes: 28 additions & 5 deletions client/src/routes/calendar/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
let templates: TemplateVariables | undefined = $derived(currentEventPrefs?.templates);
let resolved: ResolvedData | undefined = $derived(currentEventPrefs?.resolved);
let editMode = $state(false);
let notificationsDisabled = $state(false);

let titleTemplates = [
"{% if schedule_type == 'Laboratory' %}{{title | remove: '- Lab'}} - {{schedule_type_short}}{% else %}{{title}}{% endif %}",
Expand Down Expand Up @@ -643,6 +644,7 @@
location_template: string;
reminder_settings: ReminderSettings[];
color_id: string;
notifications_disabled: boolean;
}> = {};

const titleChanged = editTitle !== (resolved?.title_template ?? titleTemplates[0]);
Expand Down Expand Up @@ -680,6 +682,8 @@
event_preference.reminder_settings = convertedNotifications;
}

event_preference.notifications_disabled = notificationsDisabled;

if (Object.keys(event_preference).length === 0) {
activeCourse = undefined;
activeMeeting = undefined;
Expand Down Expand Up @@ -908,6 +912,7 @@
editDescriptionManual = currentEventPrefs.preview?.description ?? "";
editLocationManual = currentEventPrefs.preview?.location ?? "";
courseColor = resolved?.color_id ?? "#d50000";
notificationsDisabled = currentEventPrefs.notifications_disabled ?? false;

if (resolved?.reminder_settings && resolved.reminder_settings.length > 0) {
//@ts-ignore
Expand Down Expand Up @@ -1157,31 +1162,49 @@
</div>
{/if}
<div class="flex flex-col gap-3">
<h2 class="text-md">Remind me before class</h2>
<div class="flex flex-row items-center gap-2 justify-between">
<h2 class="text-md">Remind me before class</h2>
{#if notificationsDisabled}
<div class="flex flex-row items-center gap-1 text-error" title="All reminders are currently disabled in Settings. Your reminder preferences are saved and will be restored when you re-enable notifications.">
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"/>
<line x1="3" y1="3" x2="21" y2="21" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/>
</svg>
<span class="text-xs font-medium">Do Not Disturb</span>
</div>
{/if}
</div>
{#if notificationsDisabled}
<p class="text-sm text-on-surface-variant bg-error-container/20 p-3 rounded-md border border-error-container">
<strong>Reminders are muted.</strong> Your settings are preserved but notifications are currently disabled. Re-enable notifications in Settings to activate them.
</p>
{/if}
{#each notifications, i}
<div class="flex flex-row gap-2 items-center stuff-moment peak">
<div class="flex flex-row gap-2 items-center stuff-moment peak {notificationsDisabled ? 'opacity-50' : ''}">
<SelectOutlined label=""
options={[
{ text: "Notification", value: "notification" },
{ text: "Email", value: "email" },
]}
bind:value={notifications[i].method}
disabled={notificationsDisabled}
/>
<TextFieldOutlined type="number" label="" bind:value={notifications[i].time} />
<TextFieldOutlined type="number" label="" bind:value={notifications[i].time} disabled={notificationsDisabled} />
<SelectOutlined label=""
options={[
{ text: "minutes", value: "minutes" },
{ text: "hours", value: "hours" },
{ text: "days", value: "days" },
]}
bind:value={notifications[i].type}
disabled={notificationsDisabled}
/>
<Button variant="tonal" onclick={() => { notifications = notifications.filter((_, idx) => idx !== i); }}>
<Button variant="tonal" onclick={() => { notifications = notifications.filter((_, idx) => idx !== i); }} disabled={notificationsDisabled}>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M6 13q-.425 0-.712-.288T5 12t.288-.712T6 11h12q.425 0 .713.288T19 12t-.288.713T18 13z"/></svg>
</Button>
</div>
{/each}
<Button variant="tonal" onclick={() => { notifications = [...notifications, { time: "30", type: "minutes", method: "notification" }]; }}>
<Button variant="tonal" onclick={() => { notifications = [...notifications, { time: "30", type: "minutes", method: "notification" }]; }} disabled={notificationsDisabled}>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 21q-.425 0-.712-.288T11 20v-7H4q-.425 0-.712-.288T3 12t.288-.712T4 11h7V4q0-.425.288-.712T12 3t.713.288T13 4v7h7q.425 0 .713.288T21 12t-.288.713T20 13h-7v7q0 .425-.288.713T12 21"/></svg>
</Button>
<h2 class="text-md">Color</h2>
Expand Down