Skip to content

Commit

Permalink
fix: correctly show the active root (#1307)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
  • Loading branch information
pedrolamas committed Jan 12, 2024
1 parent 3843701 commit ff0b120
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 31 deletions.
37 changes: 12 additions & 25 deletions src/components/widgets/filesystem/FileSystem.vue
Expand Up @@ -201,9 +201,6 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
@Prop({ type: Boolean })
readonly bulkActions?: boolean
// Ready. True once the available roots have loaded from moonraker.
ready = false
// Maintains the path and root.
currentRoot = ''
Expand Down Expand Up @@ -271,11 +268,19 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
}
// Gets available roots.
get availableRoots () {
if (!Array.isArray(this.roots)) {
return [this.roots]
get availableRoots (): string[] {
const roots = !Array.isArray(this.roots)
? [this.roots]
: this.roots
if (
roots.length > 0 &&
!roots.includes(this.currentRoot)
) {
this.currentRoot = roots[0]
}
return this.roots
return roots
}
// Properties of the current root.
Expand Down Expand Up @@ -448,10 +453,6 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
return this.$store.state.files.uploads
}
get registeredRoots () {
return this.$store.state.server.info.registered_directories || []
}
get fileDropRoot () {
return this.$route.meta?.fileDropRoot
}
Expand All @@ -470,20 +471,6 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
items.push(...thumbnails)
}
// Set the initial root, and load the dir.
@Watch('registeredRoots', { immediate: true })
onRegisteredRoots (roots: string[]) {
if (roots.length > 0 && !this.ready) {
for (const root of this.availableRoots) {
if (roots.includes(root)) {
this.currentRoot = root
this.ready = true
break
}
}
}
}
// If the root changes, reset the path and load the root path files.
handleRootChange (root: string) {
if (root.length) {
Expand Down
7 changes: 1 addition & 6 deletions src/components/widgets/filesystem/FileSystemToolbar.vue
Expand Up @@ -142,7 +142,7 @@
>
<v-tabs>
<v-tab
v-for="(root, index) in registeredRoots"
v-for="(root, index) in roots"
:key="index"
@change="$emit('root-change', root)"
>
Expand Down Expand Up @@ -220,11 +220,6 @@ export default class FileSystemToolbar extends Mixins(StatesMixin) {
return this.$store.getters['files/getRootProperties'](this.root) as RootProperties
}
// Only show roots that have been registered.
get registeredRoots () {
return this.roots?.filter(r => this.$store.state.server.info.registered_directories.includes(r))
}
get thumbnailSize () {
return this.$store.state.config.uiSettings.general.thumbnailSize
}
Expand Down

0 comments on commit ff0b120

Please sign in to comment.