diff --git a/apps/web/src/app.css b/apps/web/src/app.css index 5370a720e..426280bf2 100644 --- a/apps/web/src/app.css +++ b/apps/web/src/app.css @@ -235,3 +235,7 @@ textarea, margin-inline-start: 0px !important; padding: 0px !important; } + +#app.app-focus-mode .toasts-container { + display: none; +} diff --git a/apps/web/src/app.tsx b/apps/web/src/app.tsx index f4a1fc8cd..3ea3a6c05 100644 --- a/apps/web/src/app.tsx +++ b/apps/web/src/app.tsx @@ -48,6 +48,7 @@ function App() { const isMobile = useMobile(); const [show, setShow] = useState(true); const [isAppLoaded] = useDatabase(); + const isFocusMode = useStore((store) => store.isFocusMode); return ( <> @@ -69,6 +70,7 @@ function App() { {isMobile ? ( diff --git a/apps/web/src/utils/task-scheduler.ts b/apps/web/src/utils/task-scheduler.ts index 256f33e88..14cf37cc2 100644 --- a/apps/web/src/utils/task-scheduler.ts +++ b/apps/web/src/utils/task-scheduler.ts @@ -23,6 +23,7 @@ import type { TaskSchedulerEvent } from "./task-scheduler.worker"; import { wrap, Remote } from "comlink"; +import { showToast } from "./toast"; let worker: globalThis.Worker | undefined; let scheduler: Remote | undefined; @@ -45,7 +46,14 @@ export class TaskScheduler { break; } }); - await scheduler?.registerTask(id, time); + try { + await scheduler?.registerTask(id, time); + } catch (e) { + showToast( + "error", + `Failed to register task: ${(e as Error).message} (cron: ${time})` + ); + } } static async stop(id: string) { diff --git a/apps/web/src/utils/toast.tsx b/apps/web/src/utils/toast.tsx index 752613da9..9c31f29e5 100644 --- a/apps/web/src/utils/toast.tsx +++ b/apps/web/src/utils/toast.tsx @@ -20,7 +20,6 @@ along with this program. If not, see . import { Button, Flex, Text } from "@theme-ui/components"; import { ScopedThemeProvider } from "../components/theme-provider"; import { Error, Warn, Success, Info } from "../components/icons"; -import { store as appstore } from "../stores/app-store"; import toast from "react-hot-toast"; type ToastType = "success" | "error" | "warn" | "info"; @@ -43,8 +42,6 @@ function showToast( actions?: ToastAction[], hideAfter = 5000 ): { hide: () => void } { - if (appstore.get().isFocusMode) return { hide: () => {} }; // TODO - const id = toast(, { duration: hideAfter || Infinity, icon: ,