From 4da231aeb5bf3ee0296fb8626dae3ac99893a158 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 3 Oct 2025 13:18:47 -0700 Subject: implement api call to save topic for given fcm token --- site/src/components/NotificationButton.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'site/src/components') diff --git a/site/src/components/NotificationButton.tsx b/site/src/components/NotificationButton.tsx index 3e0342b..1e9bc5e 100644 --- a/site/src/components/NotificationButton.tsx +++ b/site/src/components/NotificationButton.tsx @@ -75,7 +75,10 @@ export default function NotificationButton({ className = "", isMoe = false, game // TODO: Subscribe to topic via backend API console.log(`Subscribing to topic: ${gameId} with token: ${token}`); - // Stub for now - will make actual API call to backend to subscribe to topic + await fetch(import.meta.env.VITE_MIDDLEWARE_BASE_URL+`/api/notifications/set?topic=${gameId}&token=${token}&action=subscribe`, { + method: "GET", + headers: { "Content-Type": "application/json" }, + }); // Update local storage to track subscribed topics const subscribedTopics = JSON.parse(localStorage.getItem('subscribed_topics') || '[]'); @@ -106,7 +109,11 @@ export default function NotificationButton({ className = "", isMoe = false, game // TODO: Unsubscribe from topic via backend API console.log(`Unsubscribing from topic: ${gameId} with token: ${token}`); - // Stub for now - will make actual API call to backend to unsubscribe from topic + await fetch(import.meta.env.VITE_MIDDLEWARE_BASE_URL+`/api/notifications/set?topic=${gameId}&token=${token}&action=unsubscribe`, { + method: "GET", + headers: { "Content-Type": "application/json" }, + }); + // Update local storage to remove topic const subscribedTopics = JSON.parse(localStorage.getItem('subscribed_topics') || '[]'); -- cgit v1.2.3