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
6 changes: 3 additions & 3 deletions src/components/layout/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ import UserPasswordDialog from '@/components/settings/auth/UserPasswordDialog.vu
import PendingChangesDialog from '@/components/settings/PendingChangesDialog.vue'
import AppSaveConfigAndRestartBtn from './AppSaveConfigAndRestartBtn.vue'
import AppUploadAndPrintBtn from './AppUploadAndPrintBtn.vue'
import { defaultState } from '@/store/layout/state'
import { createState } from '@/store/layout/state'
import StateMixin from '@/mixins/state'
import ServicesMixin from '@/mixins/services'
import FilesMixin from '@/mixins/files'
Expand Down Expand Up @@ -404,7 +404,7 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin
? this.$route.name
: undefined
const layoutDefaultState = pathLayout
? defaultState().layouts[pathLayout]
? createState().layouts[pathLayout]
: this.$typedGetters['layout/getLayout']('dashboard')!

const toReset = pathLayout ?? this.$typedGetters['layout/getSpecificLayoutName']
Expand Down Expand Up @@ -437,7 +437,7 @@ export default class AppBar extends Mixins(StateMixin, ServicesMixin, FilesMixin
handleResetDefaultLayout () {
this.$typedDispatch('layout/onLayoutChange', {
name: 'dashboard',
value: defaultState().layouts.dashboard
value: createState().layouts.dashboard
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/settings/FileEditorSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import StateMixin from '@/mixins/state'
import { defaultState } from '@/store/config/state'
import { createState } from '@/store/config/state'
import type { KlipperSaveAndRestartAction, RestoreViewState } from '@/store/config/types'

@Component({})
Expand Down Expand Up @@ -195,7 +195,7 @@ export default class FileEditorSettings extends Mixins(StateMixin) {
handleReset () {
this.$typedDispatch('config/saveByPath', {
path: 'uiSettings.editor',
value: defaultState().uiSettings.editor,
value: createState().uiSettings.editor,
server: true
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/settings/GcodePreviewSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { defaultState } from '@/store/config/state'
import { createState } from '@/store/config/state'

@Component({
components: {}
Expand Down Expand Up @@ -365,7 +365,7 @@ export default class GcodePreviewSettings extends Vue {
handleReset () {
this.$typedDispatch('config/saveByPath', {
path: 'uiSettings.gcodePreview',
value: defaultState().uiSettings.gcodePreview,
value: createState().uiSettings.gcodePreview,
server: true
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/settings/MmuSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
import { Component, Mixins } from 'vue-property-decorator'
import StateMixin from '@/mixins/state'
import MmuMixin from '@/mixins/mmu'
import { defaultState } from '@/store/config/state'
import { createState } from '@/store/config/state'

@Component({
components: {}
Expand Down Expand Up @@ -215,7 +215,7 @@ export default class MmuSettings extends Mixins(StateMixin, MmuMixin) {
handleReset () {
this.$typedDispatch('config/saveByPath', {
path: 'uiSettings.mmu',
value: defaultState().uiSettings.mmu,
value: createState().uiSettings.mmu,
server: true
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/settings/SpoolmanSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import { defaultState } from '@/store/config/state'
import { createState } from '@/store/config/state'
import StateMixin from '@/mixins/state'
import type { SpoolmanRemainingFilamentUnit } from '@/store/config/types'

Expand Down Expand Up @@ -281,7 +281,7 @@ export default class SpoolmanSettings extends Mixins(StateMixin) {
handleReset () {
this.$typedDispatch('config/saveByPath', {
path: 'uiSettings.spoolman',
value: defaultState().uiSettings.spoolman,
value: createState().uiSettings.spoolman,
server: true
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/settings/ToolheadSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@

<script lang="ts">
import { Component, Ref, Mixins } from 'vue-property-decorator'
import { defaultState } from '@/store/config/state'
import { createState } from '@/store/config/state'
import type { VCombobox } from 'vuetify/lib'
import ToolheadMixin from '@/mixins/toolhead'
import type { GeneralConfig, ToolheadControlStyle } from '@/store/config/types'
Expand Down Expand Up @@ -729,7 +729,7 @@ export default class ToolHeadSettings extends Mixins(ToolheadMixin) {
const { instanceName, chartVisible, chartSmoothingWindow, hideTempWaits }: GeneralConfig = this.$typedState.config.uiSettings.general

const value: GeneralConfig = {
...defaultState().uiSettings.general,
...createState().uiSettings.general,
instanceName,
chartVisible,
chartSmoothingWindow,
Expand Down
4 changes: 2 additions & 2 deletions src/components/settings/WarningsSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { defaultState } from '@/store/config/state'
import { createState } from '@/store/config/state'

@Component({})
export default class WarningsSettings extends Vue {
Expand Down Expand Up @@ -81,7 +81,7 @@ export default class WarningsSettings extends Vue {
handleReset () {
this.$typedDispatch('config/saveByPath', {
path: 'uiSettings.warnings',
value: defaultState().uiSettings.warnings,
value: createState().uiSettings.warnings,
server: true
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
import { Component, Vue, Prop } from 'vue-property-decorator'
import type { DiagnosticsCardConfig } from '@/store/diagnostics/types'
import MetricsCollectorConfig from './MetricsCollectorConfig.vue'
import { defaultState } from '@/store/layout/state'
import { createDiagnosticsCardState } from '@/store/layout/state'

@Component({
components: {
Expand All @@ -180,8 +180,7 @@ export default class MetricsConfigStep extends Vue {
]

addMetric (axis: number) {
const defaultCard = defaultState().layouts.diagnostics.container1[0] as DiagnosticsCardConfig
const defaultMetric = defaultCard.axes[0].metrics[0]
const defaultMetric = createDiagnosticsCardState().axes[0].metrics[0]

this.config.axes[axis].metrics.push(defaultMetric)
}
Expand Down
8 changes: 3 additions & 5 deletions src/store/afc/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import type { Module } from 'vuex'
import { state } from './state'
import { createState } from './state'
import { getters } from './getters'
import { actions } from './actions'
import { mutations } from './mutations'
import type { AfcState } from './types'
import type { RootState } from '../types'

const namespaced = true

export const afc = {
namespaced,
state,
namespaced: true,
state: createState,
getters,
actions,
mutations
Expand Down
4 changes: 2 additions & 2 deletions src/store/afc/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { MutationTree } from 'vuex'
import type { AfcDialogState, AfcState } from './types'
import { defaultState } from './state'
import { createState } from './state'

export const mutations = {
/**
* Reset state
*/
setReset (state) {
Object.assign(state, defaultState())
Object.assign(state, createState())
},

setDialogState (state, payload: AfcDialogState) {
Expand Down
4 changes: 1 addition & 3 deletions src/store/afc/state.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { AfcState } from './types'

export const defaultState = (): AfcState => {
export const createState = (): AfcState => {
return {
dialog: {
show: false
}
}
}

export const state = defaultState()
8 changes: 3 additions & 5 deletions src/store/analysis/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import type { Module } from 'vuex'
import { state } from './state'
import { createState } from './state'
import { getters } from './getters'
import { actions } from './actions'
import { mutations } from './mutations'
import type { AnalysisState } from './types'
import type { RootState } from '../types'

const namespaced = true

export const analysis = {
namespaced,
state,
namespaced: true,
state: createState,
getters,
actions,
mutations
Expand Down
4 changes: 2 additions & 2 deletions src/store/analysis/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { MutationTree } from 'vuex'
import type { AnalysisState } from './types'
import { defaultState } from './state'
import { createState } from './state'

export const mutations = {
/**
* Reset state
*/
setReset (state) {
Object.assign(state, defaultState())
Object.assign(state, createState())
},

setAnalysisStatus (state, payload: Moonraker.Analysis.StatusResponse) {
Expand Down
4 changes: 1 addition & 3 deletions src/store/analysis/state.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { AnalysisState } from './types'

export const defaultState = (): AnalysisState => {
export const createState = (): AnalysisState => {
return {
status: null
}
}

export const state = defaultState()
8 changes: 3 additions & 5 deletions src/store/announcements/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import type { Module } from 'vuex'
import { state } from './state'
import { createState } from './state'
import { getters } from './getters'
import { actions } from './actions'
import { mutations } from './mutations'
import type { AnnouncementsState } from './types'
import type { RootState } from '../types'

const namespaced = true

export const announcements = {
namespaced,
state,
namespaced: true,
state: createState,
getters,
actions,
mutations
Expand Down
4 changes: 2 additions & 2 deletions src/store/announcements/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { MutationTree } from 'vuex'
import { defaultState } from './state'
import { createState } from './state'
import type { AnnouncementsState } from './types'

export const mutations = {
/**
* Reset state
*/
setReset (state) {
Object.assign(state, defaultState())
Object.assign(state, createState())
},

setAnnouncementsList (state, payload: Moonraker.Announcements.ListResponse) {
Expand Down
4 changes: 1 addition & 3 deletions src/store/announcements/state.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { AnnouncementsState } from './types'

export const defaultState = (): AnnouncementsState => {
export const createState = (): AnnouncementsState => {
return {
entries: [],
feeds: []
}
}

export const state = defaultState()
8 changes: 3 additions & 5 deletions src/store/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import type { Module } from 'vuex'
import { state } from './state'
import { createState } from './state'
import { getters } from './getters'
import { actions } from './actions'
import { mutations } from './mutations'
import type { AuthState } from './types'
import type { RootState } from '../types'

const namespaced = true

export const auth = {
namespaced,
state,
namespaced: true,
state: createState,
getters,
actions,
mutations
Expand Down
4 changes: 2 additions & 2 deletions src/store/auth/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { MutationTree } from 'vuex'
import { defaultState } from './state'
import { createState } from './state'
import type { AppUser, AuthState } from './types'

export const mutations = {
/**
* Reset state
*/
setReset (state) {
Object.assign(state, defaultState())
Object.assign(state, createState())
},

setCurrentUser (state, user: AppUser | null) {
Expand Down
4 changes: 1 addition & 3 deletions src/store/auth/state.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { AuthState } from './types'

export const defaultState = (): AuthState => {
export const createState = (): AuthState => {
return {
currentUser: null,
users: [],
apiKey: ''
}
}

export const state = defaultState()
8 changes: 3 additions & 5 deletions src/store/charts/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import type { Module } from 'vuex'
import { state } from './state'
import { createState } from './state'
import { getters } from './getters'
import { actions } from './actions'
import { mutations } from './mutations'
import type { ChartState } from './types'
import type { RootState } from '../types'

const namespaced = true

export const charts = {
namespaced,
state,
namespaced: true,
state: createState,
getters,
actions,
mutations
Expand Down
6 changes: 3 additions & 3 deletions src/store/charts/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { MutationTree } from 'vuex'
import { appendChartSamples, createChartBuffer, resizeChartBuffer } from '@/util/chart-buffer'
import { Globals } from '@/globals'
import type { ChartBucket, ChartBuffer, ChartEntriesPayload, ChartEntryPayload, ChartsDbDocument, ChartSelectedLegends, ChartState } from './types'
import { defaultState } from './state'
import { createState } from './state'

const resolveBuffer = (state: ChartState, payload: ChartBucket): ChartBuffer => {
switch (payload.bucket) {
Expand Down Expand Up @@ -37,11 +37,11 @@ export const mutations = {
* Reset our store
*/
setReset (state) {
Object.assign(state, defaultState())
Object.assign(state, createState())
},

setResetChartStore (state) {
const { thermal, ready } = defaultState()
const { thermal, ready } = createState()

Object.assign(state, {
thermal,
Expand Down
Loading