Skip to content
Snippets Groups Projects
Commit b23a068d authored by Daniel's avatar Daniel
Browse files

Revert "app/model: Hub: Add ability for multi. instances"

This reverts commit d7e158d6.
parent 74d19821
No related merge requests found
...@@ -41,19 +41,10 @@ class Hub { ...@@ -41,19 +41,10 @@ class Hub {
this.waitAsync = async (id, locations, rejectFunc) => { this.waitAsync = async (id, locations, rejectFunc) => {
let promise = new Promise((resolve, reject) => { let promise = new Promise((resolve, reject) => {
let devices = this.drivers[id] this.drivers[id] = {
// Keep device informations.
if (!devices) {
devices = []
this.drivers[id] = devices
}
devices.push({
resolve: resolve, resolve: resolve,
reject: reject reject: reject
}) }
// Pass reject function. // Pass reject function.
if (rejectFunc) { if (rejectFunc) {
...@@ -64,41 +55,25 @@ class Hub { ...@@ -64,41 +55,25 @@ class Hub {
indexLambda(id, locations) indexLambda(id, locations)
}) })
try { let userId = await promise
return await promise
} finally { // Remove indexed locations.
// Remove indexed locations. unindexLambda(id, locations)
unindexLambda(id, locations)
delete this.drivers[id] return userId
}
} }
} }
filter (location) { filter (location) {
return [...this.locations[location] || []] return this.locations[location]
} }
pick (id, userId) { pick (id, userId) {
let handle = this.drivers[id] this.drivers[id].resolve(userId)
if (handle) {
handle.forEach(h => h.resolve(userId))
return true
}
return false
} }
reject (id, reason) { reject (id, reason) {
let handle = this.drivers[id] this.drivers[id].reject(reason)
if (handle) {
handle.forEach(h => h.reject(reason))
return true
}
return false
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment