fix: rework wallet screen

This commit is contained in:
Taranto 2020-04-07 19:03:18 +01:00 committed by Josh Harvey
parent 1f7ae74b42
commit 1f6d272aa0
103 changed files with 2094 additions and 3892 deletions

View file

@ -1,20 +1,19 @@
const machineLoader = require('../machine-loader')
const { UserInputError } = require('apollo-server-express')
function getMachine(machineId) {
return machineLoader.getMachines()
.then(machines => machines.find(({ deviceId }) => deviceId === machineId))
function getMachine (machineId) {
return machineLoader.getMachines()
.then(machines => machines.find(({ deviceId }) => deviceId === machineId))
}
function machineAction({ deviceId, action }) {
return getMachine(deviceId)
.then(machine => {
if (!machine) throw new UserInputError(`machine:${deviceId} not found`, { deviceId })
return machine
})
.then(machineLoader.setMachine({ deviceId, action }))
.then(getMachine(deviceId))
function machineAction ({ deviceId, action }) {
return getMachine(deviceId)
.then(machine => {
if (!machine) throw new UserInputError(`machine:${deviceId} not found`, { deviceId })
return machine
})
.then(machineLoader.setMachine({ deviceId, action }))
.then(getMachine(deviceId))
}
module.exports = { machineAction }