Skip to content

Commit

Permalink
fix: stay in the same position after renaming or deleting (#3039)
Browse files Browse the repository at this point in the history
  • Loading branch information
niubility000 committed Mar 7, 2024
1 parent e167c3e commit cdf8def
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/prompts/Delete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default {
submit: async function () {
buttons.loading("delete");
window.sessionStorage.setItem("modified", "true");
try {
if (!this.isListing) {
await api.remove(this.$route.path);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/prompts/Rename.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default {
newLink =
url.removeLastDir(oldLink) + "/" + encodeURIComponent(this.name);
window.sessionStorage.setItem("modified", "true");
try {
await api.move([{ from: oldLink, to: newLink }]);
if (!this.isListing) {
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/views/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export default {
currentView() {
if (this.req.type == undefined || this.req.isDir) {
return null;
}
else if (
} else if (
this.req.type === "text" ||
this.req.type === "textImmutable"
) {
Expand All @@ -72,11 +71,11 @@ export default {
$route: function (to, from) {
if (from.path.endsWith("/")) {
if (to.path.endsWith("/")) {
window.sessionStorage.setItem('listFrozen', "false");
window.sessionStorage.setItem("listFrozen", "false");
this.fetchData();
return;
} else {
window.sessionStorage.setItem('listFrozen', "true");
window.sessionStorage.setItem("listFrozen", "true");
this.fetchData();
return;
}
Expand Down Expand Up @@ -117,7 +116,7 @@ export default {
this.$store.commit("closeHovers");
// Set loading to true and reset the error.
if (window.sessionStorage.getItem('listFrozen') !=="true"){
if (window.sessionStorage.getItem("listFrozen") !=="true" && window.sessionStorage.getItem("modified") !=="true"){
this.setLoading(true);
}
this.error = null;
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/views/files/Editor.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<div id="editor-container">
<div
id="editor-container"
@touchmove.prevent.stop
@wheel.prevent.stop
>
<header-bar>
<action icon="close" :label="$t('buttons.close')" @action="close()" />
<title>{{ req.name }}</title>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/views/files/Listing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export default {
},
watch: {
req: function () {
if (window.sessionStorage.getItem('listFrozen') !=="true"){
if (window.sessionStorage.getItem("listFrozen") !=="true" && window.sessionStorage.getItem("modified") !=="true"){
// Reset the show value
this.showLimit = 50;
Expand All @@ -397,7 +397,8 @@ export default {
});
}
if (this.req.isDir) {
window.sessionStorage.setItem('listFrozen', "false");
window.sessionStorage.setItem("listFrozen", "false");
window.sessionStorage.setItem("modified", "false");
}
},
},
Expand Down

0 comments on commit cdf8def

Please sign in to comment.