🔔 refine messages and notifications
Browse files at this commit81b2656ccbfc0fdd87d2313557a6c2660a330f3eParent: e1768cd- fix
- 🔔 refine messages and notifications
5 changed files +242 -88
- src/components/layout/app-shell.tsx +1 -14
- src/components/layout/notification-center.tsx +198 -55
- src/i18n/messages.ts +3 -0
- src/lib/notifications.ts +27 -0
- src/pages/messages-page.tsx +13 -19
src/components/layout/app-shell.tsxmodified+1 -14
| @@ -21,7 +21,6 @@ import { celebiPanelOpen, openCelebiPanel, setCelebiPanelOpen } from "@/stores/c | ||
| 21 | 21 | import { commandPaletteOpen, openCommandPalette, setCommandPaletteOpen } from "@/stores/command-palette"; |
| 22 | 22 | import { ShellFeedProvider } from "@/stores/shell-feed-context"; |
| 23 | 23 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 24 | -import { useGoBack } from "@/lib/use-go-back"; | |
| 25 | 24 | import { cn } from "@/lib/cn"; |
| 26 | 25 | import { ModuleGate } from "@/components/layout/module-gate"; |
| 27 | 26 | |
| @@ -38,7 +37,6 @@ export function AppShell(props: ParentProps) { | ||
| 38 | 37 | const [profileOpen, setProfileOpen] = createSignal(false); |
| 39 | 38 | const collapsed = () => prefs.sidebarCollapsed(); |
| 40 | 39 | const location = useLocation(); |
| 41 | - const goBack = useGoBack(); | |
| 42 | 40 | const fullScreen = () => location().pathname.startsWith("/exam-room/"); |
| 43 | 41 | const routeLabel = createMemo(() => { |
| 44 | 42 | const key = routeLabelKey(location().pathname, auth.user()?.role); |
| @@ -133,19 +131,8 @@ export function AppShell(props: ParentProps) { | ||
| 133 | 131 | |
| 134 | 132 | <main id="main-content" tabIndex={-1} class="min-w-0 flex-1 outline-hidden"> |
| 135 | 133 | <Show when={auth.user() && !fullScreen()}> |
| 136 | - <header class="sticky top-[env(safe-area-inset-top)] z-30 flex h-[45px] items-center gap-3 border-b border-border/70 bg-background px-4 sm:px-6 lg:px-4"> | |
| 134 | + <header class="sticky top-[env(safe-area-inset-top)] z-30 flex h-[49px] items-center gap-3 border-b border-border/70 bg-background px-4 pt-1.5 sm:px-6 lg:px-4"> | |
| 137 | 135 | <div class="flex min-w-0 shrink-0 items-center gap-2 sm:w-52 lg:w-[260px]"> |
| 138 | - <Show when={location().pathname !== "/"}> | |
| 139 | - <button | |
| 140 | - type="button" | |
| 141 | - onClick={goBack} | |
| 142 | - class="topbar-control flex h-9 w-9 shrink-0 items-center justify-center rounded-md outline-hidden focus-visible:ring-2 focus-visible:ring-ring" | |
| 143 | - aria-label={t("common.back")} | |
| 144 | - title={t("common.back")} | |
| 145 | - > | |
| 146 | - <IconChevronLeft class="h-4 w-4" /> | |
| 147 | - </button> | |
| 148 | - </Show> | |
| 149 | 136 | <span class="hidden truncate text-sm font-semibold sm:block" title={routeLabel()}>{routeLabel()}</span> |
| 150 | 137 | </div> |
| 151 | 138 |
src/components/layout/notification-center.tsxmodified+198 -55
| @@ -8,7 +8,9 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 8 | 8 | import { |
| 9 | 9 | IconBell, |
| 10 | 10 | IconCalendar, |
| 11 | + IconChevronLeft, | |
| 11 | 12 | IconExam, |
| 13 | + IconExternalLink, | |
| 12 | 14 | IconHomework, |
| 13 | 15 | IconMessage, |
| 14 | 16 | IconTrash, |
| @@ -20,7 +22,10 @@ import { | ||
| 20 | 22 | dismissAllNotificationIds, |
| 21 | 23 | dismissNotificationId, |
| 22 | 24 | getDismissedNotificationIds, |
| 25 | + getReadNotificationIds, | |
| 26 | + markNotificationRead, | |
| 23 | 27 | type NotificationItem, |
| 28 | + type NotificationType, | |
| 24 | 29 | } from "@/lib/notifications"; |
| 25 | 30 | import { usePreferences } from "@/stores/preferences-context"; |
| 26 | 31 | import { useShellFeed } from "@/stores/shell-feed-context"; |
| @@ -32,6 +37,8 @@ export function NotificationCenter() { | ||
| 32 | 37 | const feed = useShellFeed(); |
| 33 | 38 | const [open, setOpen] = createSignal(false); |
| 34 | 39 | const [dismissedIds, setDismissedIds] = createSignal<Set<string>>(getDismissedNotificationIds()); |
| 40 | + const [readIds, setReadIds] = createSignal<Set<string>>(getReadNotificationIds()); | |
| 41 | + const [previewNotification, setPreviewNotification] = createSignal<NotificationItem | null>(null); | |
| 35 | 42 | |
| 36 | 43 | // Shell feed data comes from the shared poller (ShellFeedProvider): one fetch |
| 37 | 44 | // per source for the whole shell instead of a duplicate set here. Every read |
| @@ -58,11 +65,13 @@ export function NotificationCenter() { | ||
| 58 | 65 | // id DESC, so an older unread message is simply not in it. |
| 59 | 66 | const msgs = feed.unreadMessages().items; |
| 60 | 67 | for (const m of msgs) { |
| 68 | + const body = m.body.replace(/<[^>]*>?/gm, "").trim(); | |
| 61 | 69 | list.push({ |
| 62 | 70 | id: `msg_${m.id}`, |
| 63 | 71 | type: "message", |
| 64 | 72 | title: personLabel(m.sender), |
| 65 | - description: m.subject || m.body.replace(/<[^>]*>?/gm, "").trim(), | |
| 73 | + description: m.subject || body, | |
| 74 | + preview: m.subject ? `${m.subject}\n${body}` : body, | |
| 66 | 75 | targetUrl: "/messages", |
| 67 | 76 | timestamp: m.sent_at, |
| 68 | 77 | }); |
| @@ -147,6 +156,37 @@ export function NotificationCenter() { | ||
| 147 | 156 | return allNotifications().filter((item) => !dismissed.has(item.id)); |
| 148 | 157 | }); |
| 149 | 158 | |
| 159 | + const isUnread = (item: NotificationItem) => !readIds().has(item.id); | |
| 160 | + const unreadNotifications = createMemo(() => activeNotifications().filter(isUnread)); | |
| 161 | + | |
| 162 | + const notificationGroupOrder: NotificationType[] = ["message", "event", "exam", "homework"]; | |
| 163 | + const notificationGroupLabel = (type: NotificationType) => { | |
| 164 | + if (type === "message") return t("nav.messages"); | |
| 165 | + if (type === "event") return t("events.title"); | |
| 166 | + if (type === "exam") return t("exams.title"); | |
| 167 | + return t("homework.title"); | |
| 168 | + }; | |
| 169 | + const notificationGroupTone = (type: NotificationType) => { | |
| 170 | + if (type === "message") return "border-primary/20 bg-primary/[0.035]"; | |
| 171 | + if (type === "event") return "border-violet-500/20 bg-violet-500/[0.035]"; | |
| 172 | + if (type === "exam") return "border-amber-500/25 bg-amber-500/[0.045]"; | |
| 173 | + return "border-emerald-500/20 bg-emerald-500/[0.035]"; | |
| 174 | + }; | |
| 175 | + const notificationGroupIconTone = (type: NotificationType) => { | |
| 176 | + if (type === "message") return "bg-primary/10 text-primary-text"; | |
| 177 | + if (type === "event") return "bg-violet-500/10 text-violet-700 dark:text-violet-300"; | |
| 178 | + if (type === "exam") return "bg-amber-500/10 text-amber-700 dark:text-amber-300"; | |
| 179 | + return "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"; | |
| 180 | + }; | |
| 181 | + const notificationGroups = createMemo(() => | |
| 182 | + notificationGroupOrder | |
| 183 | + .map((type) => ({ | |
| 184 | + type, | |
| 185 | + items: activeNotifications().filter((item) => item.type === type), | |
| 186 | + })) | |
| 187 | + .filter((group) => group.items.length > 0) | |
| 188 | + ); | |
| 189 | + | |
| 150 | 190 | // The list only holds the newest 10 unread messages; `total` is the real |
| 151 | 191 | // server-side unread count, so the rest still counts towards the badge. |
| 152 | 192 | // Those extra rows have no id here, so they cannot be dismissed one by one: |
| @@ -166,7 +206,7 @@ export function NotificationCenter() { | ||
| 166 | 206 | const sinceDismissAll = page.total - dismissedUnreadTotal() - activeMessageCount(); |
| 167 | 207 | return Math.max(0, Math.min(beyondPage, sinceDismissAll)); |
| 168 | 208 | }; |
| 169 | - const unreadCount = () => activeNotifications().length + unlistedUnread(); | |
| 209 | + const unreadCount = () => unreadNotifications().length + unlistedUnread(); | |
| 170 | 210 | |
| 171 | 211 | const handleDismissSingle = (evt: MouseEvent, id: string) => { |
| 172 | 212 | evt.stopPropagation(); |
| @@ -182,7 +222,11 @@ export function NotificationCenter() { | ||
| 182 | 222 | }; |
| 183 | 223 | |
| 184 | 224 | const handleSelectNotification = async (item: NotificationItem) => { |
| 185 | - // If message notification, mark read in backend | |
| 225 | + if (isUnread(item)) { | |
| 226 | + setReadIds(new Set(markNotificationRead(item.id))); | |
| 227 | + } | |
| 228 | + | |
| 229 | + // Message notifications also need to be marked read in the backend. | |
| 186 | 230 | if (item.id.startsWith("msg_")) { |
| 187 | 231 | const realId = item.id.replace("msg_", ""); |
| 188 | 232 | try { |
| @@ -192,15 +236,27 @@ export function NotificationCenter() { | ||
| 192 | 236 | // ignore |
| 193 | 237 | } |
| 194 | 238 | } |
| 195 | - // Dismiss locally | |
| 196 | - const updated = dismissNotificationId(item.id); | |
| 197 | - setDismissedIds(new Set(updated)); | |
| 239 | + setPreviewNotification(item); | |
| 240 | + }; | |
| 241 | + | |
| 242 | + const handleNavigateToNotification = () => { | |
| 243 | + const item = previewNotification(); | |
| 244 | + if (!item) return; | |
| 245 | + setPreviewNotification(null); | |
| 198 | 246 | setOpen(false); |
| 199 | 247 | void navigate({ to: item.targetUrl }); |
| 200 | 248 | }; |
| 201 | 249 | |
| 202 | 250 | return ( |
| 203 | - <Popover open={open()} onOpenChange={setOpen} placement="bottom-end" gutter={8}> | |
| 251 | + <Popover | |
| 252 | + open={open()} | |
| 253 | + onOpenChange={(nextOpen) => { | |
| 254 | + setOpen(nextOpen); | |
| 255 | + if (!nextOpen) setPreviewNotification(null); | |
| 256 | + }} | |
| 257 | + placement="bottom-end" | |
| 258 | + gutter={8} | |
| 259 | + > | |
| 204 | 260 | <PopoverTrigger |
| 205 | 261 | class={cn( |
| 206 | 262 | "topbar-control relative flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-xl outline-hidden focus-visible:ring-2 focus-visible:ring-ring", |
| @@ -243,10 +299,13 @@ export function NotificationCenter() { | ||
| 243 | 299 | </Show> |
| 244 | 300 | </div> |
| 245 | 301 | |
| 246 | - <Tabs defaultValue="all" class="p-2"> | |
| 247 | - <TabsList class="mb-1 w-full"> | |
| 248 | - <TabsTrigger value="all" class="flex-1">{t("notifications.tabAll")}</TabsTrigger> | |
| 249 | - <TabsTrigger value="system" class="flex-1">{t("notifications.tabSystem")}</TabsTrigger> | |
| 302 | + <Show | |
| 303 | + when={previewNotification()} | |
| 304 | + fallback={ | |
| 305 | + <Tabs defaultValue="all" class="p-2"> | |
| 306 | + <TabsList class="mx-auto mb-2 h-8 w-fit min-w-[180px] p-0.5"> | |
| 307 | + <TabsTrigger value="all" class="h-7 flex-1 px-3 text-[11px]">{t("notifications.tabAll")}</TabsTrigger> | |
| 308 | + <TabsTrigger value="system" class="h-7 flex-1 px-3 text-[11px]">{t("notifications.tabSystem")}</TabsTrigger> | |
| 250 | 309 | </TabsList> |
| 251 | 310 | |
| 252 | 311 | <TabsContent value="all" class="mt-0 max-h-80 space-y-1 overflow-y-auto"> |
| @@ -258,7 +317,7 @@ export function NotificationCenter() { | ||
| 258 | 317 | } |
| 259 | 318 | > |
| 260 | 319 | <Show |
| 261 | - when={activeNotifications().length > 0} | |
| 320 | + when={notificationGroups().length > 0} | |
| 262 | 321 | fallback={ |
| 263 | 322 | <div class="space-y-2 p-8 text-center"> |
| 264 | 323 | <div class="mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-surface-tint text-text-subtle"> |
| @@ -270,55 +329,139 @@ export function NotificationCenter() { | ||
| 270 | 329 | </div> |
| 271 | 330 | } |
| 272 | 331 | > |
| 273 | - <For each={activeNotifications()}> | |
| 274 | - {(item) => ( | |
| 275 | - <div | |
| 276 | - onClick={() => handleSelectNotification(item)} | |
| 277 | - class="group relative flex cursor-pointer select-none items-start gap-3 rounded-xl p-2.5 text-xs transition-colors hover:bg-surface-tint" | |
| 278 | - > | |
| 279 | - <div class="mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-tint text-text-subtle transition-colors group-hover:bg-primary group-hover:text-primary-foreground"> | |
| 280 | - <Show when={item.type === "message"}> | |
| 281 | - <IconMessage class="h-4 w-4" /> | |
| 282 | - </Show> | |
| 283 | - <Show when={item.type === "event"}> | |
| 284 | - <IconCalendar class="h-4 w-4" /> | |
| 285 | - </Show> | |
| 286 | - <Show when={item.type === "exam"}> | |
| 287 | - <IconExam class="h-4 w-4" /> | |
| 288 | - </Show> | |
| 289 | - <Show when={item.type === "homework"}> | |
| 290 | - <IconHomework class="h-4 w-4" /> | |
| 291 | - </Show> | |
| 292 | - </div> | |
| 332 | + <div class="space-y-2"> | |
| 333 | + <For each={notificationGroups()}> | |
| 334 | + {(group) => ( | |
| 335 | + <section class={cn("overflow-hidden rounded-xl border", notificationGroupTone(group.type))}> | |
| 336 | + <div class="flex items-center justify-between gap-2 px-2.5 py-2"> | |
| 337 | + <div class="flex min-w-0 items-center gap-2"> | |
| 338 | + <div class={cn("flex h-6 w-6 shrink-0 items-center justify-center rounded-md", notificationGroupIconTone(group.type))}> | |
| 339 | + <Show when={group.type === "message"}> | |
| 340 | + <IconMessage class="h-3.5 w-3.5" /> | |
| 341 | + </Show> | |
| 342 | + <Show when={group.type === "event"}> | |
| 343 | + <IconCalendar class="h-3.5 w-3.5" /> | |
| 344 | + </Show> | |
| 345 | + <Show when={group.type === "exam"}> | |
| 346 | + <IconExam class="h-3.5 w-3.5" /> | |
| 347 | + </Show> | |
| 348 | + <Show when={group.type === "homework"}> | |
| 349 | + <IconHomework class="h-3.5 w-3.5" /> | |
| 350 | + </Show> | |
| 351 | + </div> | |
| 352 | + <span class="truncate text-[11px] font-bold uppercase tracking-[0.08em] text-text-subtle"> | |
| 353 | + {notificationGroupLabel(group.type)} | |
| 354 | + </span> | |
| 355 | + </div> | |
| 356 | + <span class="shrink-0 rounded-full bg-background/70 px-1.5 py-0.5 font-mono text-[10px] font-bold text-text-subtle"> | |
| 357 | + {group.items.length} | |
| 358 | + </span> | |
| 359 | + </div> | |
| 293 | 360 | |
| 294 | - <div class="min-w-0 flex-1 space-y-0.5 pr-6"> | |
| 295 | - <span class="block truncate font-semibold text-text-strong"> | |
| 296 | - {item.title} | |
| 297 | - </span> | |
| 298 | - <p class="line-clamp-2 text-[11px] leading-snug text-text-subtle"> | |
| 299 | - {item.description} | |
| 300 | - </p> | |
| 301 | - </div> | |
| 361 | + <div class="space-y-0.5 px-1 pb-1"> | |
| 362 | + <For each={group.items}> | |
| 363 | + {(item) => ( | |
| 364 | + <div | |
| 365 | + onClick={() => handleSelectNotification(item)} | |
| 366 | + class="group relative flex cursor-pointer select-none items-start gap-3 rounded-lg p-2 text-xs transition-colors hover:bg-background/70" | |
| 367 | + > | |
| 368 | + <div class="mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-background/75 text-text-subtle transition-colors group-hover:bg-primary group-hover:text-primary-foreground"> | |
| 369 | + <Show when={item.type === "message"}> | |
| 370 | + <IconMessage class="h-4 w-4" /> | |
| 371 | + </Show> | |
| 372 | + <Show when={item.type === "event"}> | |
| 373 | + <IconCalendar class="h-4 w-4" /> | |
| 374 | + </Show> | |
| 375 | + <Show when={item.type === "exam"}> | |
| 376 | + <IconExam class="h-4 w-4" /> | |
| 377 | + </Show> | |
| 378 | + <Show when={item.type === "homework"}> | |
| 379 | + <IconHomework class="h-4 w-4" /> | |
| 380 | + </Show> | |
| 381 | + </div> | |
| 302 | 382 | |
| 303 | - <button | |
| 304 | - type="button" | |
| 305 | - class="absolute right-2 top-2.5 flex h-6 w-6 items-center justify-center rounded-md text-text-subtle/70 opacity-80 transition-all hover:bg-destructive/10 hover:text-destructive-text sm:opacity-0 sm:group-hover:opacity-100" | |
| 306 | - title={t("notifications.dismiss")} | |
| 307 | - onClick={(e) => handleDismissSingle(e, item.id)} | |
| 308 | - > | |
| 309 | - <IconX class="h-3.5 w-3.5" /> | |
| 310 | - </button> | |
| 311 | - </div> | |
| 312 | - )} | |
| 313 | - </For> | |
| 383 | + <div class="min-w-0 flex-1 space-y-0.5 pr-6"> | |
| 384 | + <span class="block truncate font-semibold text-text-strong"> | |
| 385 | + {item.title} | |
| 386 | + </span> | |
| 387 | + <p class="line-clamp-2 text-[11px] leading-snug text-text-subtle"> | |
| 388 | + {item.description} | |
| 389 | + </p> | |
| 390 | + </div> | |
| 391 | + | |
| 392 | + <button | |
| 393 | + type="button" | |
| 394 | + class="absolute right-2 top-2 flex h-6 w-6 items-center justify-center rounded-md text-text-subtle/70 opacity-80 transition-all hover:bg-destructive/10 hover:text-destructive-text sm:opacity-0 sm:group-hover:opacity-100" | |
| 395 | + title={t("notifications.dismiss")} | |
| 396 | + onClick={(e) => handleDismissSingle(e, item.id)} | |
| 397 | + > | |
| 398 | + <IconX class="h-3.5 w-3.5" /> | |
| 399 | + </button> | |
| 400 | + </div> | |
| 401 | + )} | |
| 402 | + </For> | |
| 403 | + </div> | |
| 404 | + </section> | |
| 405 | + )} | |
| 406 | + </For> | |
| 407 | + </div> | |
| 314 | 408 | </Show> |
| 315 | 409 | </Suspense> |
| 316 | 410 | </TabsContent> |
| 317 | 411 | |
| 318 | - <TabsContent value="system" class="mt-0"> | |
| 319 | - <ComingSoonPanel title={t("notifications.tabSystem")} class="border-0 p-3" /> | |
| 320 | - </TabsContent> | |
| 321 | - </Tabs> | |
| 412 | + <TabsContent value="system" class="mt-0"> | |
| 413 | + <ComingSoonPanel title={t("notifications.tabSystem")} class="border-0 p-3" /> | |
| 414 | + </TabsContent> | |
| 415 | + </Tabs> | |
| 416 | + } | |
| 417 | + > | |
| 418 | + {(item) => ( | |
| 419 | + <div class="space-y-4 p-4"> | |
| 420 | + <div class="flex items-center gap-2"> | |
| 421 | + <Button | |
| 422 | + type="button" | |
| 423 | + variant="ghost" | |
| 424 | + size="sm" | |
| 425 | + class="h-7 rounded-lg px-2 text-[11px] text-text-subtle" | |
| 426 | + onClick={() => setPreviewNotification(null)} | |
| 427 | + > | |
| 428 | + <IconChevronLeft class="mr-1 h-3.5 w-3.5" /> | |
| 429 | + {t("common.back")} | |
| 430 | + </Button> | |
| 431 | + </div> | |
| 432 | + | |
| 433 | + <div class="space-y-2"> | |
| 434 | + <div class="flex items-start gap-3"> | |
| 435 | + <div class={cn("flex h-10 w-10 shrink-0 items-center justify-center rounded-xl", notificationGroupIconTone(item().type))}> | |
| 436 | + <Show when={item().type === "message"}> | |
| 437 | + <IconMessage class="h-5 w-5" /> | |
| 438 | + </Show> | |
| 439 | + <Show when={item().type === "event"}> | |
| 440 | + <IconCalendar class="h-5 w-5" /> | |
| 441 | + </Show> | |
| 442 | + <Show when={item().type === "exam"}> | |
| 443 | + <IconExam class="h-5 w-5" /> | |
| 444 | + </Show> | |
| 445 | + <Show when={item().type === "homework"}> | |
| 446 | + <IconHomework class="h-5 w-5" /> | |
| 447 | + </Show> | |
| 448 | + </div> | |
| 449 | + <div class="min-w-0 space-y-1"> | |
| 450 | + <h4 class="text-sm font-semibold leading-snug text-text-strong">{item().title}</h4> | |
| 451 | + <p class="whitespace-pre-line text-xs leading-relaxed text-text-subtle"> | |
| 452 | + {item().preview ?? item().description} | |
| 453 | + </p> | |
| 454 | + </div> | |
| 455 | + </div> | |
| 456 | + </div> | |
| 457 | + | |
| 458 | + <Button type="button" size="sm" class="w-full rounded-lg" onClick={handleNavigateToNotification}> | |
| 459 | + <IconExternalLink class="mr-1.5 h-3.5 w-3.5" /> | |
| 460 | + {t("notifications.goToPage")} | |
| 461 | + </Button> | |
| 462 | + </div> | |
| 463 | + )} | |
| 464 | + </Show> | |
| 322 | 465 | </PopoverContent> |
| 323 | 466 | </Popover> |
| 324 | 467 | ); |
src/i18n/messages.tsmodified+3 -0
| @@ -545,6 +545,7 @@ export type MessageKey = | ||
| 545 | 545 | | "notifications.empty" |
| 546 | 546 | | "notifications.tabAll" |
| 547 | 547 | | "notifications.tabSystem" |
| 548 | + | "notifications.goToPage" | |
| 548 | 549 | | "errors.notFoundDescription" |
| 549 | 550 | | "errors.accessDeniedDescription" |
| 550 | 551 | | "network.offlineTitle" |
| @@ -2543,6 +2544,7 @@ const en: Dict = { | ||
| 2543 | 2544 | "notifications.empty": "No new notifications yet.", |
| 2544 | 2545 | "notifications.tabAll": "All", |
| 2545 | 2546 | "notifications.tabSystem": "System", |
| 2547 | + "notifications.goToPage": "Go to page", | |
| 2546 | 2548 | "errors.notFoundDescription": "The page you're looking for may have moved or been deleted.", |
| 2547 | 2549 | "errors.accessDeniedDescription": "Your role can't view this section. Ask an administrator if you need access.", |
| 2548 | 2550 | "network.offlineTitle": "You're offline", |
| @@ -4730,6 +4732,7 @@ const tr: Dict = { | ||
| 4730 | 4732 | "notifications.empty": "Henüz yeni bir bildiriminiz yok.", |
| 4731 | 4733 | "notifications.tabAll": "Tümü", |
| 4732 | 4734 | "notifications.tabSystem": "Sistem", |
| 4735 | + "notifications.goToPage": "Sayfaya git", | |
| 4733 | 4736 | "errors.notFoundDescription": "Aradığın sayfa taşınmış ya da silinmiş olabilir.", |
| 4734 | 4737 | "errors.accessDeniedDescription": "Rolün bu bölümü görüntülemeye yetkili değil. Gerekliyse kurum yöneticinden yetki iste.", |
| 4735 | 4738 | "network.offlineTitle": "Bağlantın koptu", |
src/lib/notifications.tsmodified+27 -0
| @@ -5,11 +5,13 @@ export interface NotificationItem { | ||
| 5 | 5 | type: NotificationType; |
| 6 | 6 | title: string; |
| 7 | 7 | description: string; |
| 8 | + preview?: string; | |
| 8 | 9 | targetUrl: string; |
| 9 | 10 | timestamp: number; |
| 10 | 11 | } |
| 11 | 12 | |
| 12 | 13 | const STORAGE_KEY = "hezarfen.dismissedNotifications"; |
| 14 | +const READ_STORAGE_KEY = "hezarfen.readNotifications"; | |
| 13 | 15 | |
| 14 | 16 | function canUseStorage(): boolean { |
| 15 | 17 | return typeof window !== "undefined" && typeof localStorage !== "undefined"; |
| @@ -52,3 +54,28 @@ export function dismissAllNotificationIds(ids: string[]): Set<string> { | ||
| 52 | 54 | } |
| 53 | 55 | return current; |
| 54 | 56 | } |
| 57 | + | |
| 58 | +export function getReadNotificationIds(): Set<string> { | |
| 59 | + if (!canUseStorage()) return new Set(); | |
| 60 | + try { | |
| 61 | + const raw = localStorage.getItem(READ_STORAGE_KEY); | |
| 62 | + if (!raw) return new Set(); | |
| 63 | + const arr = JSON.parse(raw); | |
| 64 | + return Array.isArray(arr) ? new Set(arr) : new Set(); | |
| 65 | + } catch { | |
| 66 | + return new Set(); | |
| 67 | + } | |
| 68 | +} | |
| 69 | + | |
| 70 | +export function markNotificationRead(id: string): Set<string> { | |
| 71 | + const current = getReadNotificationIds(); | |
| 72 | + current.add(id); | |
| 73 | + if (canUseStorage()) { | |
| 74 | + try { | |
| 75 | + localStorage.setItem(READ_STORAGE_KEY, JSON.stringify(Array.from(current))); | |
| 76 | + } catch { | |
| 77 | + // ignore | |
| 78 | + } | |
| 79 | + } | |
| 80 | + return current; | |
| 81 | +} |
src/pages/messages-page.tsxmodified+13 -19
| @@ -185,23 +185,6 @@ export default function MessagesPage() { | ||
| 185 | 185 | return ( |
| 186 | 186 | <RouteGuard> |
| 187 | 187 | <div class="space-y-4"> |
| 188 | - <div class="flex flex-wrap items-start justify-between gap-3"> | |
| 189 | - <div class="min-w-0"> | |
| 190 | - <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{t("nav.messages")}</h1> | |
| 191 | - </div> | |
| 192 | - <Button | |
| 193 | - size="sm" | |
| 194 | - class="shrink-0 rounded-lg" | |
| 195 | - onClick={() => { | |
| 196 | - setReplyData(null); | |
| 197 | - setComposeOpen(true); | |
| 198 | - }} | |
| 199 | - > | |
| 200 | - <IconPlus class="h-4 w-4" /> | |
| 201 | - <span>{t("messages.newMessage")}</span> | |
| 202 | - </Button> | |
| 203 | - </div> | |
| 204 | - | |
| 205 | 188 | <div class="min-h-[50vh] sm:min-h-[calc(100vh-11rem)]"> |
| 206 | 189 | <section class="data-shell overflow-hidden p-0"> |
| 207 | 190 | <div class="flex min-h-[50vh] flex-col sm:min-h-[calc(100vh-11rem)]"> |
| @@ -215,9 +198,9 @@ export default function MessagesPage() { | ||
| 215 | 198 | </Show> |
| 216 | 199 | </div> |
| 217 | 200 | {/* Folder toolbar — the app shell already owns the global sidebar. */} |
| 218 | - <aside class="flex flex-wrap items-center gap-2 border-b border-border-hairline bg-surface-overlay px-3 py-2.5"> | |
| 201 | + <aside class="flex flex-wrap items-center justify-between gap-2 border-b border-border-hairline bg-surface-overlay px-3 py-2.5"> | |
| 219 | 202 | {/* Folder navigation stays compact, leaving the only sidebar to the app shell. */} |
| 220 | - <nav class="flex min-w-0 max-w-full flex-1 items-center gap-1 overflow-x-auto"> | |
| 203 | + <nav class="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto"> | |
| 221 | 204 | <button |
| 222 | 205 | type="button" |
| 223 | 206 | class={cn( |
| @@ -311,6 +294,17 @@ export default function MessagesPage() { | ||
| 311 | 294 | </div> |
| 312 | 295 | </button> |
| 313 | 296 | </nav> |
| 297 | + <Button | |
| 298 | + size="sm" | |
| 299 | + class="shrink-0 rounded-lg" | |
| 300 | + onClick={() => { | |
| 301 | + setReplyData(null); | |
| 302 | + setComposeOpen(true); | |
| 303 | + }} | |
| 304 | + > | |
| 305 | + <IconPlus class="h-4 w-4" /> | |
| 306 | + <span>{t("messages.newMessage")}</span> | |
| 307 | + </Button> | |
| 314 | 308 | </aside> |
| 315 | 309 | |
| 316 | 310 | {/* Gmail Main Content Area */} |