From de7e4e9c69df494c28d93ba1da0d294b609be4a0 Mon Sep 17 00:00:00 2001 From: Athou Date: Thu, 19 Feb 2026 22:13:11 +0100 Subject: [PATCH] add a button for testing push notification settings --- commafeed-client/src/app/client.ts | 3 + .../settings/PushNotificationSettings.tsx | 29 ++++++++- commafeed-client/src/locales/ar/messages.po | 8 +++ commafeed-client/src/locales/ca/messages.po | 8 +++ commafeed-client/src/locales/cs/messages.po | 8 +++ commafeed-client/src/locales/cy/messages.po | 8 +++ commafeed-client/src/locales/da/messages.po | 8 +++ commafeed-client/src/locales/de/messages.po | 8 +++ commafeed-client/src/locales/en/messages.po | 8 +++ commafeed-client/src/locales/es/messages.po | 8 +++ commafeed-client/src/locales/fa/messages.po | 8 +++ commafeed-client/src/locales/fi/messages.po | 8 +++ commafeed-client/src/locales/fr/messages.po | 8 +++ commafeed-client/src/locales/gl/messages.po | 8 +++ commafeed-client/src/locales/hu/messages.po | 8 +++ commafeed-client/src/locales/id/messages.po | 8 +++ commafeed-client/src/locales/it/messages.po | 8 +++ commafeed-client/src/locales/ja/messages.po | 8 +++ commafeed-client/src/locales/ko/messages.po | 8 +++ commafeed-client/src/locales/ms/messages.po | 8 +++ commafeed-client/src/locales/nb/messages.po | 8 +++ commafeed-client/src/locales/nl/messages.po | 8 +++ commafeed-client/src/locales/nn/messages.po | 8 +++ commafeed-client/src/locales/pl/messages.po | 8 +++ commafeed-client/src/locales/pt/messages.po | 8 +++ commafeed-client/src/locales/ru/messages.po | 8 +++ commafeed-client/src/locales/sk/messages.po | 8 +++ commafeed-client/src/locales/sv/messages.po | 8 +++ commafeed-client/src/locales/tr/messages.po | 8 +++ commafeed-client/src/locales/zh/messages.po | 8 +++ .../backend/feed/FeedUpdateNotifier.java | 4 +- .../commafeed/backend/model/UserSettings.java | 42 ++++++++----- .../service/PushNotificationService.java | 36 ++++++----- .../commafeed/frontend/resource/UserREST.java | 63 ++++++++++++++++--- .../service/PushNotificationServiceTest.java | 26 ++++---- 35 files changed, 367 insertions(+), 60 deletions(-) diff --git a/commafeed-client/src/app/client.ts b/commafeed-client/src/app/client.ts index 4ec112a0..25661e34 100644 --- a/commafeed-client/src/app/client.ts +++ b/commafeed-client/src/app/client.ts @@ -20,6 +20,7 @@ import type { PasswordResetConfirmationRequest, PasswordResetRequest, ProfileModificationRequest, + PushNotificationSettings, RegistrationRequest, ServerInfo, Settings, @@ -101,6 +102,8 @@ export const client = { passwordResetCallback: async (req: PasswordResetConfirmationRequest) => await axiosInstance.post("user/passwordResetCallback", req), getSettings: async () => await axiosInstance.get("user/settings"), saveSettings: async (settings: Settings) => await axiosInstance.post("user/settings", settings), + sendTestPushNotification: async (settings: PushNotificationSettings) => + await axiosInstance.post("user/pushNotificationTest", settings), getProfile: async () => await axiosInstance.get("user/profile"), saveProfile: async (req: ProfileModificationRequest) => await axiosInstance.post("user/profile", req), deleteProfile: async () => await axiosInstance.post("user/profile/deleteAccount"), diff --git a/commafeed-client/src/components/settings/PushNotificationSettings.tsx b/commafeed-client/src/components/settings/PushNotificationSettings.tsx index 2354b1b5..ec5aa599 100644 --- a/commafeed-client/src/components/settings/PushNotificationSettings.tsx +++ b/commafeed-client/src/components/settings/PushNotificationSettings.tsx @@ -1,13 +1,17 @@ +import { msg } from "@lingui/core/macro" import { useLingui } from "@lingui/react" import { Trans } from "@lingui/react/macro" -import { Button, Group, Select, Stack, TextInput } from "@mantine/core" +import { Button, Divider, Group, Select, Stack, TextInput } from "@mantine/core" import { useForm } from "@mantine/form" import { useEffect } from "react" -import { TbDeviceFloppy } from "react-icons/tb" +import { useAsyncCallback } from "react-async-hook" +import { TbDeviceFloppy, TbSend } from "react-icons/tb" +import { client, errorToStrings } from "@/app/client" import { redirectToSelectedSource } from "@/app/redirect/thunks" import { useAppDispatch, useAppSelector } from "@/app/store" import type { PushNotificationSettings as PushNotificationSettingsModel } from "@/app/types" import { changeNotificationSettings } from "@/app/user/thunks" +import { Alert } from "@/components/Alert" export function PushNotificationSettings() { const notificationSettings = useAppSelector(state => state.user.settings?.pushNotificationSettings) @@ -24,6 +28,8 @@ export function PushNotificationSettings() { dispatch(changeNotificationSettings(values)) } + const sendTestPushNotification = useAsyncCallback(client.user.sendTestPushNotification) + const typeInputProps = form.getInputProps("type") if (!pushNotificationsEnabled) { @@ -32,6 +38,14 @@ export function PushNotificationSettings() { return (
+ {sendTestPushNotification.status === "success" && ( + + )} + + {sendTestPushNotification.status === "error" && ( + + )} +