diff --git a/.corenode b/.corenode index a005c72a..2b0be6b5 100755 --- a/.corenode +++ b/.corenode @@ -1,3 +1,3 @@ { - "version": "0.17.1" + "version": "0.17.2" } diff --git a/package.json b/package.json index c1d50e53..b7385a60 100644 --- a/package.json +++ b/package.json @@ -9,5 +9,5 @@ "dependencies": { "corenode": "^0.28.26" }, - "version": "0.17.1" + "version": "0.17.2" } diff --git a/packages/app/constants/settings/account.jsx b/packages/app/constants/settings/account.jsx index 9e57bb71..760eec89 100644 --- a/packages/app/constants/settings/account.jsx +++ b/packages/app/constants/settings/account.jsx @@ -144,6 +144,6 @@ export default [ "type": "Button", "icon": "LogOut", "title": "Logout", - "emitEvent": "logout", + "emitEvent": "session.logout", } ] \ No newline at end of file diff --git a/packages/app/package.json b/packages/app/package.json index 647df6bf..c4adc3a3 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,6 +1,6 @@ { "name": "comty", - "version": "0.17.1", + "version": "0.17.2", "license": "MIT", "scripts": { "dev": "vite", diff --git a/packages/app/src/App.jsx b/packages/app/src/App.jsx index 8528afcf..82f08f22 100644 --- a/packages/app/src/App.jsx +++ b/packages/app/src/App.jsx @@ -53,7 +53,7 @@ import { Translation } from "react-i18next" import { Session, User } from "models" import config from "config" -import { NotFound, RenderError, Crash, Settings, Navigation } from "components" +import { NotFound, RenderError, Crash, Settings, Navigation, Login } from "components" import { Icons } from "components/Icons" import Layout from "./layout" @@ -62,7 +62,16 @@ import * as Render from "extensions/render.extension.jsx" import "theme/index.less" class App extends React.Component { - //static debugMode = true + //static debugMode = true // this will enable debug mode of evite app (dah...) + + sessionController = new Session() + + userController = new User() + + state = { + session: null, + user: null, + } loadingMessage = false @@ -71,6 +80,16 @@ class App extends React.Component { } static eventsHandlers = { + "app.createLogin": async function () { + app.DrawerController.open("login", Login, { + componentProps: { + sessionController: this.sessionController + } + }) + }, + "session.logout": async function () { + await this.sessionController.logout() + }, "new_session": async function () { await this.flushState() await this.initialization() @@ -85,11 +104,12 @@ class App extends React.Component { this.eventBus.emit("forceToLogin") }, "forceToLogin": function () { - if (window.location.pathname !== "/login") { - this.beforeLoginLocation = window.location.pathname - } + // if (window.location.pathname !== "/login") { + // this.beforeLoginLocation = window.location.pathname + // } - window.app.setLocation("/login") + // window.app.setLocation("/login") + app.eventBus.emit("app.createLogin") }, "invalid_session": async function (error) { await this.sessionController.forgetLocalSession() @@ -246,13 +266,6 @@ class App extends React.Component { } } - sessionController = new Session() - userController = new User() - state = { - session: null, - user: null, - } - flushState = async () => { await this.setState({ session: null, user: null }) } diff --git a/packages/app/src/pages/login/index.jsx b/packages/app/src/components/Login/index.jsx similarity index 64% rename from packages/app/src/pages/login/index.jsx rename to packages/app/src/components/Login/index.jsx index 79f9f7c1..ead2d74c 100644 --- a/packages/app/src/pages/login/index.jsx +++ b/packages/app/src/components/Login/index.jsx @@ -98,46 +98,33 @@ export default class Login extends React.Component { if (typeof this.props.onDone === "function") { this.props.onDone() } - } - componentWillUnmount() { - window.app.SidebarController.toogleVisible(true) - window.app.HeaderController.toogleVisible(true) - } - - componentDidMount() { - const sidebarVisible = window.app.SidebarController.isVisible() - const headerVisible = window.app.HeaderController.isVisible() - - if (sidebarVisible) { - window.app.SidebarController.toogleVisible(false) - } - - if (headerVisible) { - window.app.HeaderController.toogleVisible(false) + if (typeof this.props.close === "function") { + this.props.close() } } render() { - return ( -