From 60390009d198272392a3ea58b1381fdecef61c91 Mon Sep 17 00:00:00 2001
From: TheOnlyMace <0815cracky@gmail.com>
Date: Tue, 21 Jul 2026 22:30:08 +0200
Subject: [PATCH] Refactor dashboard notification handling and improve admin
broadcast functionality. Ensure only admins can access global notifications,
implement draft management for broadcast messages, and add event listeners
for real-time updates across dashboard components.
---
dashboard/app/dashboard/layout.tsx | 31 ++++-
.../components/dashboard/admin-content.tsx | 113 ++++++++++++++----
2 files changed, 114 insertions(+), 30 deletions(-)
diff --git a/dashboard/app/dashboard/layout.tsx b/dashboard/app/dashboard/layout.tsx
index 3b4f83d..f035c5a 100644
--- a/dashboard/app/dashboard/layout.tsx
+++ b/dashboard/app/dashboard/layout.tsx
@@ -69,9 +69,15 @@ export default function DashboardLayout({
if (status === "unauthenticated") {
signIn("discord");
}
-
- // Fetch global notification
+
+ if (status !== "authenticated") return;
+
const fetchNotification = async () => {
+ // Only admins can read admin config — skip for everyone else
+ if (!isAdmin(session?.user?.id)) {
+ setGlobalNotification(null);
+ return;
+ }
try {
const config = await api.getAdminConfig();
setGlobalNotification(config.global_notification);
@@ -79,8 +85,15 @@ export default function DashboardLayout({
console.error("Failed to fetch notifications:", err);
}
};
+
fetchNotification();
- }, [status]);
+
+ const onBroadcastUpdated = () => {
+ fetchNotification();
+ };
+ window.addEventListener("axiom:broadcast-updated", onBroadcastUpdated);
+ return () => window.removeEventListener("axiom:broadcast-updated", onBroadcastUpdated);
+ }, [status, session?.user?.id]);
if (status === "loading" || status === "unauthenticated") {
return (
@@ -367,7 +380,17 @@ export default function DashboardLayout({
Broadcast Metrics