🐛 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 | 37 | - Components in the same domain live in the same folder: `components/notes/`, |
| 38 | 38 | `components/events/`, `components/exams/`, `components/users/`, |
| 39 | 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 | 42 | - Cross-cutting app state lives in `src/stores/` (`auth-context.tsx`, |
| 42 | 43 | `preferences-context.tsx`) — context providers only, never domain components. |
| 43 | 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 | 546 | <ConfirmDialog |
| 547 | 547 | open={finishOpen()} |
| 548 | 548 | onOpenChange={setFinishOpen} |
| 549 | + variant="destructive" | |
| 549 | 550 | title={t("attempt.finish")} |
| 551 | + description={t("attempt.finishHint")} | |
| 552 | + confirmLabel={t("attempt.finishConfirm")} | |
| 550 | 553 | summary={props.exam.title} |
| 551 | 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 | 2 | import type { Message, MessageFolder } from "@/api/client"; |
| 3 | 3 | import { Badge } from "@/components/ui/badge"; |
| 4 | 4 | import { Button } from "@/components/ui/button"; |
| 5 | 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 | 7 | import { postMessage } from "@/api/messages"; |
| 8 | 8 | import { formatApiError } from "@/api/client"; |
| 9 | 9 | import { personLabel } from "@/lib/person"; |
| @@ -14,7 +14,7 @@ interface GmailMailDetailProps { | ||
| 14 | 14 | currentUserId?: string; |
| 15 | 15 | folder: string; |
| 16 | 16 | onBack: () => void; |
| 17 | - onAction: (action: { folder?: MessageFolder; delete?: boolean }) => Promise<void>; | |
| 17 | + onAction: (action: { folder?: MessageFolder; delete?: boolean; read?: boolean }) => Promise<void>; | |
| 18 | 18 | onSuccess: () => void; |
| 19 | 19 | setFlash: (text: string) => void; |
| 20 | 20 | } |
| @@ -27,6 +27,21 @@ export function GmailMailDetail(props: GmailMailDetailProps) { | ||
| 27 | 27 | const [error, setError] = createSignal(""); |
| 28 | 28 | |
| 29 | 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 | 45 | const peer = () => (isSent() ? props.message.recipient : props.message.sender); |
| 31 | 46 | const peerName = () => personLabel(peer()); |
| 32 | 47 | const role = () => (isSent() ? props.message.recipient_role : props.message.sender_role); |
| @@ -109,6 +124,25 @@ export function GmailMailDetail(props: GmailMailDetailProps) { | ||
| 109 | 124 | |
| 110 | 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 | 146 | {/* Move to Archive Action */} |
| 113 | 147 | <Show when={props.folder !== "archive" && props.folder !== "trash"}> |
| 114 | 148 | <Button |
src/components/ui/confirm-dialog.tsxmodified+2 -1
| @@ -18,6 +18,7 @@ export type ConfirmDialogProps = { | ||
| 18 | 18 | open: boolean; |
| 19 | 19 | onOpenChange: (open: boolean) => void; |
| 20 | 20 | title: string; |
| 21 | + description?: string; | |
| 21 | 22 | summary: JSX.Element | string; |
| 22 | 23 | confirmLabel?: string; |
| 23 | 24 | cancelLabel?: string; |
| @@ -57,7 +58,7 @@ export function ConfirmDialog(props: ConfirmDialogProps) { | ||
| 57 | 58 | </span> |
| 58 | 59 | <div class="min-w-0 space-y-1"> |
| 59 | 60 | <AlertDialogTitle>{props.title}</AlertDialogTitle> |
| 60 | - <AlertDialogDescription>{t("confirm.review")}</AlertDialogDescription> | |
| 61 | + <AlertDialogDescription>{props.description ?? t("confirm.review")}</AlertDialogDescription> | |
| 61 | 62 | </div> |
| 62 | 63 | </AlertDialogHeader> |
| 63 | 64 |
src/i18n/messages.tsmodified+12 -0
| @@ -468,6 +468,8 @@ export type MessageKey = | ||
| 468 | 468 | | "attempt.start" |
| 469 | 469 | | "attempt.resume" |
| 470 | 470 | | "attempt.finish" |
| 471 | + | "attempt.finishConfirm" | |
| 472 | + | "attempt.finishHint" | |
| 471 | 473 | | "attempt.status" |
| 472 | 474 | | "attempt.remaining" |
| 473 | 475 | | "attempt.attempt" |
| @@ -795,6 +797,8 @@ export type MessageKey = | ||
| 795 | 797 | | "messages.sentToast" |
| 796 | 798 | | "messages.to" |
| 797 | 799 | | "messages.from" |
| 800 | + | "messages.markAsRead" | |
| 801 | + | "messages.markAsUnread" | |
| 798 | 802 | | "messages.selectRecipient" |
| 799 | 803 | | "calendar.title" |
| 800 | 804 | | "calendar.today" |
| @@ -1279,6 +1283,8 @@ const en: Dict = { | ||
| 1279 | 1283 | "attempt.start": "Start exam", |
| 1280 | 1284 | "attempt.resume": "Resume exam", |
| 1281 | 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 | 1288 | "attempt.status": "Status", |
| 1283 | 1289 | "attempt.remaining": "Remaining", |
| 1284 | 1290 | "attempt.attempt": "Attempt", |
| @@ -1617,6 +1623,8 @@ const en: Dict = { | ||
| 1617 | 1623 | "messages.sentToast": "Message sent.", |
| 1618 | 1624 | "messages.to": "To: ", |
| 1619 | 1625 | "messages.from": "From: ", |
| 1626 | + "messages.markAsRead": "Mark as read", | |
| 1627 | + "messages.markAsUnread": "Mark as unread", | |
| 1620 | 1628 | "messages.selectRecipient": "Please select a recipient.", |
| 1621 | 1629 | }; |
| 1622 | 1630 | |
| @@ -2095,6 +2103,8 @@ const tr: Dict = { | ||
| 2095 | 2103 | "attempt.start": "Sınava başla", |
| 2096 | 2104 | "attempt.resume": "Sınava devam et", |
| 2097 | 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 | 2108 | "attempt.status": "Durum", |
| 2099 | 2109 | "attempt.remaining": "Kalan süre", |
| 2100 | 2110 | "attempt.attempt": "Deneme", |
| @@ -2433,6 +2443,8 @@ const tr: Dict = { | ||
| 2433 | 2443 | "messages.sentToast": "Mesaj gönderildi.", |
| 2434 | 2444 | "messages.to": "Kime: ", |
| 2435 | 2445 | "messages.from": "Kimden: ", |
| 2446 | + "messages.markAsRead": "Okundu olarak işaretle", | |
| 2447 | + "messages.markAsUnread": "Okunmadı olarak işaretle", | |
| 2436 | 2448 | "messages.selectRecipient": "Lütfen bir alıcı seçin.", |
| 2437 | 2449 | }; |
| 2438 | 2450 |