From 4574b7f03ccc85c4bebdbfd9475788456086704f Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 8 Aug 2024 12:27:40 -0400
Subject: many changes to add typing in place of 'any's etc

---
 src/client/util/ServerStats.tsx | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

(limited to 'src/client/util/ServerStats.tsx')

diff --git a/src/client/util/ServerStats.tsx b/src/client/util/ServerStats.tsx
index 57363663d..11db5ee5e 100644
--- a/src/client/util/ServerStats.tsx
+++ b/src/client/util/ServerStats.tsx
@@ -6,18 +6,29 @@ import './SharingManager.scss';
 import { PingManager } from './PingManager';
 import { SettingsManager } from './SettingsManager';
 
+/**
+ * NOTE: this must be kept in synch with UserStats definition in server's DashStats.ts file
+ * UserStats holds the stats associated with a particular user.
+ */
+interface UserStats {
+    socketId: string;
+    username: string;
+    time: string;
+    operations: number;
+    rate: number;
+}
 @observer
-export class ServerStats extends React.Component<{}> {
+export class ServerStats extends React.Component<object> {
     // eslint-disable-next-line no-use-before-define
     public static Instance: ServerStats;
     @observable private isOpen = false; // whether the SharingManager modal is open or not
 
-    @observable _stats: { [key: string]: any } | undefined = undefined;
+    @observable _stats: { socketMap: UserStats[]; currentConnections: number } | undefined = undefined;
     // private get linkVisible() {
     //     return this.targetDoc ? this.targetDoc['acl_' + PublicKey] !== SharingPermissions.None : false;
     // }
 
-    constructor(props: {}) {
+    constructor(props: object) {
         super(props);
         makeObservable(this);
         ServerStats.Instance = this;
@@ -41,7 +52,7 @@ export class ServerStats extends React.Component<{}> {
 
                     <br />
                     <span>Active users:{this._stats?.socketMap.length}</span>
-                    {this._stats?.socketMap.map((user: any) => <p>{user.username}</p>)}
+                    {this._stats?.socketMap.map(user => <p key={user.username}>{user.username}</p>)}
                 </div>
             </div>
         );
-- 
cgit v1.2.3-70-g09d2

