Skip to content
Open
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"md5": "^2.3.0",
"monaco-editor": "^0.56.0",
"panzoom": "^9.4.4",
"pinia": "^2.3.1",
"qr-scanner": "^1.4.2",
"qrcode.vue": "^1.7.0",
"semver": "^7.8.5",
Expand Down
36 changes: 32 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ overrides:
typescript-eslint: ^8.66.0
vite: 'catalog:'
vue: 'catalog:'
vue-demi: ^0.14.10
'@originjs/vite-plugin-content>xlsx': '-'
6 changes: 4 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ import FileSystemUploadDialog from '@/components/widgets/filesystem/FileSystemUp
import SpoolSelectionDialog from '@/components/widgets/spoolman/SpoolSelectionDialog.vue'
import type { FlashMessage } from '@/types'
import { getFilesFromDataTransfer, hasFilesInDataTransfer } from '@/util/file-system-entry'
import { useWaitStore } from '@/stores/wait'
import type { ThemeConfig } from '@/store/config/types'
import ActionCommandPromptDialog from '@/components/common/ActionCommandPromptDialog.vue'
import KeyboardShortcutsDialog from '@/components/common/KeyboardShortcutsDialog.vue'
Expand Down Expand Up @@ -432,12 +433,13 @@ export default class App extends Mixins(StateMixin, FilesMixin, BrowserMixin) {
: pathWithRoot.substring(root.length + 1)

const wait = `${this.$waits.onFileSystem}/${pathWithRoot}/`
const waitStore = useWaitStore()

this.$typedDispatch('wait/addWait', wait)
waitStore.addWait(wait)

await this.uploadFiles(files, path, root, false)

this.$typedDispatch('wait/removeWait', wait)
waitStore.removeWait(wait)
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/api/socketActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,15 +930,6 @@ export const SocketActions = {
)
},

serverAnalysisStatus (options?: NotifyOptions) {
return baseEmit<Moonraker.Analysis.StatusResponse>(
'server.analysis.status', {
dispatch: 'analysis/onAnalysisStatus',
...options
}
)
},

serverAnalysisEstimate (filename: string, estimator_config?: string, options?: NotifyOptions) {
return baseEmit<Moonraker.Analysis.EstimateResponse>(
'server.analysis.estimate', {
Expand All @@ -956,7 +947,6 @@ export const SocketActions = {
return baseEmit<Moonraker.Analysis.ProcessResponse>(
'server.analysis.process', {
wait: `${Waits.onFileSystem}/gcodes/${filename}`,
dispatch: 'analysis/onAnalysisProcess',
...options,
params: {
filename,
Expand Down
12 changes: 9 additions & 3 deletions src/components/widgets/filesystem/FileSystem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ import { getFilesFromDataTransfer, hasFilesInDataTransfer } from '@/util/file-sy
import { getFileDataTransferDataFromDataTransfer, hasFileDataTransferTypeInDataTransfer, setFileDataTransferDataInDataTransfer } from '@/util/file-data-transfer'
import { consola } from 'consola'
import type { DataTableHeader } from 'vuetify'
import { useWaitStore } from '@/stores/wait'
import { useAnalysisStore } from '@/stores/analysis'
import type { KlipperSaveAndRestartAction } from '@/store/config/types'

/**
Expand Down Expand Up @@ -897,8 +899,11 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
.filter((item): item is AppFileWithMeta => item.type === 'file' && this.rootProperties.accepts.includes(item.extension))
.map(file => file.path ? `${file.path}/${file.filename}` : file.filename)

const analysisStore = useAnalysisStore()

for (const filename of filenames) {
SocketActions.serverAnalysisProcess(filename, undefined, true)
analysisStore.process(filename, undefined, true)
.catch(error => consola.error('[FileSystem] time analysis', error))
}
}

Expand Down Expand Up @@ -1137,12 +1142,13 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM

async handleUpload (files: FileList | File[] | FileWithPath[], print: boolean) {
const wait = `${this.$waits.onFileSystem}/${this.currentPath}/`
const waitStore = useWaitStore()

this.$typedDispatch('wait/addWait', wait)
waitStore.addWait(wait)

await this.uploadFiles(files, this.visiblePath, this.currentRoot, print)

this.$typedDispatch('wait/removeWait', wait)
waitStore.removeWait(wait)
}

handleAddDir (name: string) {
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Vue from 'vue'
import i18n from '@/plugins/i18n'
import router from './router'
import store from './store'
import pinia from '@/stores'

// 3rd party.
import vuetify from './plugins/vuetify'
Expand Down Expand Up @@ -58,6 +59,7 @@ new Vue({
i18n,
router,
store,
pinia,
vuetify,
render: (h) => h(App)
}).$mount('#app')
Expand Down
7 changes: 4 additions & 3 deletions src/mixins/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SocketActions } from '@/api/socketActions'
import { Component } from 'vue-property-decorator'
import type { Macro } from '@/store/macros/types'
import type { PrinterStatus } from '@/store/printer/types'
import { useWaitStore } from '@/stores/wait'

@Component
export default class StateMixin extends Vue {
Expand Down Expand Up @@ -92,21 +93,21 @@ export default class StateMixin extends Vue {
* Supports a single string or a list of.
*/
hasWait (wait: string | string[]): boolean {
return this.$typedGetters['wait/hasWait'](wait)
return useWaitStore().hasWait(wait)
}

/**
* Indicates if we have any waits.
*/
get hasWaits (): boolean {
return this.$typedGetters['wait/hasWaits']
return useWaitStore().hasWaits
}

/**
* Indicates if we have any waits prefixed by.
*/
hasWaitsBy (prefix: string): boolean {
return this.$typedGetters['wait/hasWaitsBy'](prefix)
return useWaitStore().hasWaitsBy(prefix)
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/socketClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type _Vue from 'vue'
import { consola } from 'consola'
import { camelCase, mergeWith } from 'lodash-es'
import type { TypedStore } from '@/store'
import { useWaitStore } from '@/stores/wait'
import type { SocketError } from '@/store/socket/types'

const LOG_PREFIX = '[WEBSOCKET]'
Expand Down Expand Up @@ -105,7 +106,7 @@ export class WebSocketClient {

// Remove a wait if defined.
if (request?.wait?.length) {
this.store.typedCommit('wait/setRemoveWait', request.wait)
useWaitStore().removeWait(request.wait)
}

if ('error' in socketResponse) { // Is it in error?
Expand Down Expand Up @@ -136,7 +137,6 @@ export class WebSocketClient {
Object.defineProperty(result, '__request__', { enumerable: false, value: request })

consola.debug(`${LOG_PREFIX} Response:`, result)

if (request.dispatch) {
this.store.dispatch(request.dispatch, result)
}
Expand Down Expand Up @@ -270,7 +270,7 @@ export class WebSocketClient {
}

if (wait) {
this.store.typedDispatch('wait/addWait', wait)
useWaitStore().addWait(wait)
}

this.requests.set(id, request)
Expand Down
27 changes: 0 additions & 27 deletions src/store/analysis/actions.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/store/analysis/getters.ts

This file was deleted.

17 changes: 0 additions & 17 deletions src/store/analysis/index.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/store/analysis/mutations.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/store/analysis/state.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/store/analysis/types.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/store/config/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Waits } from '@/globals'
import type { FileFilterType } from '../files/types'
import { TinyColor } from '@ctrl/tinycolor'
import dbKey from '@/util/db-key'
import { useWaitStore } from '@/stores/wait'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low. Relative '../../stores/wait' here, but @/stores/analysis in src/store/index.ts (and '../stores/wait' on the line above it) — three styles for the same target.

Given src/stores/ sits one character away from the existing src/store/, mixed relative paths between the two trees are a real typo hazard: ../stores/… mistyped as ../store/… resolves to a different, existing directory and silently imports the wrong thing. Suggest standardising on @/stores/… everywhere, and possibly a less collision-prone directory name (src/pinia/).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that's my error, ill standardize to '@/'

I see valid concern here about store/stores. I took the naming from Pinia's migration guide regarding stores. End state @/stores makes a more descriptive folder structure for maintainability long term and fits the style of the rest of the code base where folders are generally descriptive by function rather than library. How would you like to proceed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, please continue with @/stores plan, and keep an eye to make sure there are no leftovers on @/store after migration.

export const actions = {
/**
Expand Down Expand Up @@ -54,7 +55,7 @@ export const actions = {
* Sets, and saves a locale change.
*/
async onLocaleChange ({ dispatch, state }, payload: string) {
dispatch('wait/addWait', Waits.onLoadLanguage, { root: true })
useWaitStore().addWait(Waits.onLoadLanguage)

try {
const locale = await loadLocaleMessagesAsync(
Expand All @@ -75,7 +76,7 @@ export const actions = {
})
}
} finally {
dispatch('wait/removeWait', Waits.onLoadLanguage, { root: true })
useWaitStore().removeWait(Waits.onLoadLanguage)
}
},

Expand Down
Loading