Refactor
This commit is contained in:
parent
686e276163
commit
c605734d8f
|
@ -31,16 +31,7 @@ async function setAllDevicesAsOffline() {
|
|||
})
|
||||
}
|
||||
|
||||
async function updateDevicesInfo() {
|
||||
if (working) return -1 // Debounce updates
|
||||
|
||||
working = true
|
||||
|
||||
try {
|
||||
const onlineDevices = await getOnlineDevices()
|
||||
|
||||
await setAllDevicesAsOffline()
|
||||
|
||||
async function updateDB(onlineDevices) {
|
||||
for (const device of onlineDevices) {
|
||||
if (!device.user)
|
||||
await prisma.$executeRaw(
|
||||
|
@ -72,6 +63,19 @@ async function updateDevicesInfo() {
|
|||
console.log('[wifiDevice upsert error]', e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function updateDevicesInfo() {
|
||||
if (working) return -1 // Debounce updates
|
||||
|
||||
working = true
|
||||
|
||||
try {
|
||||
const onlineDevices = await getOnlineDevices()
|
||||
|
||||
await setAllDevicesAsOffline()
|
||||
|
||||
await updateDB(onlineDevices)
|
||||
|
||||
pubsub.publish(USER_PRESENCE_UPDATED, {
|
||||
userPresenceUpdated: onlineDevices.length
|
||||
|
|
Loading…
Reference in New Issue
Block a user