Skip to content
TypeScript

perf(web): notification settings compile with the React Compiler (#20504)

Julius Marminge0a453f00d594
diff --git a/apps/web/reactCompiledFiles.ts b/apps/web/reactCompiledFiles.ts
index b58f199c279..8c2a795bba2 100644
--- a/apps/web/reactCompiledFiles.ts
+++ b/apps/web/reactCompiledFiles.ts
@@ -79,4 +79,5 @@ export const REACT_COMPILED_FILES = [
"apps/web/src/components/settings/useHostConnectionChecks.ts",
"apps/web/src/components/settings/useProjectScriptSettings.ts",
"apps/web/src/components/settings/SnapShotSetupDialog.tsx",
+ "apps/web/src/components/settings/NotificationSettings.tsx",
] as const;
diff --git a/apps/web/src/components/settings/NotificationSettings.tsx b/apps/web/src/components/settings/NotificationSettings.tsx
index 5af5f0a8523..5724a4de961 100644
--- a/apps/web/src/components/settings/NotificationSettings.tsx
+++ b/apps/web/src/components/settings/NotificationSettings.tsx
@@ -1,3 +1,4 @@
+import { settlePromise } from "@t3tools/client-runtime/state/runtime";
import { useState } from "react";
import {
@@ -46,21 +47,19 @@ export function NotificationSettings() {
return;
}
setRequesting(true);
- try {
- const permission = await Notification.requestPermission();
- if (permission !== "granted") {
- setPermissionMessage(
- "Allow notifications in your browser or system settings, then choose this option again. Sound only is still available.",
- );
- return;
- }
- } catch {
+ const permission = await settlePromise(() => Notification.requestPermission());
+ setRequesting(false);
+ if (permission._tag === "Failure") {
setPermissionMessage(
"Notifications are unavailable in this browser. Sound only is still available.",
);
return;
- } finally {
- setRequesting(false);
+ }
+ if (permission.value !== "granted") {
+ setPermissionMessage(
+ "Allow notifications in your browser or system settings, then choose this option again. Sound only is still available.",
+ );
+ return;
}
}
updateSettings({ notificationMode: value });