forge
Explore
Log in

Don't you dare go Hollow

🐛 clearer message read state and exam finish dialog

Browse files at this commit

11850f1a7fabe1870fef08caf1b58595c1fc99e7Ahmet Kaan GümüşParent: 4f9c8ec
  • fix
    • 🐛 clearer message read state and exam finish dialog
Show full message
fix: 🐛 clearer message read state and exam finish dialog
- auto-mark opened received messages read (effect gated on message id
  so manual "mark as unread" is not undone)
- add mark-as-read/unread toggle button to the mail detail action bar;
  widen detail onAction to accept read
- add ConfirmDialog description prop (was hardcoded confirm.review)
- exam finish dialog now says "Yes, finish exam" with a plain-words
  hint that answers are turned in, destructive variant
- new i18n keys attempt.finishConfirm/finishHint,
  messages.markAsRead/markAsUnread (EN+TR)
- code map: add messages, homework component dirs
AGENTS.mdmodified+2 -1
@@ -37,7 +37,8 @@ instructions. Always written and read in English.
3737 - Components in the same domain live in the same folder: `components/notes/`,
3838 `components/events/`, `components/exams/`, `components/users/`,
3939 `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/`.
4142 - Cross-cutting app state lives in `src/stores/` (`auth-context.tsx`,
4243 `preferences-context.tsx`) — context providers only, never domain components.
4344 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 }) {
546546 <ConfirmDialog
547547 open={finishOpen()}
548548 onOpenChange={setFinishOpen}
549+ variant="destructive"
549550 title={t("attempt.finish")}
551+ description={t("attempt.finishHint")}
552+ confirmLabel={t("attempt.finishConfirm")}
550553 summary={props.exam.title}
551554 onConfirm={finish}
552555 />
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";
22 import type { Message, MessageFolder } from "@/api/client";
33 import { Badge } from "@/components/ui/badge";
44 import { Button } from "@/components/ui/button";
55 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";
77 import { postMessage } from "@/api/messages";
88 import { formatApiError } from "@/api/client";
99 import { personLabel } from "@/lib/person";
@@ -14,7 +14,7 @@ interface GmailMailDetailProps {
1414 currentUserId?: string;
1515 folder: string;
1616 onBack: () => void;
17- onAction: (action: { folder?: MessageFolder; delete?: boolean }) => Promise<void>;
17+ onAction: (action: { folder?: MessageFolder; delete?: boolean; read?: boolean }) => Promise<void>;
1818 onSuccess: () => void;
1919 setFlash: (text: string) => void;
2020 }
@@ -27,6 +27,21 @@ export function GmailMailDetail(props: GmailMailDetailProps) {
2727 const [error, setError] = createSignal("");
2828
2929 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+
3045 const peer = () => (isSent() ? props.message.recipient : props.message.sender);
3146 const peerName = () => personLabel(peer());
3247 const role = () => (isSent() ? props.message.recipient_role : props.message.sender_role);
@@ -109,6 +124,25 @@ export function GmailMailDetail(props: GmailMailDetailProps) {
109124
110125 <div class="h-4 w-[1px] bg-border mx-1" />
111126
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+
112146 {/* Move to Archive Action */}
113147 <Show when={props.folder !== "archive" && props.folder !== "trash"}>
114148 <Button
src/components/ui/confirm-dialog.tsxmodified+2 -1
@@ -18,6 +18,7 @@ export type ConfirmDialogProps = {
1818 open: boolean;
1919 onOpenChange: (open: boolean) => void;
2020 title: string;
21+ description?: string;
2122 summary: JSX.Element | string;
2223 confirmLabel?: string;
2324 cancelLabel?: string;
@@ -57,7 +58,7 @@ export function ConfirmDialog(props: ConfirmDialogProps) {
5758 </span>
5859 <div class="min-w-0 space-y-1">
5960 <AlertDialogTitle>{props.title}</AlertDialogTitle>
60- <AlertDialogDescription>{t("confirm.review")}</AlertDialogDescription>
61+ <AlertDialogDescription>{props.description ?? t("confirm.review")}</AlertDialogDescription>
6162 </div>
6263 </AlertDialogHeader>
6364
src/i18n/messages.tsmodified+12 -0
@@ -468,6 +468,8 @@ export type MessageKey =
468468 | "attempt.start"
469469 | "attempt.resume"
470470 | "attempt.finish"
471+ | "attempt.finishConfirm"
472+ | "attempt.finishHint"
471473 | "attempt.status"
472474 | "attempt.remaining"
473475 | "attempt.attempt"
@@ -795,6 +797,8 @@ export type MessageKey =
795797 | "messages.sentToast"
796798 | "messages.to"
797799 | "messages.from"
800+ | "messages.markAsRead"
801+ | "messages.markAsUnread"
798802 | "messages.selectRecipient"
799803 | "calendar.title"
800804 | "calendar.today"
@@ -1279,6 +1283,8 @@ const en: Dict = {
12791283 "attempt.start": "Start exam",
12801284 "attempt.resume": "Resume exam",
12811285 "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.",
12821288 "attempt.status": "Status",
12831289 "attempt.remaining": "Remaining",
12841290 "attempt.attempt": "Attempt",
@@ -1617,6 +1623,8 @@ const en: Dict = {
16171623 "messages.sentToast": "Message sent.",
16181624 "messages.to": "To: ",
16191625 "messages.from": "From: ",
1626+ "messages.markAsRead": "Mark as read",
1627+ "messages.markAsUnread": "Mark as unread",
16201628 "messages.selectRecipient": "Please select a recipient.",
16211629 };
16221630
@@ -2095,6 +2103,8 @@ const tr: Dict = {
20952103 "attempt.start": "Sınava başla",
20962104 "attempt.resume": "Sınava devam et",
20972105 "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.",
20982108 "attempt.status": "Durum",
20992109 "attempt.remaining": "Kalan süre",
21002110 "attempt.attempt": "Deneme",
@@ -2433,6 +2443,8 @@ const tr: Dict = {
24332443 "messages.sentToast": "Mesaj gönderildi.",
24342444 "messages.to": "Kime: ",
24352445 "messages.from": "Kimden: ",
2446+ "messages.markAsRead": "Okundu olarak işaretle",
2447+ "messages.markAsUnread": "Okunmadı olarak işaretle",
24362448 "messages.selectRecipient": "Lütfen bir alıcı seçin.",
24372449 };
24382450