Skip to content

Commit

Permalink
feat: hide/ignore .git directories in file init process (#1227)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Jan 29, 2023
1 parent e7eb94f commit 051b896
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
46 changes: 24 additions & 22 deletions src/store/files/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@/store/files/types'
import { RootState } from '@/store/types'
import i18n from '@/plugins/i18n'
import { validGcodeExtensions } from '@/store/variables'
import { hiddenDirectories, validGcodeExtensions } from '@/store/variables'
import axios from 'axios'

export const actions: ActionTree<FileState, RootState> = {
Expand Down Expand Up @@ -67,28 +67,30 @@ export const actions: ActionTree<FileState, RootState> = {
}

if (payload.dirs?.length) {
payload.dirs.forEach((dir: ApiGetDirectoryReturnDir) => {
if (
directory?.childrens?.findIndex(
(element: FileStateFile) => element.isDirectory && element.filename === dir.dirname
) === -1
) {
commit('setCreateDir', {
item: {
path: path.length ? path + '/' + dir.dirname : dir.dirname,
root: root,
permissions: dir.permissions,
modified: dir.modified * 1000,
},
})
payload.dirs
.filter((dir) => !hiddenDirectories.includes(dir.dirname))
.forEach((dir: ApiGetDirectoryReturnDir) => {
if (
directory?.childrens?.findIndex(
(element: FileStateFile) => element.isDirectory && element.filename === dir.dirname
) === -1
) {
commit('setCreateDir', {
item: {
path: path.length ? path + '/' + dir.dirname : dir.dirname,
root: root,
permissions: dir.permissions,
modified: dir.modified * 1000,
},
})

Vue.$socket.emit(
'server.files.get_directory',
{ path: payload.requestParams.path + '/' + dir.dirname },
{ action: 'files/getDirectory' }
)
}
})
Vue.$socket.emit(
'server.files.get_directory',
{ path: payload.requestParams.path + '/' + dir.dirname },
{ action: 'files/getDirectory' }
)
}
})
}

if (payload.files?.length) {
Expand Down
5 changes: 5 additions & 0 deletions src/store/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ export const timelapseConsoleFilters = [
*/
export const hiddenRootDirectories = ['gcodes', 'timelapse', 'timelapse_frames']

/*
* Hide directories
*/
export const hiddenDirectories = ['.git']

/*
* List of available Klipper config reference translations
* https://www.klipper3d.org/Config_Reference.html
Expand Down

0 comments on commit 051b896

Please sign in to comment.