mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: prevent repeated redirect when switching from grid to sidebar view
The default-view redirect in HomePage fired on every mount, not just the initial page load. A module-level flag now gates the redirect so it only applies once per session, allowing users to switch to sidebar view when grid is the default. Closes #128
This commit is contained in:
@@ -13,6 +13,8 @@ import { useSettingsStore } from "@/stores/settings-store";
|
||||
// Tools shown prominently as "quick actions" at the top
|
||||
const QUICK_ACTION_IDS = ["resize", "compress", "convert", "remove-background"];
|
||||
|
||||
let hasAppliedDefaultRedirect = false;
|
||||
|
||||
export function HomePage() {
|
||||
const {
|
||||
setFiles,
|
||||
@@ -37,7 +39,13 @@ export function HomePage() {
|
||||
}, [fetchSettings, fetchFeatures]);
|
||||
|
||||
useEffect(() => {
|
||||
if (settingsLoaded && defaultToolView === "fullscreen" && files.length === 0) {
|
||||
if (
|
||||
!hasAppliedDefaultRedirect &&
|
||||
settingsLoaded &&
|
||||
defaultToolView === "fullscreen" &&
|
||||
files.length === 0
|
||||
) {
|
||||
hasAppliedDefaultRedirect = true;
|
||||
navigate("/fullscreen", { replace: true });
|
||||
}
|
||||
}, [settingsLoaded, defaultToolView, files.length, navigate]);
|
||||
|
||||
Reference in New Issue
Block a user