add a button for testing push notification settings

This commit is contained in:
Athou
2026-02-19 22:13:11 +01:00
parent 6861fe303b
commit de7e4e9c69
35 changed files with 367 additions and 60 deletions

View File

@@ -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<Settings>("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<UserModel>("user/profile"),
saveProfile: async (req: ProfileModificationRequest) => await axiosInstance.post("user/profile", req),
deleteProfile: async () => await axiosInstance.post("user/profile/deleteAccount"),

View File

@@ -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 (
<form onSubmit={form.onSubmit(handleSubmit)}>
<Stack>
{sendTestPushNotification.status === "success" && (
<Alert level="success" messages={[_(msg`Test notification sent successfully.`)]} />
)}
{sendTestPushNotification.status === "error" && (
<Alert level="error" messages={errorToStrings(sendTestPushNotification.error)} />
)}
<Select
label={<Trans>Push notification service</Trans>}
description={
@@ -92,6 +106,17 @@ export function PushNotificationSettings() {
<Button type="submit" leftSection={<TbDeviceFloppy size={16} />}>
<Trans>Save</Trans>
</Button>
<Divider orientation="vertical" />
<Button
variant="outline"
leftSection={<TbSend size={16} />}
onClick={() => sendTestPushNotification.execute(form.values)}
loading={sendTestPushNotification.loading}
>
<Trans>Test</Trans>
</Button>
</Group>
</Stack>
</form>

View File

@@ -1061,6 +1061,14 @@ msgstr "الكلمات"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "عنوان URL للتغذية التي تريد الاشتراك فيها. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Etiquetes"
msgid "Teal"
msgstr "Blau verdós"
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "l'URL del canal al qual us voleu subscriure. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Značky"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "Adresa URL kanálu, k jehož odběru se chcete přihlásit. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Tagiau"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "Y URL ar gyfer y porthwr rydych chi am danysgrifio iddo. "

View File

@@ -1061,6 +1061,14 @@ msgstr ""
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL'en til det feed, du vil abonnere på. "

View File

@@ -1061,6 +1061,14 @@ msgstr ""
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "Die URL für den Feed, den Sie abonnieren möchten. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Tags"
msgid "Teal"
msgstr "Teal"
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr "Test"
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr "Test notification sent successfully."
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."

View File

@@ -1062,6 +1062,14 @@ msgstr "Etiquetas"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "La URL del feed al que desea suscribirse. También puede utilizar la URL del sitio web directamente y CommaFeed intentará encontrar el feed en la página."

View File

@@ -1061,6 +1061,14 @@ msgstr "برچسب ها"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL فیدی که می خواهید در آن مشترک شوید. "

View File

@@ -1061,6 +1061,14 @@ msgstr ""
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "Sen syötteen URL-osoite, jonka haluat tilata. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Marqueurs"
msgid "Teal"
msgstr "Bleu-vert"
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "L'URL du flux auquel vous souhaitez vous abonner. Vous pouvez aussi utiliser l'URL du site directement et CommaFeed va essayer de trouver le flux dans la page."

View File

@@ -1062,6 +1062,14 @@ msgstr "Etiquetas"
msgid "Teal"
msgstr "Verdoso"
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL da canle á que queres subscribirte. Podes usar a url do sitio web directamente e CommaFeed intentará atopar a canle na páxina."

View File

@@ -1061,6 +1061,14 @@ msgstr "Címkék"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "Az előfizetni kívánt hírcsatorna URL-je. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Tag"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL untuk umpan yang ingin Anda langgani. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Tag"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "L'URL del feed a cui vuoi iscriverti. "

View File

@@ -1061,6 +1061,14 @@ msgstr "タグ"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "購読したいフィードのURL。ウェブサイトのURLを直接使用して、CommaFeedはページ内のフィードを検索します。"

View File

@@ -1061,6 +1061,14 @@ msgstr "태그"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "구독하려는 피드의 URL입니다. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Tag"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL untuk suapan yang anda ingin langgan. "

View File

@@ -1061,6 +1061,14 @@ msgstr ""
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL-en til feeden du vil abonnere på. "

View File

@@ -1061,6 +1061,14 @@ msgstr ""
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "De URL voor de feed waarop u zich wilt abonneren. "

View File

@@ -1061,6 +1061,14 @@ msgstr ""
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL-en til feeden du vil abonnere på. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Tagi"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL kanału, który chcesz subskrybować. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Etiquetas"
msgid "Teal"
msgstr "Azul petróleo"
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "A URL do feed que você deseja assinar. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Теги"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL канала, на который вы хотите подписаться. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Značky"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL zdroja, na odber ktorého sa chcete prihlásiť. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Taggar"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "URL:en för flödet du vill prenumerera på. "

View File

@@ -1061,6 +1061,14 @@ msgstr "Etiketler"
msgid "Teal"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "Abone olmak istediğiniz beslemenin URL'si. "

View File

@@ -1061,6 +1061,14 @@ msgstr "标签"
msgid "Teal"
msgstr "青绿"
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test"
msgstr ""
#: src/components/settings/PushNotificationSettings.tsx
msgid "Test notification sent successfully."
msgstr ""
#: src/components/content/add/Subscribe.tsx
msgid "The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed will try to find the feed in the page."
msgstr "您要订阅的信息流的网址。您也可以直接使用网站的网址CommaFeed 会尝试在页面中找到信息流。"