From e73bc8a97130ca9f62c221f97b172294ab862a5d Mon Sep 17 00:00:00 2001 From: Kafigoto Date: Tue, 4 Jul 2023 18:23:40 -0300 Subject: [PATCH 1/2] fixes Unexpected behavior of back arrow #55 --- src/App.tsx | 7 ++++--- src/hooks/useNavigation.ts | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 610f2f3..b6c71ee 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -42,9 +42,9 @@ function App() { } async function onVolumeClick(mountpoint: string) { - if (pathHistory[pathHistory.length - 1] != mountpoint) { - pathHistory.push(mountpoint); - } + pathHistory.splice(1); + pathHistory.push(mountpoint); + setHistoryPlace(pathHistory.length - 1); setCurrentVolume(mountpoint); @@ -56,6 +56,7 @@ function App() { setSearchResults([]); } + pathHistory.splice(historyPlace + 1); pathHistory.push(filePath); setHistoryPlace(pathHistory.length - 1); diff --git a/src/hooks/useNavigation.ts b/src/hooks/useNavigation.ts index dfd7c72..a0385b9 100644 --- a/src/hooks/useNavigation.ts +++ b/src/hooks/useNavigation.ts @@ -17,7 +17,6 @@ export default function useNavigation( return; } - pathHistory.push(pathHistory[historyPlace - 1]); setHistoryPlace((prevPlace) => prevPlace - 1); } From 79cdbd7fc2b2c398b053cd6b2f8131860506a1f8 Mon Sep 17 00:00:00 2001 From: Kafigoto Date: Tue, 4 Jul 2023 23:56:26 -0300 Subject: [PATCH 2/2] length will always be two in this case --- src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index b6c71ee..ec5f206 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -45,7 +45,7 @@ function App() { pathHistory.splice(1); pathHistory.push(mountpoint); - setHistoryPlace(pathHistory.length - 1); + setHistoryPlace(1); setCurrentVolume(mountpoint); await getNewDirectoryContents();