From 66fb0e4bbf88a5e9bcb5869dd7c8b8a7714de024 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 18 Jan 2022 12:10:47 -0500 Subject: fixed warnings. display last user to edit db. fixed /activity to show only users with a connected socket. fixed toggle "Overlay" button to toggle its background based on overlay state. --- src/server/ApiManagers/UserManager.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/server/ApiManagers') diff --git a/src/server/ApiManagers/UserManager.ts b/src/server/ApiManagers/UserManager.ts index f36506b14..fe80c6a7c 100644 --- a/src/server/ApiManagers/UserManager.ts +++ b/src/server/ApiManagers/UserManager.ts @@ -4,6 +4,7 @@ import { Database } from "../database"; import { msToTime } from "../ActionUtilities"; import * as bcrypt from "bcrypt-nodejs"; import { Opt } from "../../fields/Doc"; +import { WebSocket } from "../websocket"; export const timeMap: { [id: string]: number } = {}; interface ActivityUnit { @@ -131,9 +132,12 @@ export default class UserManager extends ApiManager { for (const user in timeMap) { const time = timeMap[user]; - const duration = now - time; - const target = (duration / 1000) < (60 * 5) ? activeTimes : inactiveTimes; - target.push({ user, duration }); + const socketPair = Array.from(WebSocket.socketMap).find(pair => pair[1] === user); + if (socketPair && !socketPair[0].disconnected) { + const duration = now - time; + const target = (duration / 1000) < (60 * 5) ? activeTimes : inactiveTimes; + target.push({ user, duration }); + } } const process = (target: { user: string, duration: number }[]) => { -- cgit v1.2.3-70-g09d2