Skip to content

Commit

Permalink
feat: freezing the list in the backgroud while previewing a file (#3004)
Browse files Browse the repository at this point in the history
  • Loading branch information
niubility000 committed Feb 22, 2024
1 parent fe5ca74 commit e167c3e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
2 changes: 1 addition & 1 deletion frontend/src/css/styles.css
Expand Up @@ -152,7 +152,7 @@ main .spinner .bounce2 {
/* PREVIEWER */

#previewer {
background-color: rgba(0, 0, 0, 0.9);
background-color: rgba(0, 0, 0, 0.99);
padding-top: 4em;
position: fixed;
top: 0;
Expand Down
36 changes: 27 additions & 9 deletions frontend/src/views/Files.vue
Expand Up @@ -3,10 +3,10 @@
<header-bar v-if="error || req.type == null" showMenu showLogo />

<breadcrumbs base="/files" />

<listing />
<errors v-if="error" :errorCode="error.status" />
<component v-else-if="currentView" :is="currentView"></component>
<div v-else>
<div v-else-if="currentView !== null">
<h2 class="message delayed">
<div class="spinner">
<div class="bounce1"></div>
Expand Down Expand Up @@ -52,13 +52,10 @@ export default {
computed: {
...mapState(["req", "reload", "loading"]),
currentView() {
if (this.req.type == undefined) {
if (this.req.type == undefined || this.req.isDir) {
return null;
}
if (this.req.isDir) {
return "listing";
} else if (
else if (
this.req.type === "text" ||
this.req.type === "textImmutable"
) {
Expand All @@ -72,7 +69,26 @@ export default {
this.fetchData();
},
watch: {
$route: "fetchData",
$route: function (to, from) {
if (from.path.endsWith("/")) {
if (to.path.endsWith("/")) {
window.sessionStorage.setItem('listFrozen', "false");
this.fetchData();
return;
} else {
window.sessionStorage.setItem('listFrozen', "true");
this.fetchData();
return;
}
} else if (to.path.endsWith("/")) {
this.$store.commit("updateRequest", {});
this.fetchData();
return;
} else {
this.fetchData();
return;
}
},
reload: function (value) {
if (value === true) {
this.fetchData();
Expand Down Expand Up @@ -101,7 +117,9 @@ export default {
this.$store.commit("closeHovers");
// Set loading to true and reset the error.
this.setLoading(true);
if (window.sessionStorage.getItem('listFrozen') !=="true"){
this.setLoading(true);
}
this.error = null;
let url = this.$route.path;
Expand Down
23 changes: 14 additions & 9 deletions frontend/src/views/files/Listing.vue
Expand Up @@ -383,17 +383,22 @@ export default {
},
watch: {
req: function () {
// Reset the show value
this.showLimit = 50;
if (window.sessionStorage.getItem('listFrozen') !=="true"){
// Reset the show value
this.showLimit = 50;
// Ensures that the listing is displayed
Vue.nextTick(() => {
// How much every listing item affects the window height
this.setItemWeight();
// Ensures that the listing is displayed
Vue.nextTick(() => {
// How much every listing item affects the window height
this.setItemWeight();
// Fill and fit the window with listing items
this.fillWindow(true);
});
// Fill and fit the window with listing items
this.fillWindow(true);
});
}
if (this.req.isDir) {
window.sessionStorage.setItem('listFrozen', "false");
}
},
},
mounted: function () {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/views/files/Preview.vue
@@ -1,6 +1,8 @@
<template>
<div
id="previewer"
@touchmove.prevent.stop
@wheel.prevent.stop
@mousemove="toggleNavigation"
@touchstart="toggleNavigation"
>
Expand Down

0 comments on commit e167c3e

Please sign in to comment.