import { action, computed, makeObservable, observable, runInAction } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { MainViewModal } from '../views/MainViewModal'; import './SharingManager.scss'; import { PingManager } from './PingManager'; import { SettingsManager } from './SettingsManager'; @observer export class ServerStats extends React.Component<{}> { // 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; // private get linkVisible() { // return this.targetDoc ? this.targetDoc['acl_' + PublicKey] !== SharingPermissions.None : false; // } constructor(props: {}) { super(props); makeObservable(this); ServerStats.Instance = this; } /** * @returns the main interface of the SharingManager. */ @computed get sharingInterface() { return (
{PingManager.Instance.IsBeating ? 'The server connection is active' : 'The server connection has been interrupted.NOTE: Any changes made will appear to persist but will be lost after a browser refreshes.'}
Active users:{this._stats?.socketMap.length} {this._stats?.socketMap.map((user: any) =>

{user.username}

)}
); } // eslint-disable-next-line react/sort-comp public close = action(() => { this.isOpen = false; }); public open = async () => { /** * Populates the list of users. */ fetch('/stats').then((res: Response) => res.text().then( action(stats => { this._stats = JSON.parse(stats); }) ) ); runInAction(() => { this.isOpen = true; }); }; render() { return ; } }