🐛 clearer message read state and exam finish dialog
Browse files at this commit11850f1a7fabe1870fef08caf1b58595c1fc99e7Parent: 4f9c8ec- fix
- 🐛 clearer message read state and exam finish dialog
5 changed files +56 -5
- AGENTS.md +2 -1
- src/components/exams/exam-room-ws.tsx +3 -0
- src/components/messages/gmail-mail-detail.tsx +37 -3
- src/components/ui/confirm-dialog.tsx +2 -1
- src/i18n/messages.ts +12 -0
AGENTS.mdmodified+2 -1
| @@ -37,7 +37,8 @@ instructions. Always written and read in English. | |||
| 37 | - Components in the same domain live in the same folder: `components/notes/`, | 37 | - Components in the same domain live in the same folder: `components/notes/`, |
| 38 | `components/events/`, `components/exams/`, `components/users/`, | 38 | `components/events/`, `components/exams/`, `components/users/`, |
| 39 | `components/attendance/`, `components/courses/`, `components/marks/`, | 39 | `components/attendance/`, `components/courses/`, `components/marks/`, |
| 40 | - `components/sessions/`, `components/layout/`, `components/ui/`. | 40 | + `components/sessions/`, `components/messages/`, `components/homework/`, |
| 41 | + `components/layout/`, `components/ui/`. | ||
| 41 | - Cross-cutting app state lives in `src/stores/` (`auth-context.tsx`, | 42 | - Cross-cutting app state lives in `src/stores/` (`auth-context.tsx`, |
| 42 | `preferences-context.tsx`) — context providers only, never domain components. | 43 | `preferences-context.tsx`) — context providers only, never domain components. |
| 43 | School-policy lists (exam kinds, attendance statuses, grade bands) come from | 44 | School-policy lists (exam kinds, attendance statuses, grade bands) come from |
src/components/exams/exam-room-ws.tsxmodified+3 -0
| @@ -546,7 +546,10 @@ export function ExamRoomWS(props: { exam: Exam }) { | |||
| 546 | <ConfirmDialog | 546 | <ConfirmDialog |
| 547 | open={finishOpen()} | 547 | open={finishOpen()} |
| 548 | onOpenChange={setFinishOpen} | 548 | onOpenChange={setFinishOpen} |
| 549 | + variant="destructive" | ||
| 549 | title={t("attempt.finish")} | 550 | title={t("attempt.finish")} |
| 551 | + description={t("attempt.finishHint")} | ||
| 552 | + confirmLabel={t("attempt.finishConfirm")} | ||
| 550 | summary={props.exam.title} | 553 | summary={props.exam.title} |
| 551 | onConfirm={finish} | 554 | onConfirm={finish} |
| 552 | /> | 555 | /> |
src/components/messages/gmail-mail-detail.tsxmodified+37 -3
| @@ -1,9 +1,9 @@ | |||
| 1 | -import { createSignal, Show } from "solid-js"; | 1 | +import { createEffect, createSignal, Show, untrack } from "solid-js"; |
| 2 | import type { Message, MessageFolder } from "@/api/client"; | 2 | import type { Message, MessageFolder } from "@/api/client"; |
| 3 | import { Badge } from "@/components/ui/badge"; | 3 | import { Badge } from "@/components/ui/badge"; |
| 4 | import { Button } from "@/components/ui/button"; | 4 | import { Button } from "@/components/ui/button"; |
| 5 | import { RichTextEditor } from "@/components/ui/rich-text-editor"; | 5 | import { RichTextEditor } from "@/components/ui/rich-text-editor"; |
| 6 | -import { IconSend, IconTrash, IconMessage, IconArchive, IconChevronLeft } from "@/components/ui/icons"; | 6 | +import { IconSend, IconTrash, IconMessage, IconArchive, IconChevronLeft, IconCheck } from "@/components/ui/icons"; |
| 7 | import { postMessage } from "@/api/messages"; | 7 | import { postMessage } from "@/api/messages"; |
| 8 | import { formatApiError } from "@/api/client"; | 8 | import { formatApiError } from "@/api/client"; |
| 9 | import { personLabel } from "@/lib/person"; | 9 | import { personLabel } from "@/lib/person"; |
| @@ -14,7 +14,7 @@ interface GmailMailDetailProps { | |||
| 14 | currentUserId?: string; | 14 | currentUserId?: string; |
| 15 | folder: string; | 15 | folder: string; |
| 16 | onBack: () => void; | 16 | onBack: () => void; |
| 17 | - onAction: (action: { folder?: MessageFolder; delete?: boolean }) => Promise<void>; | 17 | + onAction: (action: { folder?: MessageFolder; delete?: boolean; read?: boolean }) => Promise<void>; |
| 18 | onSuccess: () => void; | 18 | onSuccess: () => void; |
| 19 | setFlash: (text: string) => void; | 19 | setFlash: (text: string) => void; |
| 20 | } | 20 | } |
| @@ -27,6 +27,21 @@ export function GmailMailDetail(props: GmailMailDetailProps) { | |||
| 27 | const [error, setError] = createSignal(""); | 27 | const [error, setError] = createSignal(""); |
| 28 | 28 | ||
| 29 | const isSent = () => props.folder === "sent" || props.message.sender.id === props.currentUserId; | 29 | const isSent = () => props.folder === "sent" || props.message.sender.id === props.currentUserId; |
| 30 | + | ||
| 31 | + // Auto-mark an opened received message as read, once per message. Gated on | ||
| 32 | + // message id (not `read`) so a manual "mark as unread" is not undone. | ||
| 33 | + let autoReadId: string | undefined; | ||
| 34 | + createEffect(() => { | ||
| 35 | + const id = props.message?.id; | ||
| 36 | + if (!id || id === autoReadId) return; | ||
| 37 | + autoReadId = id; | ||
| 38 | + untrack(() => { | ||
| 39 | + if (!isSent() && !props.message.read) { | ||
| 40 | + void props.onAction({ read: true }); | ||
| 41 | + } | ||
| 42 | + }); | ||
| 43 | + }); | ||
| 44 | + | ||
| 30 | const peer = () => (isSent() ? props.message.recipient : props.message.sender); | 45 | const peer = () => (isSent() ? props.message.recipient : props.message.sender); |
| 31 | const peerName = () => personLabel(peer()); | 46 | const peerName = () => personLabel(peer()); |
| 32 | const role = () => (isSent() ? props.message.recipient_role : props.message.sender_role); | 47 | const role = () => (isSent() ? props.message.recipient_role : props.message.sender_role); |
| @@ -109,6 +124,25 @@ export function GmailMailDetail(props: GmailMailDetailProps) { | |||
| 109 | 124 | ||
| 110 | <div class="h-4 w-[1px] bg-border mx-1" /> | 125 | <div class="h-4 w-[1px] bg-border mx-1" /> |
| 111 | 126 | ||
| 127 | + {/* Mark as Read / Unread (received messages only) */} | ||
| 128 | + <Show when={!isSent()}> | ||
| 129 | + <Button | ||
| 130 | + variant="ghost" | ||
| 131 | + size="sm" | ||
| 132 | + class="h-8 rounded-lg text-xs" | ||
| 133 | + onClick={() => props.onAction({ read: !props.message.read })} | ||
| 134 | + title={props.message.read ? t("messages.markAsUnread") : t("messages.markAsRead")} | ||
| 135 | + > | ||
| 136 | + <Show | ||
| 137 | + when={props.message.read} | ||
| 138 | + fallback={<IconCheck class="mr-1.5 h-3.5 w-3.5" />} | ||
| 139 | + > | ||
| 140 | + <IconMessage class="mr-1.5 h-3.5 w-3.5" /> | ||
| 141 | + </Show> | ||
| 142 | + {props.message.read ? t("messages.markAsUnread") : t("messages.markAsRead")} | ||
| 143 | + </Button> | ||
| 144 | + </Show> | ||
| 145 | + | ||
| 112 | {/* Move to Archive Action */} | 146 | {/* Move to Archive Action */} |
| 113 | <Show when={props.folder !== "archive" && props.folder !== "trash"}> | 147 | <Show when={props.folder !== "archive" && props.folder !== "trash"}> |
| 114 | <Button | 148 | <Button |
src/components/ui/confirm-dialog.tsxmodified+2 -1
| @@ -18,6 +18,7 @@ export type ConfirmDialogProps = { | |||
| 18 | open: boolean; | 18 | open: boolean; |
| 19 | onOpenChange: (open: boolean) => void; | 19 | onOpenChange: (open: boolean) => void; |
| 20 | title: string; | 20 | title: string; |
| 21 | + description?: string; | ||
| 21 | summary: JSX.Element | string; | 22 | summary: JSX.Element | string; |
| 22 | confirmLabel?: string; | 23 | confirmLabel?: string; |
| 23 | cancelLabel?: string; | 24 | cancelLabel?: string; |
| @@ -57,7 +58,7 @@ export function ConfirmDialog(props: ConfirmDialogProps) { | |||
| 57 | </span> | 58 | </span> |
| 58 | <div class="min-w-0 space-y-1"> | 59 | <div class="min-w-0 space-y-1"> |
| 59 | <AlertDialogTitle>{props.title}</AlertDialogTitle> | 60 | <AlertDialogTitle>{props.title}</AlertDialogTitle> |
| 60 | - <AlertDialogDescription>{t("confirm.review")}</AlertDialogDescription> | 61 | + <AlertDialogDescription>{props.description ?? t("confirm.review")}</AlertDialogDescription> |
| 61 | </div> | 62 | </div> |
| 62 | </AlertDialogHeader> | 63 | </AlertDialogHeader> |
| 63 | 64 | ||
src/i18n/messages.tsmodified+12 -0
| @@ -468,6 +468,8 @@ export type MessageKey = | |||
| 468 | | "attempt.start" | 468 | | "attempt.start" |
| 469 | | "attempt.resume" | 469 | | "attempt.resume" |
| 470 | | "attempt.finish" | 470 | | "attempt.finish" |
| 471 | + | "attempt.finishConfirm" | ||
| 472 | + | "attempt.finishHint" | ||
| 471 | | "attempt.status" | 473 | | "attempt.status" |
| 472 | | "attempt.remaining" | 474 | | "attempt.remaining" |
| 473 | | "attempt.attempt" | 475 | | "attempt.attempt" |
| @@ -795,6 +797,8 @@ export type MessageKey = | |||
| 795 | | "messages.sentToast" | 797 | | "messages.sentToast" |
| 796 | | "messages.to" | 798 | | "messages.to" |
| 797 | | "messages.from" | 799 | | "messages.from" |
| 800 | + | "messages.markAsRead" | ||
| 801 | + | "messages.markAsUnread" | ||
| 798 | | "messages.selectRecipient" | 802 | | "messages.selectRecipient" |
| 799 | | "calendar.title" | 803 | | "calendar.title" |
| 800 | | "calendar.today" | 804 | | "calendar.today" |
| @@ -1279,6 +1283,8 @@ const en: Dict = { | |||
| 1279 | "attempt.start": "Start exam", | 1283 | "attempt.start": "Start exam", |
| 1280 | "attempt.resume": "Resume exam", | 1284 | "attempt.resume": "Resume exam", |
| 1281 | "attempt.finish": "Finish exam", | 1285 | "attempt.finish": "Finish exam", |
| 1286 | + "attempt.finishConfirm": "Yes, finish exam", | ||
| 1287 | + "attempt.finishHint": "This ends the exam and turns in your answers. You can't change them afterwards.", | ||
| 1282 | "attempt.status": "Status", | 1288 | "attempt.status": "Status", |
| 1283 | "attempt.remaining": "Remaining", | 1289 | "attempt.remaining": "Remaining", |
| 1284 | "attempt.attempt": "Attempt", | 1290 | "attempt.attempt": "Attempt", |
| @@ -1617,6 +1623,8 @@ const en: Dict = { | |||
| 1617 | "messages.sentToast": "Message sent.", | 1623 | "messages.sentToast": "Message sent.", |
| 1618 | "messages.to": "To: ", | 1624 | "messages.to": "To: ", |
| 1619 | "messages.from": "From: ", | 1625 | "messages.from": "From: ", |
| 1626 | + "messages.markAsRead": "Mark as read", | ||
| 1627 | + "messages.markAsUnread": "Mark as unread", | ||
| 1620 | "messages.selectRecipient": "Please select a recipient.", | 1628 | "messages.selectRecipient": "Please select a recipient.", |
| 1621 | }; | 1629 | }; |
| 1622 | 1630 | ||
| @@ -2095,6 +2103,8 @@ const tr: Dict = { | |||
| 2095 | "attempt.start": "Sınava başla", | 2103 | "attempt.start": "Sınava başla", |
| 2096 | "attempt.resume": "Sınava devam et", | 2104 | "attempt.resume": "Sınava devam et", |
| 2097 | "attempt.finish": "Sınavı bitir", | 2105 | "attempt.finish": "Sınavı bitir", |
| 2106 | + "attempt.finishConfirm": "Evet, sınavı bitir", | ||
| 2107 | + "attempt.finishHint": "Bu, sınavı bitirir ve cevaplarını teslim eder. Sonrasında cevaplarını değiştiremezsin.", | ||
| 2098 | "attempt.status": "Durum", | 2108 | "attempt.status": "Durum", |
| 2099 | "attempt.remaining": "Kalan süre", | 2109 | "attempt.remaining": "Kalan süre", |
| 2100 | "attempt.attempt": "Deneme", | 2110 | "attempt.attempt": "Deneme", |
| @@ -2433,6 +2443,8 @@ const tr: Dict = { | |||
| 2433 | "messages.sentToast": "Mesaj gönderildi.", | 2443 | "messages.sentToast": "Mesaj gönderildi.", |
| 2434 | "messages.to": "Kime: ", | 2444 | "messages.to": "Kime: ", |
| 2435 | "messages.from": "Kimden: ", | 2445 | "messages.from": "Kimden: ", |
| 2446 | + "messages.markAsRead": "Okundu olarak işaretle", | ||
| 2447 | + "messages.markAsUnread": "Okunmadı olarak işaretle", | ||
| 2436 | "messages.selectRecipient": "Lütfen bir alıcı seçin.", | 2448 | "messages.selectRecipient": "Lütfen bir alıcı seçin.", |
| 2437 | }; | 2449 | }; |
| 2438 | 2450 | ||