fix(desktop): surface notification test errors in UI
Show inline error text when the test notification fails or isn't delivered instead of silently logging to console.
This commit is contained in:
@@ -14,6 +14,7 @@ export function DesktopPermissionsSection() {
|
|||||||
isRefreshing,
|
isRefreshing,
|
||||||
requestingPermission,
|
requestingPermission,
|
||||||
isSendingTestNotification,
|
isSendingTestNotification,
|
||||||
|
testNotificationError,
|
||||||
refreshPermissions,
|
refreshPermissions,
|
||||||
requestPermission,
|
requestPermission,
|
||||||
sendTestNotification,
|
sendTestNotification,
|
||||||
@@ -58,6 +59,11 @@ export function DesktopPermissionsSection() {
|
|||||||
void sendTestNotification();
|
void sendTestNotification();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{testNotificationError ? (
|
||||||
|
<Text style={[styles.errorText, { color: theme.colors.danger }]}>
|
||||||
|
{testNotificationError}
|
||||||
|
</Text>
|
||||||
|
) : null}
|
||||||
<DesktopPermissionRow
|
<DesktopPermissionRow
|
||||||
title="Microphone"
|
title="Microphone"
|
||||||
showBorder
|
showBorder
|
||||||
@@ -80,4 +86,9 @@ const styles = StyleSheet.create((theme) => ({
|
|||||||
gap: theme.spacing[2],
|
gap: theme.spacing[2],
|
||||||
marginBottom: theme.spacing[3],
|
marginBottom: theme.spacing[3],
|
||||||
},
|
},
|
||||||
|
errorText: {
|
||||||
|
fontSize: theme.fontSize.xs,
|
||||||
|
paddingHorizontal: theme.spacing[4],
|
||||||
|
paddingBottom: theme.spacing[2],
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export interface UseDesktopPermissionsReturn {
|
|||||||
isRefreshing: boolean;
|
isRefreshing: boolean;
|
||||||
requestingPermission: DesktopPermissionKind | null;
|
requestingPermission: DesktopPermissionKind | null;
|
||||||
isSendingTestNotification: boolean;
|
isSendingTestNotification: boolean;
|
||||||
|
testNotificationError: string | null;
|
||||||
refreshPermissions: () => Promise<void>;
|
refreshPermissions: () => Promise<void>;
|
||||||
requestPermission: (kind: DesktopPermissionKind) => Promise<void>;
|
requestPermission: (kind: DesktopPermissionKind) => Promise<void>;
|
||||||
sendTestNotification: () => Promise<void>;
|
sendTestNotification: () => Promise<void>;
|
||||||
@@ -112,22 +113,25 @@ export function useDesktopPermissions(): UseDesktopPermissionsReturn {
|
|||||||
[isDesktop, refreshPermissions],
|
[isDesktop, refreshPermissions],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [testNotificationError, setTestNotificationError] = useState<string | null>(null);
|
||||||
|
|
||||||
const sendTestNotification = useCallback(async () => {
|
const sendTestNotification = useCallback(async () => {
|
||||||
if (!isDesktop) {
|
if (!isDesktop) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsSendingTestNotification(true);
|
setIsSendingTestNotification(true);
|
||||||
|
setTestNotificationError(null);
|
||||||
try {
|
try {
|
||||||
const sent = await sendOsNotification({
|
const sent = await sendOsNotification({
|
||||||
title: "Paseo notification test",
|
title: "Paseo notification test",
|
||||||
body: "If you can see this, desktop notifications work.",
|
body: "If you can see this, desktop notifications work.",
|
||||||
});
|
});
|
||||||
if (!sent) {
|
if (!sent) {
|
||||||
console.warn("[Settings] Desktop test notification was not delivered");
|
setTestNotificationError("Notification was not delivered. Check System Settings > Notifications.");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[Settings] Failed to send desktop test notification", error);
|
setTestNotificationError("Failed to send notification.");
|
||||||
} finally {
|
} finally {
|
||||||
if (isMountedRef.current) {
|
if (isMountedRef.current) {
|
||||||
setIsSendingTestNotification(false);
|
setIsSendingTestNotification(false);
|
||||||
@@ -149,6 +153,7 @@ export function useDesktopPermissions(): UseDesktopPermissionsReturn {
|
|||||||
isRefreshing,
|
isRefreshing,
|
||||||
requestingPermission,
|
requestingPermission,
|
||||||
isSendingTestNotification,
|
isSendingTestNotification,
|
||||||
|
testNotificationError,
|
||||||
refreshPermissions,
|
refreshPermissions,
|
||||||
requestPermission,
|
requestPermission,
|
||||||
sendTestNotification,
|
sendTestNotification,
|
||||||
|
|||||||
Reference in New Issue
Block a user