mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
refactor for use evite
This commit is contained in:
parent
76ab58d388
commit
e41cf70b51
@ -51,36 +51,23 @@ import { StatusBar, Style } from "@capacitor/status-bar"
|
|||||||
import { Translation } from "react-i18next"
|
import { Translation } from "react-i18next"
|
||||||
|
|
||||||
import { Session, User } from "models"
|
import { Session, User } from "models"
|
||||||
import { API, SettingsController, Render, Splash, Theme, Sound, Notifications, i18n, Debug, Shortcuts } from "extensions"
|
|
||||||
import config from "config"
|
import config from "config"
|
||||||
|
|
||||||
import { NotFound, RenderError, Crash, Settings, Navigation } from "components"
|
import { NotFound, RenderError, Crash, Settings, Navigation } from "components"
|
||||||
import { Icons } from "components/Icons"
|
import { Icons } from "components/Icons"
|
||||||
|
|
||||||
import Layout from "./layout"
|
import Layout from "./layout"
|
||||||
|
import * as Render from "extensions/render.extension.jsx"
|
||||||
|
|
||||||
import "theme/index.less"
|
import "theme/index.less"
|
||||||
|
|
||||||
const SplashExtension = Splash.extension({
|
class App extends React.Component {
|
||||||
logo: config.logo.alt,
|
//static debugMode = true
|
||||||
preset: "fadeOut",
|
|
||||||
velocity: 1000,
|
|
||||||
props: {
|
|
||||||
logo: {
|
|
||||||
style: {
|
|
||||||
marginBottom: "10%",
|
|
||||||
stroke: "black",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
class App {
|
loadingMessage = false
|
||||||
static initialize() {
|
|
||||||
window.app.version = config.package.version
|
|
||||||
|
|
||||||
this.mainSocket = this.contexts.app.WSInterface.sockets.main
|
async initialize() {
|
||||||
this.loadingMessage = false
|
console.log("[App] initialize")
|
||||||
this.isAppCapacitor = () => navigator.userAgent === "capacitor"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static eventsHandlers = {
|
static eventsHandlers = {
|
||||||
@ -177,9 +164,6 @@ class App {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"appLoadError": function (error) {
|
|
||||||
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static windowContext() {
|
static windowContext() {
|
||||||
@ -194,34 +178,33 @@ class App {
|
|||||||
return window.app.setLocation(`/account`, { username })
|
return window.app.setLocation(`/account`, { username })
|
||||||
},
|
},
|
||||||
setStatusBarStyleDark: async () => {
|
setStatusBarStyleDark: async () => {
|
||||||
if (!this.isAppCapacitor()) {
|
if (!window.app.isAppCapacitor()) {
|
||||||
console.warn("[App] setStatusBarStyleDark is only available on capacitor")
|
console.warn("[App] setStatusBarStyleDark is only available on capacitor")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return await StatusBar.setStyle({ style: Style.Dark })
|
return await StatusBar.setStyle({ style: Style.Dark })
|
||||||
},
|
},
|
||||||
setStatusBarStyleLight: async () => {
|
setStatusBarStyleLight: async () => {
|
||||||
if (!this.isAppCapacitor()) {
|
if (!window.app.isAppCapacitor()) {
|
||||||
console.warn("[App] setStatusBarStyleLight is not supported on this platform")
|
console.warn("[App] setStatusBarStyleLight is not supported on this platform")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return await StatusBar.setStyle({ style: Style.Light })
|
return await StatusBar.setStyle({ style: Style.Light })
|
||||||
},
|
},
|
||||||
hideStatusBar: async () => {
|
hideStatusBar: async () => {
|
||||||
if (!this.isAppCapacitor()) {
|
if (!window.app.isAppCapacitor()) {
|
||||||
console.warn("[App] hideStatusBar is not supported on this platform")
|
console.warn("[App] hideStatusBar is not supported on this platform")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return await StatusBar.hide()
|
return await StatusBar.hide()
|
||||||
},
|
},
|
||||||
showStatusBar: async () => {
|
showStatusBar: async () => {
|
||||||
if (!this.isAppCapacitor()) {
|
if (!window.app.isAppCapacitor()) {
|
||||||
console.warn("[App] showStatusBar is not supported on this platform")
|
console.warn("[App] showStatusBar is not supported on this platform")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return await StatusBar.show()
|
return await StatusBar.show()
|
||||||
},
|
},
|
||||||
isAppCapacitor: this.isAppCapacitor,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +225,11 @@ class App {
|
|||||||
},
|
},
|
||||||
Crash: Crash,
|
Crash: Crash,
|
||||||
initialization: () => {
|
initialization: () => {
|
||||||
return <Splash.SplashComponent logo={config.logo.alt} />
|
return <div className="splash_wrapper">
|
||||||
|
<div className="splash_logo">
|
||||||
|
<img src={config.logo.alt} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +258,7 @@ class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount = async () => {
|
componentDidMount = async () => {
|
||||||
if (this.isAppCapacitor()) {
|
if (window.app.isAppCapacitor()) {
|
||||||
window.addEventListener("statusTap", () => {
|
window.addEventListener("statusTap", () => {
|
||||||
this.eventBus.emit("statusTap")
|
this.eventBus.emit("statusTap")
|
||||||
})
|
})
|
||||||
@ -313,7 +300,7 @@ class App {
|
|||||||
const initializationTasks = [
|
const initializationTasks = [
|
||||||
async () => {
|
async () => {
|
||||||
try {
|
try {
|
||||||
await this.contexts.app.attachAPIConnection()
|
await app.ApiController.attachAPIConnection()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw {
|
throw {
|
||||||
cause: "Cannot connect to API",
|
cause: "Cannot connect to API",
|
||||||
@ -380,10 +367,7 @@ class App {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = await Session.token
|
await app.ApiController.attachWSConnection()
|
||||||
await this.contexts.app.attachWSConnection()
|
|
||||||
|
|
||||||
this.mainSocket.emit("authenticate", token)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__UserInit = async () => {
|
__UserInit = async () => {
|
||||||
@ -406,6 +390,8 @@ class App {
|
|||||||
<BindPropsProvider
|
<BindPropsProvider
|
||||||
user={this.state.user}
|
user={this.state.user}
|
||||||
session={this.state.session}
|
session={this.state.session}
|
||||||
|
sessionController={this.sessionController}
|
||||||
|
userController={this.userController}
|
||||||
>
|
>
|
||||||
<Render.RouteRender staticRenders={App.staticRenders} />
|
<Render.RouteRender staticRenders={App.staticRenders} />
|
||||||
</BindPropsProvider>
|
</BindPropsProvider>
|
||||||
@ -416,17 +402,4 @@ class App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CreateEviteApp(App, {
|
export default CreateEviteApp(App)
|
||||||
extensions: [
|
|
||||||
Shortcuts,
|
|
||||||
SettingsController,
|
|
||||||
i18n.extension,
|
|
||||||
Sound.extension,
|
|
||||||
Notifications.extension,
|
|
||||||
API,
|
|
||||||
Render.extension,
|
|
||||||
Theme.extension,
|
|
||||||
SplashExtension,
|
|
||||||
Debug,
|
|
||||||
],
|
|
||||||
})
|
|
Loading…
x
Reference in New Issue
Block a user