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
3 changes: 1 addition & 2 deletions src/store/announcements/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Vue from 'vue'
import type { MutationTree } from 'vuex'
import { defaultState } from './state'
import type { AnnouncementsState } from './types'
Expand Down Expand Up @@ -36,6 +35,6 @@ export const mutations = {
}
}

Vue.set(state, 'entries', entries)
state.entries = entries
}
} satisfies MutationTree<AnnouncementsState>
14 changes: 6 additions & 8 deletions src/store/config/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const mutations = {
(dest, src) => Array.isArray(dest) ? src : undefined
)

Vue.set(state, 'uiSettings', mergedSettings)
state.uiSettings = mergedSettings
}
},

Expand Down Expand Up @@ -107,7 +107,7 @@ export const mutations = {
})
}
localStorage.setItem(Globals.LOCAL_INSTANCES_STORAGE_KEY, JSON.stringify(instances))
Vue.set(state, 'instances', instances)
state.instances = instances
},

setUpdateInstanceName (state, payload) {
Expand All @@ -120,12 +120,10 @@ export const mutations = {
},

setRemoveInstance (state, payload) {
const instances = state.instances
const i = instances.findIndex((instance: InstanceConfig) => instance.apiUrl === payload.apiUrl)
if (i >= 0) {
instances.splice(i, 1)
Vue.set(state, 'instances', instances)
localStorage.setItem(Globals.LOCAL_INSTANCES_STORAGE_KEY, JSON.stringify(instances))
const index = state.instances.findIndex((instance: InstanceConfig) => instance.apiUrl === payload.apiUrl)
if (index >= 0) {
state.instances.splice(index, 1)
localStorage.setItem(Globals.LOCAL_INSTANCES_STORAGE_KEY, JSON.stringify(state.instances))
}
},

Expand Down
5 changes: 3 additions & 2 deletions src/store/console/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const mutations = {
while (state.console.length >= Globals.CONSOLE_HISTORY_RETENTION) {
state.console.shift()
}
state.console.push(entry)
state.console.push(Object.freeze(entry))
},

/**
Expand All @@ -45,6 +45,7 @@ export const mutations = {
setAllEntries (state, payload: ConsoleEntry[]) {
state.consoleEntryCount = payload.length
state.console = payload
.map(entry => Object.freeze(entry))
},

setResetPromptDialog (state, payload: string) {
Expand Down Expand Up @@ -162,6 +163,6 @@ export const mutations = {
},

setLastCleared (state) {
Vue.set(state, 'lastCleared', Date.now())
state.lastCleared = Date.now()
}
} satisfies MutationTree<ConsoleState>
3 changes: 1 addition & 2 deletions src/store/database/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Vue from 'vue'
import type { MutationTree } from 'vuex'
import { defaultState } from './state'
import type { DatabaseInfo, DatabaseState } from './types'
Expand All @@ -10,7 +9,7 @@ export const mutations = {
},

setServerDatabaseList (state, payload: DatabaseInfo) {
Vue.set(state, 'info', payload)
state.info = payload
},

setServerDatabasePostBackup (state, payload: { backup_path: string }) {
Expand Down
2 changes: 1 addition & 1 deletion src/store/files/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const mutations = {
}

if (state.currentPaths[root]) {
Vue.set(state.currentPaths, root, undefined)
Vue.delete(state.currentPaths, root)
}
Comment thread
pedrolamas marked this conversation as resolved.
},

Expand Down
2 changes: 1 addition & 1 deletion src/store/macros/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ export const mutations = {
},

setExpanded (state, expanded: number[]) {
Vue.set(state, 'expanded', expanded)
state.expanded = expanded
}
} satisfies MutationTree<MacrosState>
3 changes: 2 additions & 1 deletion src/store/notifications/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const mutations = {
},

setClearAllNotifications (state) {
Vue.set(state, 'notifications', [...state.notifications.filter(n => !n.clear)])
state.notifications = state.notifications
.filter(n => !n.clear)
}
} satisfies MutationTree<NotificationsState>
3 changes: 1 addition & 2 deletions src/store/power/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Vue from 'vue'
import type { MutationTree } from 'vuex'
import type { DevicePowerState } from './types'
import { defaultState } from './state'
Expand All @@ -19,7 +18,7 @@ export const mutations = {
for (const key in payload) {
const i = state.devices.findIndex(device => device.device === key)
if (i >= 0) {
Vue.set(state.devices[i], 'status', payload[key])
state.devices[i].status = payload[key]
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/store/sensors/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export const actions = {
SocketActions.serverSensorsList()
},

async onSensorsList ({ commit }, payload: { sensors: Moonraker.Sensor.ListResponse }) {
async onSensorsList ({ commit }, payload: Moonraker.Sensor.ListResponse) {
if (payload) {
commit('setSensorsList', payload)
}
},

async onSensorUpdate ({ commit }, payload: Record<string, Moonraker.Sensor.Entry>) {
async onSensorUpdate ({ commit }, payload: Record<string, Moonraker.Sensor.Values>) {
Comment thread
pedrolamas marked this conversation as resolved.
if (payload) {
commit('setSensorUpdate', payload)
}
Expand Down
16 changes: 12 additions & 4 deletions src/store/sensors/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Vue from 'vue'
import type { MutationTree } from 'vuex'
import type { MoonrakerSensorsState } from './types'
import { defaultState } from './state'
Expand All @@ -12,12 +11,21 @@ export const mutations = {
},

setSensorsList (state, payload: Moonraker.Sensor.ListResponse) {
state.sensors = payload.sensors
state.sensors = Object.fromEntries(
Object.entries(payload.sensors)
.map(([key, entry]) => [
key,
{
...entry,
values: Object.freeze(entry.values)
}
])
)
},

setSensorUpdate (state, payload: Record<string, Moonraker.Sensor.Entry>) {
setSensorUpdate (state, payload: Record<string, Moonraker.Sensor.Values>) {
for (const sensorKey in payload) {
Vue.set(state.sensors[sensorKey], 'values', payload[sensorKey])
state.sensors[sensorKey].values = Object.freeze(payload[sensorKey])
}
}
Comment thread
pedrolamas marked this conversation as resolved.
} satisfies MutationTree<MoonrakerSensorsState>