Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion apps/files/src/composables/useFilenameFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,29 @@ import { watchThrottled } from '@vueuse/core'
import { onMounted, onUnmounted, ref } from 'vue'
import { FilenameFilter } from '../filters/FilenameFilter'

const searchQuery = ref('')

/**
* This is for the non-component usage to modify the query
*/
export function useSearchQuery() {
/**
* Updating the search query ref
* @param value The new value
*/
function updateQuery(value: string) {
searchQuery.value = value
}

return {
updateQuery,
}
}

/**
* This is for the `Navigation` component to provide a filename filter
*/
export function useFilenameFilter() {
const searchQuery = ref('')
const filenameFilter = new FilenameFilter()

/**
Expand Down
7 changes: 7 additions & 0 deletions apps/files/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Router, { isNavigationFailure, NavigationFailureType } from 'vue-router'
import Vue from 'vue'

import { useFilesStore } from '../store/files'
import { useSearchQuery } from '../composables/useFilenameFilter'
import { useNavigation } from '../composables/useNavigation'
import { usePathsStore } from '../store/paths'
import logger from '../logger'
Expand Down Expand Up @@ -87,6 +88,12 @@ router.beforeEach((to, from, next) => {
const fromDir = (from.query?.dir || '/') as string
const toDir = (to.query?.dir || '/') as string

if (fromDir !== toDir) {
// we navigate to another directory -> unset the query
const { updateQuery } = useSearchQuery()
updateQuery('')
}

// We are going back to a parent directory
if (relative(fromDir, toDir) === '..') {
const { currentView } = useNavigation()
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

Loading