Skip to content

Commit 41b336e

Browse files
committed
refactor: sort booleans as numbers
Signed-off-by: Pedro Lamas <[email protected]>
1 parent 174d6b9 commit 41b336e

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

src/components/widgets/toolhead/ToolChangeCommands.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,7 @@ export default class ToolChangeCommands extends Mixins(StateMixin) {
9797
spoolId: macro?.variables?.spool_id ? +macro.variables.spool_id : undefined
9898
}
9999
})
100-
.sort((a, b) => {
101-
const numberA = parseInt(a.name.substring(1))
102-
const numberB = parseInt(b.name.substring(1))
103-
104-
return numberA - numberB
105-
})
100+
.sort((a, b) => +a.name.substring(1) - +b.name.substring(1))
106101
}
107102
108103
get toolChangeCommandsGrouped (): ToolChangeCommand[][] {

src/store/config/getters.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { ConfigState, TemperaturePreset } from './types'
33
import type { RootState } from '../types'
44
import type { Heater, Fan } from '../printer/types'
55
import type { AppDataTableHeader } from '@/types'
6-
import md5 from 'md5'
76

87
export const getters = {
98
getCurrentInstance: (state) => {
@@ -12,14 +11,10 @@ export const getters = {
1211
},
1312

1413
getInstances: (state) => {
15-
const instances = [
16-
...state.instances
17-
].sort((a, b) =>
18-
a.active
19-
? -1
20-
: (b.active ? 1 : a.name.localeCompare(b.name))
21-
)
14+
const instances = [...state.instances]
15+
2216
return instances
17+
.sort((a, b) => +b.active - +a.active || a.name.localeCompare(b.name))
2318
},
2419

2520
/**
@@ -109,14 +104,5 @@ export const getters = {
109104
...header,
110105
...configuredHeaders.find(p => p.value === header.value)
111106
}))
112-
},
113-
114-
getTokenKeys: (state) => {
115-
const url = state.apiUrl
116-
const hash = (url) ? md5(url) : ''
117-
return {
118-
'user-token': `user-token-${hash}`,
119-
'refresh-token': `refresh-token-${hash}`
120-
}
121107
}
122108
} satisfies GetterTree<ConfigState, RootState>

src/store/mesh/getters.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,7 @@ export const getters = {
9393
}
9494

9595
return profiles.sort((a, b) =>
96-
a.name === 'default'
97-
? -1
98-
: (
99-
b.name === 'default'
100-
? 1
101-
: a.name.localeCompare(b.name)
102-
)
96+
+(b.name === 'default') - +(a.name === 'default') || a.name.localeCompare(b.name)
10397
)
10498
},
10599

0 commit comments

Comments
 (0)