mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
fix cores inits
This commit is contained in:
parent
4cea075ec3
commit
b25249290f
@ -487,7 +487,7 @@ class ComtyApp extends React.Component {
|
||||
const userAgentPlatform = window.navigator.userAgent.toLowerCase()
|
||||
const isMac = userAgentPlatform.indexOf("mac") !== -1
|
||||
|
||||
this.props.cores.ShortcutsCore.register({
|
||||
this.props.cores.shortcuts.register({
|
||||
id: "app.openSearcher",
|
||||
key: ",",
|
||||
meta: isMac,
|
||||
@ -518,7 +518,7 @@ class ComtyApp extends React.Component {
|
||||
const initializationTasks = [
|
||||
async () => {
|
||||
try {
|
||||
await this.props.cores.ApiCore.attach()
|
||||
await this.props.cores.api.attach()
|
||||
|
||||
app.eventBus.emit("app.initialization.api_success")
|
||||
} catch (error) {
|
||||
|
@ -52,14 +52,14 @@ export default class PostsLists extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount = async () => {
|
||||
window.app.shortcuts.register({
|
||||
window.app.cores.shortcuts.register({
|
||||
id: "postsFeed.scrollUp",
|
||||
key: "ArrowUp",
|
||||
preventDefault: true,
|
||||
}, (event) => {
|
||||
this.scrollUp()
|
||||
})
|
||||
window.app.shortcuts.register({
|
||||
window.app.cores.shortcuts.register({
|
||||
id: "postsFeed.scrollDown",
|
||||
key: "ArrowDown",
|
||||
preventDefault: true,
|
||||
|
@ -48,6 +48,7 @@ function generateWSFunctionHandler(socket, type = "listen") {
|
||||
}
|
||||
|
||||
export default class ApiCore extends Core {
|
||||
static refName = "api"
|
||||
static namespace = "api"
|
||||
static depends = ["settings"]
|
||||
|
||||
|
@ -7,8 +7,14 @@ import ContextMenu from "./components/contextMenu"
|
||||
import InternalContexts from "schemas/menu-contexts"
|
||||
|
||||
export default class ContextMenuCore extends Core {
|
||||
static namespace = "ContextMenu"
|
||||
static public = ["show", "hide", "registerContext"]
|
||||
static refName = "contextMenu"
|
||||
static namespace = "contextMenu"
|
||||
|
||||
public = {
|
||||
show: this.show.bind(this),
|
||||
hide: this.hide.bind(this),
|
||||
registerContext: this.registerContext.bind(this),
|
||||
}
|
||||
|
||||
contexts = Object()
|
||||
|
||||
@ -19,14 +25,14 @@ export default class ContextMenuCore extends Core {
|
||||
})
|
||||
|
||||
async onInitialize() {
|
||||
document.addEventListener("contextmenu", this.handleEvent)
|
||||
document.addEventListener("contextmenu", this.handleEvent.bind(this))
|
||||
}
|
||||
|
||||
registerContext = (element, context) => {
|
||||
registerContext(element, context) {
|
||||
this.contexts[element] = context
|
||||
}
|
||||
|
||||
generateItems = async (element) => {
|
||||
async generateItems(element) {
|
||||
let items = []
|
||||
|
||||
// find the closest context with attribute (context-menu)
|
||||
@ -96,7 +102,7 @@ export default class ContextMenuCore extends Core {
|
||||
return items
|
||||
}
|
||||
|
||||
handleEvent = async (event) => {
|
||||
async handleEvent(event) {
|
||||
event.preventDefault()
|
||||
|
||||
// get the cords of the mouse
|
||||
@ -131,11 +137,11 @@ export default class ContextMenuCore extends Core {
|
||||
})
|
||||
}
|
||||
|
||||
show = (payload) => {
|
||||
show(payload) {
|
||||
this.DOMWindow.render(React.createElement(ContextMenu, payload))
|
||||
}
|
||||
|
||||
hide = () => {
|
||||
hide() {
|
||||
this.DOMWindow.remove()
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@ export function extractLocaleFromPath(path = "") {
|
||||
const messageImports = import.meta.glob("schemas/translations/*.json")
|
||||
|
||||
export default class I18nCore extends Core {
|
||||
static refName = "i18n"
|
||||
|
||||
onEvents = {
|
||||
"changeLanguage": (locale) => {
|
||||
this.loadAsyncLanguage(locale)
|
||||
|
@ -6,6 +6,8 @@ import { Translation } from "react-i18next"
|
||||
import { Haptics } from "@capacitor/haptics"
|
||||
|
||||
export default class NotificationCore extends Core {
|
||||
static refName = "notifications"
|
||||
|
||||
onEvents = {
|
||||
"changeNotificationsSoundVolume": (value) => {
|
||||
this.playAudio({ soundVolume: value })
|
||||
|
@ -4,6 +4,7 @@ import UserModel from "models/user"
|
||||
import SessionModel from "models/session"
|
||||
|
||||
export default class PermissionsCore extends Core {
|
||||
static refName = "permissions"
|
||||
static namespace = "permissions"
|
||||
static dependencies = ["api"]
|
||||
|
||||
|
@ -31,6 +31,8 @@ class AudioPlayerStorage {
|
||||
}
|
||||
|
||||
export default class Player extends Core {
|
||||
static refName = "player"
|
||||
|
||||
static namespace = "player"
|
||||
|
||||
currentDomWindow = null
|
||||
|
@ -4,6 +4,8 @@ import defaultSettings from "schemas/defaultSettings.json"
|
||||
import { Observable } from "rxjs"
|
||||
|
||||
export default class SettingsCore extends Core {
|
||||
static refName = "settings"
|
||||
|
||||
static namespace = "settings"
|
||||
|
||||
static storeKey = "app_settings"
|
||||
|
@ -1,13 +1,16 @@
|
||||
import Core from "evite/src/core"
|
||||
|
||||
export default class ShortcutsCore extends Core {
|
||||
shortcutsRegister = []
|
||||
static refName = "shortcuts"
|
||||
static namespace = "shortcuts"
|
||||
|
||||
registerToApp = {
|
||||
shortcuts: this
|
||||
public = {
|
||||
register: this.register.bind(this),
|
||||
}
|
||||
|
||||
handleEvent = (event, shortcut, fn) => {
|
||||
shortcutsRegister = []
|
||||
|
||||
handleEvent(event, shortcut, fn) {
|
||||
if (typeof shortcut !== "object") {
|
||||
throw new Error("Shortcut must be an object")
|
||||
}
|
||||
@ -42,7 +45,7 @@ export default class ShortcutsCore extends Core {
|
||||
}
|
||||
}
|
||||
|
||||
register = (shortcut, fn) => {
|
||||
register(shortcut, fn) {
|
||||
if (!shortcut) {
|
||||
throw new Error("`shortcut` is required")
|
||||
}
|
||||
@ -65,7 +68,7 @@ export default class ShortcutsCore extends Core {
|
||||
return document.addEventListener("keydown", handler)
|
||||
}
|
||||
|
||||
remove = (id) => {
|
||||
remove(id) {
|
||||
if (!id) {
|
||||
throw new Error("`id` is required")
|
||||
}
|
||||
@ -88,8 +91,4 @@ export default class ShortcutsCore extends Core {
|
||||
// remove the event handler from the list
|
||||
this.shortcutsRegister = this.shortcutsRegister.filter((handler) => handler.id !== id)
|
||||
}
|
||||
|
||||
window = {
|
||||
ShortcutsController: this
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ import { Howl } from "howler"
|
||||
import config from "config"
|
||||
|
||||
export default class SoundCore extends Core {
|
||||
static refName = "sound"
|
||||
|
||||
static namespace = "sound"
|
||||
|
||||
public = {
|
||||
|
@ -64,6 +64,8 @@ export class ThemeProvider extends React.Component {
|
||||
}
|
||||
|
||||
export default class StyleCore extends Core {
|
||||
static refName = "style"
|
||||
|
||||
static namespace = "style"
|
||||
|
||||
static themeManifestStorageKey = "theme"
|
||||
|
Loading…
x
Reference in New Issue
Block a user