Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
42 changes: 42 additions & 0 deletions pnpm-lock.yaml

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

5 changes: 3 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 @@ -433,11 +434,11 @@ export default class App extends Mixins(StateMixin, FilesMixin, BrowserMixin) {

const wait = `${this.$waits.onFileSystem}/${pathWithRoot}/`

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

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

this.$typedDispatch('wait/removeWait', wait)
useWaitStore().removeWait(wait)
}
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/api/socketActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Vue from 'vue'
import { Globals, Waits } from '@/globals'
import type { NotifyOptions } from '@/plugins/socketClient'
import { consola } from 'consola'
import { useAnalysisStore } from '@/stores/analysis'

const baseEmit = async <T = unknown>(method: string, options: NotifyOptions): Promise<T> => {
if (!Vue.$socket) {
Expand Down Expand Up @@ -921,10 +922,13 @@ export const SocketActions = {
serverAnalysisStatus (options?: NotifyOptions) {
return baseEmit<Moonraker.Analysis.StatusResponse>(
'server.analysis.status', {
dispatch: 'analysis/onAnalysisStatus',
...options
}
)
).then((result) => {
Comment thread
pedrolamas marked this conversation as resolved.
Outdated
useAnalysisStore().onAnalysisStatus(result)

return result
})
},

serverAnalysisEstimate (filename: string, estimator_config?: string, options?: NotifyOptions) {
Expand All @@ -944,15 +948,20 @@ export const SocketActions = {
return baseEmit<Moonraker.Analysis.ProcessResponse>(
'server.analysis.process', {
wait: `${Waits.onFileSystem}/gcodes/${filename}`,
dispatch: 'analysis/onAnalysisProcess',
...options,
params: {
filename,
estimator_config,
force
}
}
)
).then((result) => {
Comment thread
pedrolamas marked this conversation as resolved.
Outdated
if (!result.bypassed) {
SocketActions.serverFilesMetadata(filename)
}

return result
})
},

accessInfo (options?: NotifyOptions) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/widgets/filesystem/FileSystem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ 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 type { KlipperSaveAndRestartAction } from '@/store/config/types'

/**
Expand Down Expand Up @@ -1142,11 +1143,11 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
async handleUpload (files: FileList | File[] | FileWithPath[], print: boolean) {
const wait = `${this.$waits.onFileSystem}/${this.currentPath}/`

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

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

this.$typedDispatch('wait/removeWait', wait)
useWaitStore().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/pinia'

// 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)
Comment thread
pedrolamas marked this conversation as resolved.
}

/**
* 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
5 changes: 3 additions & 2 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'

const LOG_PREFIX = '[WEBSOCKET]'

Expand Down Expand Up @@ -82,7 +83,7 @@ export class WebSocketClient {

// Remove a wait if defined.
if (request?.wait?.length) {
this.store.typedCommit('wait/setRemoveWait', request.wait)
useWaitStore().removeWait(request.wait)
Comment thread
pedrolamas marked this conversation as resolved.
}

if ('error' in socketResponse) { // Is it in error?
Expand Down Expand Up @@ -244,7 +245,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 @@ -58,7 +59,7 @@ export const actions = {
// vuetify.framework.lang.current = state.uiSettings.general.locale

// Add the wait.
dispatch('wait/addWait', Waits.onLoadLanguage, { root: true })
useWaitStore().addWait(Waits.onLoadLanguage)

// Grab the browsers starting locale.
const startingLocale = getStartingLocale()
Expand All @@ -78,7 +79,7 @@ export const actions = {
server: true
})
}
dispatch('wait/removeWait', Waits.onLoadLanguage, { root: true })
useWaitStore().removeWait(Waits.onLoadLanguage)
},

/**
Expand Down
Loading