Skip to content

Commit c77b649

Browse files
authored
fix: reset current path if deleted (#1765)
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
1 parent 81b9ff4 commit c77b649

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/store/files/actions.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,22 @@ export const actions = {
150150
}
151151
},
152152

153-
async notifyDeleteDir ({ commit }, payload: Moonraker.Files.ChangeResponse) {
153+
async notifyDeleteDir ({ commit, getters }, payload: Moonraker.Files.ChangeResponse) {
154154
const paths = getFilePaths(payload.item.path, payload.item.root)
155155

156156
if (!paths.filtered) {
157157
commit('setDirDelete', paths)
158158

159159
commit('setPathDelete', paths.rootPathFilename)
160+
161+
const currentPath: string = getters.getCurrentPathByRoot(paths.root)
162+
163+
if (
164+
currentPath === paths.rootPathFilename ||
165+
currentPath.startsWith(`${paths.rootPathFilename}/`)
166+
) {
167+
commit('setCurrentPath', { root: paths.root, path: paths.rootPath })
168+
}
160169
}
161170
},
162171

@@ -179,7 +188,7 @@ export const actions = {
179188
commit('setRemoveFileDownload', payload)
180189
},
181190

182-
async updateCurrentPathByRoot ({ commit }, payload) {
191+
async updateCurrentPathByRoot ({ commit }, payload: { root: string, path: string }) {
183192
commit('setCurrentPath', payload)
184193
}
185194
} satisfies ActionTree<FilesState, RootState>

src/store/files/mutations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const mutations = {
167167
}
168168
},
169169

170-
setCurrentPath (state, payload) {
170+
setCurrentPath (state, payload: { root: string, path: string }) {
171171
Vue.set(state.currentPaths, payload.root, payload.path)
172172
},
173173

0 commit comments

Comments
 (0)