diff options
author | bobzel <zzzman@gmail.com> | 2022-01-18 12:10:47 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2022-01-18 12:10:47 -0500 |
commit | 66fb0e4bbf88a5e9bcb5869dd7c8b8a7714de024 (patch) | |
tree | a73266808167bdfc057cee44bb8d40c31b993edb /src/server/ApiManagers/UserManager.ts | |
parent | 4cdfa6c29701d372064eb4dc612807a27cb19857 (diff) |
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.
Diffstat (limited to 'src/server/ApiManagers/UserManager.ts')
-rw-r--r-- | src/server/ApiManagers/UserManager.ts | 10 |
1 files changed, 7 insertions, 3 deletions
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 }[]) => { |