This commit is contained in:
Douglas Barone 2020-12-15 11:13:18 -04:00
parent 686e276163
commit c605734d8f

View File

@ -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