Skip to content

Commit

Permalink
fix enabled toglle always false
Browse files Browse the repository at this point in the history
  • Loading branch information
SazukinPavel committed Feb 21, 2024
1 parent 7061134 commit d186472
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mocks/es/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const transport = createRouterTransport(({ service }) => {
const devicesByNs = new Map<string, Device[]>()
const nodes = new Map<string, Node[]>()

function changeDevice (key: string, uuid: string, value?: any) {
function changeDevice(key: string, uuid: string, value?: any) {
const device = devices.get(uuid) ?? new Device({ uuid })

if (value ?? true) value = !device[key]
Expand Down Expand Up @@ -157,10 +157,10 @@ export const transport = createRouterTransport(({ service }) => {
return new EmptyMessage()
},
toggle(request) {
return new Device(changeDevice('enabled', request.uuid))
return new Device(changeDevice('enabled', request.uuid, !request.enabled))
},
toggleBasic(request) {
return new Device(changeDevice('basicEnabled', request.uuid))
return new Device(changeDevice('basicEnabled', request.uuid, !request.basicEnabled))
},
makeDevicesToken(request) {
const token = Math.random().toString(16).slice(2)
Expand Down

0 comments on commit d186472

Please sign in to comment.