From dfcf086d6ce9f9a0a614395150566a9acab133d9 Mon Sep 17 00:00:00 2001 From: srgooglo Date: Thu, 4 Aug 2022 17:35:12 +0200 Subject: [PATCH] remove `serverStatus` component --- packages/app/src/App.jsx | 20 ++++++++++-- .../app/src/components/AboutApp/index.jsx | 8 ----- .../app/src/components/ServerStatus/index.jsx | 31 ------------------- packages/app/src/components/index.js | 1 - packages/app/src/pages/main/index.jsx | 6 +--- 5 files changed, 19 insertions(+), 47 deletions(-) delete mode 100644 packages/app/src/components/ServerStatus/index.jsx diff --git a/packages/app/src/App.jsx b/packages/app/src/App.jsx index 99d5a2e8..cc92cf95 100644 --- a/packages/app/src/App.jsx +++ b/packages/app/src/App.jsx @@ -313,19 +313,35 @@ class App extends React.Component { const initializationTasks = [ async () => { try { + // get remotes origins from config + const defaultRemotes = config.remotes + + // get storaged remotes origins + const storedRemotes = await app.settings.get("remotes") ?? {} + // mount main api bridge await this.props.cores.ApiCore.connectBridge("main", { - locked: true + origin: storedRemotes.mainApi ?? defaultRemotes.mainApi, + locked: true, }) // and initialize it await this.props.cores.ApiCore.namespaces["main"].initialize() + // now attach the auth server + await this.props.cores.ApiCore.connectBridge("auth", { + origin: storedRemotes.authApi ?? defaultRemotes.authApi, + locked: true, + }) + + // and initialize it + await this.props.cores.ApiCore.namespaces["auth"].initialize() + app.eventBus.emit("app.initialization.api_success") } catch (error) { app.eventBus.emit("app.initialization.api_error", error) console.error(`[App] Error while initializing api`, error) - + throw { cause: "Cannot connect to API", details: `Sorry but we cannot connect to the API. Please try again later. [${config.remotes.mainApi}]`, diff --git a/packages/app/src/components/AboutApp/index.jsx b/packages/app/src/components/AboutApp/index.jsx index 253a33f1..f715bc3b 100644 --- a/packages/app/src/components/AboutApp/index.jsx +++ b/packages/app/src/components/AboutApp/index.jsx @@ -12,8 +12,6 @@ import "./index.less" export const Card = (props) => { const isProduction = import.meta.env.PROD - const isWSMainConnected = window.app.ws.mainSocketConnected - const WSMainOrigin = app.ws.sockets.main.io.uri return { } > -
-

Server information

-
- {WSMainOrigin} -
-

Versions

diff --git a/packages/app/src/components/ServerStatus/index.jsx b/packages/app/src/components/ServerStatus/index.jsx deleted file mode 100644 index b36cdccb..00000000 --- a/packages/app/src/components/ServerStatus/index.jsx +++ /dev/null @@ -1,31 +0,0 @@ -import React from "react" -import * as antd from "antd" -import { Icons } from "components/Icons" - -export default () => { - const [connected, setConnected] = React.useState(window.app.ws.mainSocketConnected ?? false) - - window.app.eventBus.on("websocket_connected", (status) => { - setConnected(true) - }) - - window.app.eventBus.on("websocket_disconnected", (status) => { - setConnected(false) - }) - - const getColor = () => { - if (!connected) { - return "red" - } - - return "blue" - } - - return
-
- - {connected ? "Connected" : "Disconnected"} - -
-
-} \ No newline at end of file diff --git a/packages/app/src/components/index.js b/packages/app/src/components/index.js index 8dadbe29..96914a13 100644 --- a/packages/app/src/components/index.js +++ b/packages/app/src/components/index.js @@ -7,7 +7,6 @@ export { default as RenderError } from "./RenderError" export { default as ActionsBar } from "./ActionsBar" export { default as SelectableList } from "./SelectableList" export { default as ObjectInspector } from "./ObjectInspector" -export { default as ServerStatus } from "./ServerStatus" export { default as ModifierTag } from "./ModifierTag" export { default as UserSelector } from "./UserSelector" export { default as Clock } from "./Clock" diff --git a/packages/app/src/pages/main/index.jsx b/packages/app/src/pages/main/index.jsx index e65df5fb..4ea45f70 100644 --- a/packages/app/src/pages/main/index.jsx +++ b/packages/app/src/pages/main/index.jsx @@ -1,8 +1,7 @@ import React from "react" import * as antd from "antd" -import { Icons } from "components/Icons" -import { AppSearcher, ServerStatus, Clock, } from "components" +import { AppSearcher, Clock } from "components" import { Translation } from "react-i18next" import "./index.less" @@ -31,9 +30,6 @@ export default class Main extends React.Component { (t) =>

{t("main_welcome")} {user.fullName ?? user.username ?? "Guest"}

}
- {!window.isMobile &&
- -
}