perf(startup): split routes, defer background work and relax dev prebundle
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

Enables TanStack Router automatic route code splitting, preloads routes on intent, skips random search suggestions and update checks during the first paint, registers the search hotkey once, and stops forcing a full Vite dependency re-optimization on every dev launch.
This commit is contained in:
1xDed committed 2026-11-28 17:19:04 +03:00
1 parent 205b655d00
commit 6a1467e864
5 files changed
+34 -15

No files matched your search

+18 -9
View File
@@ -17,6 +17,7 @@ import type { TransitionProps } from "@mui/material/transitions";
import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "@tanstack/react-router";
import { register } from "@tauri-apps/plugin-global-shortcut";
import React, {
type ChangeEvent,
useCallback,
@@ -42,6 +43,10 @@ const Transition = React.forwardRef(function Transition(
return <Grow ref={ref} {...props} />;
});
// Register the global shortcut once. StrictMode mounts this component twice
// in development, and a second register() fails with an unhandled rejection.
let searchShortcutRegistered = false;
const Search = () => {
const theme = useTheme();
const { isOpen, handleClose, toggleSearchDialog } = useSearchStore(
@@ -54,7 +59,7 @@ const Search = () => {
const api = useApiInContext((s) => s.api);
const userId = useCentralStore((s) => s.currentUser?.Id || "");
const suggestions = useQuery({
queryKey: ["search", "suggestions"],
queryKey: ["search", "suggestions", userId],
queryFn: async () =>
api &&
(
@@ -67,6 +72,9 @@ const Search = () => {
recursive: true,
})
).data,
// Do not fetch random suggestions during app startup.
enabled: isOpen && Boolean(api && userId),
staleTime: 5 * 60 * 1000,
});
const [searchTerm, setSearchTerm] = useState("");
@@ -135,14 +143,15 @@ const Search = () => {
}, [navigate, toggleSearchDialog, debouncedSearchTerm]);
useEffect(() => {
async function registerglobalShortcut() {
await register("CommandOrControl+K", (e) => {
if (e.state === "Pressed") {
toggleSearchDialog();
}
});
}
registerglobalShortcut();
if (searchShortcutRegistered) return;
searchShortcutRegistered = true;
register("CommandOrControl+K", (e) => {
if (e.state === "Pressed") {
useSearchStore.getState().toggleSearchDialog();
}
}).catch((error) => {
console.warn("Global search shortcut is unavailable", error);
});
}, []);
return (
+3 -2
View File
@@ -24,7 +24,6 @@ export default function Updater() {
try {
const update = await check();
if (update) {
// console.log(update);
setUpdateInfo(update);
setUpdateDialog(true);
@@ -34,7 +33,9 @@ export default function Updater() {
console.error(error);
}
}
checkForUpdates();
// Let the first page paint and its own requests start first.
const timer = window.setTimeout(checkForUpdates, 5000);
return () => window.clearTimeout(timer);
}, []);
const { enqueueSnackbar } = useSnackbar();
const [downloadProgress, setDownloadProgress] = useState(0);