Files
outline/app/components/DesktopEventHandler.tsx
Tom Moor 2f68f32b40 fix: Polish UI copy, casing, and punctuation (#14144)
* fix: Polish UI copy, casing, and punctuation across the app

* fix: Remove duplicate period in API key scope hint
2026-10-19 09:05:24 -04:00

65 lines
1.8 KiB
TypeScript

import { useRef, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import { toast } from "sonner";
import KeyboardShortcuts from "~/components/KeyboardShortcuts";
import { showDownloadToast } from "~/components/DownloadToast";
import { useDesktopTitlebar } from "~/hooks/useDesktopTitlebar";
import useStores from "~/hooks/useStores";
import Desktop from "~/utils/Desktop";
export default function DesktopEventHandler() {
useDesktopTitlebar();
const { t } = useTranslation();
const history = useHistory();
const { dialogs } = useStores();
const hasDisabledUpdateMessage = useRef(false);
useEffect(() => {
Desktop.bridge?.redirect((path: string, replace: boolean) => {
if (replace) {
history.replace(path);
} else {
history.push(path);
}
});
Desktop.bridge?.updateDownloaded(() => {
if (hasDisabledUpdateMessage.current) {
return;
}
hasDisabledUpdateMessage.current = true;
toast.message(t("An update is ready to install."), {
duration: Infinity,
dismissible: true,
action: {
label: t("Install now"),
onClick: () => {
void Desktop.bridge?.restartAndInstall();
},
},
});
});
Desktop.bridge?.onDownloadComplete?.(showDownloadToast);
Desktop.bridge?.focus(() => {
window.document.body.classList.remove("backgrounded");
});
Desktop.bridge?.blur(() => {
window.document.body.classList.add("backgrounded");
});
Desktop.bridge?.openKeyboardShortcuts(() => {
dialogs.openGuide({
title: t("Keyboard shortcuts"),
content: <KeyboardShortcuts />,
});
});
}, [t, history, dialogs]);
return null;
}