mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
use new evite methods
This commit is contained in:
parent
aa8e0864cc
commit
2057b3473d
@ -8,9 +8,11 @@ import useRequest from "comty.js/hooks/useRequest"
|
|||||||
import { reconnectWebsockets } from "comty.js"
|
import { reconnectWebsockets } from "comty.js"
|
||||||
|
|
||||||
export default class APICore extends Core {
|
export default class APICore extends Core {
|
||||||
static refName = "api"
|
|
||||||
static namespace = "api"
|
static namespace = "api"
|
||||||
|
|
||||||
|
static bgColor = "coral"
|
||||||
|
static textColor = "black"
|
||||||
|
|
||||||
instance = null
|
instance = null
|
||||||
|
|
||||||
public = {
|
public = {
|
||||||
@ -37,7 +39,7 @@ export default class APICore extends Core {
|
|||||||
|
|
||||||
createPingIntervals() {
|
createPingIntervals() {
|
||||||
Object.keys(this.instance.wsInstances).forEach((instance) => {
|
Object.keys(this.instance.wsInstances).forEach((instance) => {
|
||||||
console.debug(`[API] Creating ping interval for ${instance}`)
|
this.console.debug(`[API] Creating ping interval for ${instance}`)
|
||||||
|
|
||||||
if (this.instance.wsInstances[instance].pingInterval) {
|
if (this.instance.wsInstances[instance].pingInterval) {
|
||||||
clearInterval(this.instance.wsInstances[instance].pingInterval)
|
clearInterval(this.instance.wsInstances[instance].pingInterval)
|
||||||
@ -45,14 +47,14 @@ export default class APICore extends Core {
|
|||||||
|
|
||||||
this.instance.wsInstances[instance].pingInterval = setInterval(() => {
|
this.instance.wsInstances[instance].pingInterval = setInterval(() => {
|
||||||
if (this.instance.wsInstances[instance].pendingPingTry && this.instance.wsInstances[instance].pendingPingTry > 3) {
|
if (this.instance.wsInstances[instance].pendingPingTry && this.instance.wsInstances[instance].pendingPingTry > 3) {
|
||||||
console.debug(`[API] Ping timeout for ${instance}`)
|
this.console.debug(`[API] Ping timeout for ${instance}`)
|
||||||
|
|
||||||
return clearInterval(this.instance.wsInstances[instance].pingInterval)
|
return clearInterval(this.instance.wsInstances[instance].pingInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeStart = Date.now()
|
const timeStart = Date.now()
|
||||||
|
|
||||||
//console.debug(`[API] Ping ${instance}`, this.instance.wsInstances[instance].pendingPingTry)
|
//this.console.debug(`[API] Ping ${instance}`, this.instance.wsInstances[instance].pendingPingTry)
|
||||||
|
|
||||||
this.instance.wsInstances[instance].emit("ping", () => {
|
this.instance.wsInstances[instance].emit("ping", () => {
|
||||||
this.instance.wsInstances[instance].latency = Date.now() - timeStart
|
this.instance.wsInstances[instance].latency = Date.now() - timeStart
|
||||||
@ -92,7 +94,7 @@ export default class APICore extends Core {
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/ping",
|
url: "/ping",
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error("[API] Ping error", error)
|
this.console.error("[API] Ping error", error)
|
||||||
|
|
||||||
throw new Error(`
|
throw new Error(`
|
||||||
Could not connect to the API.
|
Could not connect to the API.
|
||||||
@ -100,7 +102,7 @@ export default class APICore extends Core {
|
|||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
|
|
||||||
console.debug("[API] Attached to", this.instance)
|
this.console.debug("[API] Attached to", this.instance)
|
||||||
|
|
||||||
this.createPingIntervals()
|
this.createPingIntervals()
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import ContextMenu from "./components/contextMenu"
|
|||||||
import InternalContexts from "schemas/menu-contexts"
|
import InternalContexts from "schemas/menu-contexts"
|
||||||
|
|
||||||
export default class ContextMenuCore extends Core {
|
export default class ContextMenuCore extends Core {
|
||||||
static refName = "contextMenu"
|
|
||||||
static namespace = "contextMenu"
|
static namespace = "contextMenu"
|
||||||
|
|
||||||
public = {
|
public = {
|
||||||
@ -26,7 +25,7 @@ export default class ContextMenuCore extends Core {
|
|||||||
|
|
||||||
async onInitialize() {
|
async onInitialize() {
|
||||||
if (app.isMobile) {
|
if (app.isMobile) {
|
||||||
console.warn("Context menu is not available on mobile")
|
this.console.warn("Context menu is not available on mobile")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +124,7 @@ export default class ContextMenuCore extends Core {
|
|||||||
const items = await this.generateItems(component)
|
const items = await this.generateItems(component)
|
||||||
|
|
||||||
if (!items) {
|
if (!items) {
|
||||||
console.warn("No context menu items found, aborting")
|
this.console.warn("No context menu items found, aborting")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ const vibrationPatterns = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class HapticsCore extends Core {
|
export default class HapticsCore extends Core {
|
||||||
static refName = "haptics"
|
|
||||||
static namespace = "haptics"
|
static namespace = "haptics"
|
||||||
|
|
||||||
static dependencies = [
|
static dependencies = [
|
||||||
"settings"
|
"settings"
|
||||||
]
|
]
|
||||||
|
@ -15,7 +15,7 @@ export function extractLocaleFromPath(path = "") {
|
|||||||
const messageImports = import.meta.glob("schemas/translations/*.json")
|
const messageImports = import.meta.glob("schemas/translations/*.json")
|
||||||
|
|
||||||
export default class I18nCore extends Core {
|
export default class I18nCore extends Core {
|
||||||
static refName = "i18n"
|
static namespace = "i18n"
|
||||||
|
|
||||||
onEvents = {
|
onEvents = {
|
||||||
"changeLanguage": (locale) => {
|
"changeLanguage": (locale) => {
|
||||||
@ -67,7 +67,7 @@ export default class I18nCore extends Core {
|
|||||||
i18n.changeLanguage(locale)
|
i18n.changeLanguage(locale)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
this.console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -77,8 +77,6 @@ function parseNdefMessage(ndefMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class NFC extends Core {
|
export default class NFC extends Core {
|
||||||
static refName = "NFC"
|
|
||||||
|
|
||||||
static namespace = "nfc"
|
static namespace = "nfc"
|
||||||
|
|
||||||
isNativeMode = false
|
isNativeMode = false
|
||||||
@ -141,7 +139,7 @@ export default class NFC extends Core {
|
|||||||
this.public.scanning = false
|
this.public.scanning = false
|
||||||
this.public.incompatible = true
|
this.public.incompatible = true
|
||||||
|
|
||||||
console.error(error)
|
this.console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +151,7 @@ export default class NFC extends Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleRead(tag) {
|
handleRead(tag) {
|
||||||
console.debug(`[NFC] READ >`, tag)
|
this.console.debug(`[NFC] READ >`, tag)
|
||||||
|
|
||||||
// send to subscribers
|
// send to subscribers
|
||||||
this.subscribers.forEach((subscriber) => {
|
this.subscribers.forEach((subscriber) => {
|
||||||
@ -173,7 +171,7 @@ export default class NFC extends Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleNativeRead(tag) {
|
handleNativeRead(tag) {
|
||||||
console.debug(`[NFC] NATIVE READ >`, tag)
|
this.console.debug(`[NFC] NATIVE READ >`, tag)
|
||||||
|
|
||||||
tag.serialNumber = resolveSerialNumber(tag)
|
tag.serialNumber = resolveSerialNumber(tag)
|
||||||
|
|
||||||
@ -230,7 +228,7 @@ export default class NFC extends Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async writeNdef(payload, options) {
|
async writeNdef(payload, options) {
|
||||||
console.debug(`[NFC] WRITE >`, payload)
|
this.console.debug(`[NFC] WRITE >`, payload)
|
||||||
|
|
||||||
if (!this.isNativeMode) {
|
if (!this.isNativeMode) {
|
||||||
return this.instance.write(payload, options)
|
return this.instance.write(payload, options)
|
||||||
|
@ -13,7 +13,7 @@ const NotfTypeToAudio = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class NotificationCore extends Core {
|
export default class NotificationCore extends Core {
|
||||||
static refName = "notifications"
|
static namespace = "notifications"
|
||||||
|
|
||||||
onEvents = {
|
onEvents = {
|
||||||
"changeNotificationsSoundVolume": (value) => {
|
"changeNotificationsSoundVolume": (value) => {
|
||||||
|
@ -4,8 +4,8 @@ import UserModel from "models/user"
|
|||||||
import SessionModel from "models/session"
|
import SessionModel from "models/session"
|
||||||
|
|
||||||
export default class PermissionsCore extends Core {
|
export default class PermissionsCore extends Core {
|
||||||
static refName = "permissions"
|
|
||||||
static namespace = "permissions"
|
static namespace = "permissions"
|
||||||
|
|
||||||
static dependencies = ["api"]
|
static dependencies = ["api"]
|
||||||
|
|
||||||
public = {
|
public = {
|
||||||
|
@ -151,7 +151,7 @@ class ChunkedUpload {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (this.paused || this.offline) return
|
if (this.paused || this.offline) return
|
||||||
|
|
||||||
console.error(err)
|
this.console.error(err)
|
||||||
|
|
||||||
// this type of error can happen after network disconnection on CORS setup
|
// this type of error can happen after network disconnection on CORS setup
|
||||||
this.manageRetries()
|
this.manageRetries()
|
||||||
@ -208,7 +208,7 @@ export default class RemoteStorage extends Core {
|
|||||||
})
|
})
|
||||||
|
|
||||||
uploader.on("error", ({ message }) => {
|
uploader.on("error", ({ message }) => {
|
||||||
console.error("[Uploader] Error", message)
|
this.console.error("[Uploader] Error", message)
|
||||||
|
|
||||||
if (typeof onError === "function") {
|
if (typeof onError === "function") {
|
||||||
onError(file, message)
|
onError(file, message)
|
||||||
@ -219,7 +219,7 @@ export default class RemoteStorage extends Core {
|
|||||||
})
|
})
|
||||||
|
|
||||||
uploader.on("progress", ({ percentProgress }) => {
|
uploader.on("progress", ({ percentProgress }) => {
|
||||||
//console.debug(`[Uploader] Progress: ${percentProgress}%`)
|
//this.console.debug(`[Uploader] Progress: ${percentProgress}%`)
|
||||||
|
|
||||||
if (typeof onProgress === "function") {
|
if (typeof onProgress === "function") {
|
||||||
onProgress(file, percentProgress)
|
onProgress(file, percentProgress)
|
||||||
@ -227,7 +227,7 @@ export default class RemoteStorage extends Core {
|
|||||||
})
|
})
|
||||||
|
|
||||||
uploader.on("finish", (data) => {
|
uploader.on("finish", (data) => {
|
||||||
console.debug("[Uploader] Finish", data)
|
this.console.debug("[Uploader] Finish", data)
|
||||||
|
|
||||||
if (typeof onFinish === "function") {
|
if (typeof onFinish === "function") {
|
||||||
onFinish(file, data)
|
onFinish(file, data)
|
||||||
|
@ -4,7 +4,6 @@ import remotes from "comty.js/remotes"
|
|||||||
import SessionModel from "comty.js/models/session"
|
import SessionModel from "comty.js/models/session"
|
||||||
|
|
||||||
export default class RoomsController extends Core {
|
export default class RoomsController extends Core {
|
||||||
static refName = "rooms"
|
|
||||||
static namespace = "rooms"
|
static namespace = "rooms"
|
||||||
|
|
||||||
connectedRooms = []
|
connectedRooms = []
|
||||||
|
@ -4,8 +4,6 @@ import defaultSettings from "schemas/defaultSettings.json"
|
|||||||
import { Observable } from "rxjs"
|
import { Observable } from "rxjs"
|
||||||
|
|
||||||
export default class SettingsCore extends Core {
|
export default class SettingsCore extends Core {
|
||||||
static refName = "settings"
|
|
||||||
|
|
||||||
static namespace = "settings"
|
static namespace = "settings"
|
||||||
|
|
||||||
static storeKey = "app_settings"
|
static storeKey = "app_settings"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import Core from "evite/src/core"
|
import Core from "evite/src/core"
|
||||||
|
|
||||||
export default class ShortcutsCore extends Core {
|
export default class ShortcutsCore extends Core {
|
||||||
static refName = "shortcuts"
|
|
||||||
static namespace = "shortcuts"
|
static namespace = "shortcuts"
|
||||||
|
|
||||||
public = {
|
public = {
|
||||||
@ -81,7 +80,7 @@ export default class ShortcutsCore extends Core {
|
|||||||
const register = this.shortcutsRegister.find((handler) => handler.id === id)
|
const register = this.shortcutsRegister.find((handler) => handler.id === id)
|
||||||
|
|
||||||
if (!register) {
|
if (!register) {
|
||||||
console.warn(`Shortcut with id "${id}" not found`)
|
this.console.warn(`Shortcut with id "${id}" not found`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ import axios from "axios"
|
|||||||
import store from "store"
|
import store from "store"
|
||||||
|
|
||||||
export default class SoundCore extends Core {
|
export default class SoundCore extends Core {
|
||||||
static refName = "sound"
|
|
||||||
|
|
||||||
static namespace = "sound"
|
static namespace = "sound"
|
||||||
|
|
||||||
soundsPool = {}
|
soundsPool = {}
|
||||||
@ -20,7 +18,7 @@ export default class SoundCore extends Core {
|
|||||||
this.play(audio_id)
|
this.play(audio_id)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
this.console.error(error)
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
}
|
}
|
||||||
@ -49,17 +47,17 @@ export default class SoundCore extends Core {
|
|||||||
|
|
||||||
soundpack = data
|
soundpack = data
|
||||||
} else {
|
} else {
|
||||||
console.error(`Soundpack [${storedCustomSoundpack}] is not a valid url.`)
|
this.console.error(`Soundpack [${storedCustomSoundpack}] is not a valid url.`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof soundpack.sounds !== "object") {
|
if (typeof soundpack.sounds !== "object") {
|
||||||
console.error(`Soundpack [${soundpack.id}] is not a valid soundpack.`)
|
this.console.error(`Soundpack [${soundpack.id}] is not a valid soundpack.`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Loading soundpack [${soundpack.id} | ${soundpack.name}] by ${soundpack.author} (${soundpack.version})`)
|
this.console.log(`Loading soundpack [${soundpack.id} | ${soundpack.name}] by ${soundpack.author} (${soundpack.version})`)
|
||||||
|
|
||||||
for (const [name, path] of Object.entries(soundpack.sounds)) {
|
for (const [name, path] of Object.entries(soundpack.sounds)) {
|
||||||
this.soundsPool[name] = new Howl({
|
this.soundsPool[name] = new Howl({
|
||||||
@ -93,7 +91,7 @@ export default class SoundCore extends Core {
|
|||||||
const audioInstance = this.soundsPool[name]
|
const audioInstance = this.soundsPool[name]
|
||||||
|
|
||||||
if (!audioInstance) {
|
if (!audioInstance) {
|
||||||
console.error(`Sound [${name}] not found or is not available.`)
|
this.console.error(`Sound [${name}] not found or is not available.`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import ReactDOM from "react-dom"
|
|
||||||
import SVG from "react-inlinesvg"
|
|
||||||
|
|
||||||
import Core from "evite/src/core"
|
import Core from "evite/src/core"
|
||||||
import config from "config"
|
import config from "config"
|
||||||
@ -66,11 +64,10 @@ export class ThemeProvider extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class StyleCore extends Core {
|
export default class StyleCore extends Core {
|
||||||
static refName = "style"
|
|
||||||
static dependencies = ["settings"]
|
|
||||||
|
|
||||||
static namespace = "style"
|
static namespace = "style"
|
||||||
|
|
||||||
|
static dependencies = ["settings"]
|
||||||
|
|
||||||
static themeManifestStorageKey = "theme"
|
static themeManifestStorageKey = "theme"
|
||||||
static modificationStorageKey = "themeModifications"
|
static modificationStorageKey = "themeModifications"
|
||||||
|
|
||||||
@ -140,7 +137,7 @@ export default class StyleCore extends Core {
|
|||||||
|
|
||||||
// handle auto prefered color scheme
|
// handle auto prefered color scheme
|
||||||
window.matchMedia("(prefers-color-scheme: light)").addListener(() => {
|
window.matchMedia("(prefers-color-scheme: light)").addListener(() => {
|
||||||
console.log(`[THEME] Auto color scheme changed`)
|
this.console.log(`[THEME] Auto color scheme changed`)
|
||||||
|
|
||||||
this.applyVariant(StyleCore.variant)
|
this.applyVariant(StyleCore.variant)
|
||||||
})
|
})
|
||||||
@ -250,7 +247,7 @@ export default class StyleCore extends Core {
|
|||||||
const values = this.public.theme.variants[variant]
|
const values = this.public.theme.variants[variant]
|
||||||
|
|
||||||
if (!values) {
|
if (!values) {
|
||||||
console.error(`Variant [${variant}] not found`)
|
this.console.error(`Variant [${variant}] not found`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import SyncRoomCard from "components/SyncRoomCard"
|
|||||||
import Image from "components/Image"
|
import Image from "components/Image"
|
||||||
import { openModal as OpenUserSelectorModal } from "components/UserSelector"
|
import { openModal as OpenUserSelectorModal } from "components/UserSelector"
|
||||||
|
|
||||||
|
import SyncModel from "comty.js/models/sync"
|
||||||
|
|
||||||
// TODO: Sync current state with server
|
// TODO: Sync current state with server
|
||||||
class MusicSyncSubCore {
|
class MusicSyncSubCore {
|
||||||
constructor(ctx) {
|
constructor(ctx) {
|
||||||
@ -40,7 +42,7 @@ class MusicSyncSubCore {
|
|||||||
|
|
||||||
hubEvents = {
|
hubEvents = {
|
||||||
"invite:received": (data) => {
|
"invite:received": (data) => {
|
||||||
console.log("invite:received", data)
|
this.console.log("invite:received", data)
|
||||||
|
|
||||||
app.notification.new({
|
app.notification.new({
|
||||||
title: "Sync",
|
title: "Sync",
|
||||||
@ -60,7 +62,7 @@ class MusicSyncSubCore {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
"room:joined": (data) => {
|
"room:joined": (data) => {
|
||||||
console.log("room:joined", data)
|
this.console.log("room:joined", data)
|
||||||
|
|
||||||
this.currentRoomData = data
|
this.currentRoomData = data
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ class MusicSyncSubCore {
|
|||||||
this.eventBus.emit("room:joined", data)
|
this.eventBus.emit("room:joined", data)
|
||||||
},
|
},
|
||||||
"room:left": (data) => {
|
"room:left": (data) => {
|
||||||
console.log("room:left", data)
|
this.console.log("room:left", data)
|
||||||
|
|
||||||
this.dettachCard()
|
this.dettachCard()
|
||||||
|
|
||||||
@ -106,7 +108,7 @@ class MusicSyncSubCore {
|
|||||||
this.eventBus.emit("room:user:left", data)
|
this.eventBus.emit("room:user:left", data)
|
||||||
},
|
},
|
||||||
"room:current-data": (data) => {
|
"room:current-data": (data) => {
|
||||||
console.log("room:current-data", data)
|
this.console.log("room:current-data", data)
|
||||||
this.currentRoomData = data
|
this.currentRoomData = data
|
||||||
|
|
||||||
this.eventBus.emit("room:current-data", data)
|
this.eventBus.emit("room:current-data", data)
|
||||||
@ -167,7 +169,7 @@ class MusicSyncSubCore {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"room:moderation:kicked": (data) => {
|
"room:moderation:kicked": (data) => {
|
||||||
console.log("room:moderation:kicked", data)
|
this.console.log("room:moderation:kicked", data)
|
||||||
|
|
||||||
this.dettachCard()
|
this.dettachCard()
|
||||||
|
|
||||||
@ -208,7 +210,7 @@ class MusicSyncSubCore {
|
|||||||
|
|
||||||
let state = app.cores.player.currentState()
|
let state = app.cores.player.currentState()
|
||||||
|
|
||||||
console.log("state", state)
|
this.console.log("state", state)
|
||||||
|
|
||||||
this.musicWs.emit("music:state:update", {
|
this.musicWs.emit("music:state:update", {
|
||||||
...state,
|
...state,
|
||||||
@ -235,7 +237,7 @@ class MusicSyncSubCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!app.layout.floatingStack) {
|
if (!app.layout.floatingStack) {
|
||||||
console.error("Floating stack not found")
|
this.console.error("Floating stack not found")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +250,7 @@ class MusicSyncSubCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!app.layout.floatingStack) {
|
if (!app.layout.floatingStack) {
|
||||||
console.error("Floating stack not found")
|
this.console.error("Floating stack not found")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +261,7 @@ class MusicSyncSubCore {
|
|||||||
|
|
||||||
joinRoom(roomId, options) {
|
joinRoom(roomId, options) {
|
||||||
if (this.currentRoomData) {
|
if (this.currentRoomData) {
|
||||||
console.warn(`Already joined room ${this.currentRoomData}`)
|
this.console.warn(`Already joined room ${this.currentRoomData}`)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -280,7 +282,7 @@ class MusicSyncSubCore {
|
|||||||
this.dettachCard()
|
this.dettachCard()
|
||||||
|
|
||||||
if (!roomId && !this.currentRoomData) {
|
if (!roomId && !this.currentRoomData) {
|
||||||
console.warn(`Not joined any room`)
|
this.console.warn(`Not joined any room`)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -307,7 +309,7 @@ class MusicSyncSubCore {
|
|||||||
|
|
||||||
inviteToUser(userId) {
|
inviteToUser(userId) {
|
||||||
if (!this.currentRoomData) {
|
if (!this.currentRoomData) {
|
||||||
console.warn(`Not joined any room`)
|
this.console.warn(`Not joined any room`)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -320,7 +322,7 @@ class MusicSyncSubCore {
|
|||||||
|
|
||||||
createSyncRoom() {
|
createSyncRoom() {
|
||||||
if (this.currentRoomData) {
|
if (this.currentRoomData) {
|
||||||
console.warn(`Already joined room ${this.currentRoomData}`)
|
this.console.warn(`Already joined room ${this.currentRoomData}`)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -336,14 +338,14 @@ class MusicSyncSubCore {
|
|||||||
//open invite modal
|
//open invite modal
|
||||||
OpenUserSelectorModal({
|
OpenUserSelectorModal({
|
||||||
onFinished: (selected_ids) => {
|
onFinished: (selected_ids) => {
|
||||||
console.log("selected_ids", selected_ids)
|
this.console.log("selected_ids", selected_ids)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
kickUser(userId) {
|
kickUser(userId) {
|
||||||
if (!this.currentRoomData) {
|
if (!this.currentRoomData) {
|
||||||
console.warn(`Not joined any room`)
|
this.console.warn(`Not joined any room`)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -356,7 +358,7 @@ class MusicSyncSubCore {
|
|||||||
|
|
||||||
transferOwner(userId) {
|
transferOwner(userId) {
|
||||||
if (!this.currentRoomData) {
|
if (!this.currentRoomData) {
|
||||||
console.warn(`Not joined any room`)
|
this.console.warn(`Not joined any room`)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -369,11 +371,16 @@ class MusicSyncSubCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class SyncCore extends Core {
|
export default class SyncCore extends Core {
|
||||||
static refName = "sync"
|
|
||||||
static namespace = "sync"
|
static namespace = "sync"
|
||||||
static dependencies = ["api", "player"]
|
static dependencies = ["api", "player"]
|
||||||
|
|
||||||
public = {}
|
activeLinkedServices = {}
|
||||||
|
|
||||||
|
public = {
|
||||||
|
getActiveLinkedServices: function () {
|
||||||
|
return this.activeLinkedServices
|
||||||
|
}.bind(this),
|
||||||
|
}
|
||||||
|
|
||||||
async onInitialize() {
|
async onInitialize() {
|
||||||
const subCores = [
|
const subCores = [
|
||||||
@ -390,8 +397,20 @@ export default class SyncCore extends Core {
|
|||||||
this.public[subCore.constructor.namespace] = subCore.public
|
this.public[subCore.constructor.namespace] = subCore.public
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
this.console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async initializeAfterCoresInit() {
|
||||||
|
const activeServices = await SyncModel.getLinkedServices().catch((error) => {
|
||||||
|
this.console.error(error)
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
|
||||||
|
if (activeServices) {
|
||||||
|
this.console.log(`Active services`, activeServices)
|
||||||
|
this.activeLinkedServices = activeServices
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,13 +21,13 @@ export default class TasksQueue extends Core {
|
|||||||
|
|
||||||
processTasks() {
|
processTasks() {
|
||||||
if (this.runningTasksIds.length >= TasksQueue.maxRunningTasks ?? 1) {
|
if (this.runningTasksIds.length >= TasksQueue.maxRunningTasks ?? 1) {
|
||||||
console.log("We are already running the maximum number of tasks")
|
this.console.log("We are already running the maximum number of tasks")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if there are new tasks in the queue and move them to the tasks array with the maximum number of tasks can be run
|
// check if there are new tasks in the queue and move them to the tasks array with the maximum number of tasks can be run
|
||||||
if (this.taskQueue.length === 0) {
|
if (this.taskQueue.length === 0) {
|
||||||
console.log("No tasks in the queue")
|
this.console.log("No tasks in the queue")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ export default class TasksQueue extends Core {
|
|||||||
this.processTasks()
|
this.processTasks()
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error)
|
this.console.error(error)
|
||||||
this.processTasks()
|
this.processTasks()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ export default class WidgetsCore extends Core {
|
|||||||
store.set(WidgetsCore.storeKey, [])
|
store.set(WidgetsCore.storeKey, [])
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
this.console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ export default class WidgetsCore extends Core {
|
|||||||
isInstalled(widget_id) {
|
isInstalled(widget_id) {
|
||||||
const widgets = this.getInstalled()
|
const widgets = this.getInstalled()
|
||||||
|
|
||||||
console.log(widgets)
|
this.console.log(widgets)
|
||||||
|
|
||||||
const widget = widgets.find((widget) => widget._id === widget_id)
|
const widget = widgets.find((widget) => widget._id === widget_id)
|
||||||
|
|
||||||
@ -52,14 +52,14 @@ export default class WidgetsCore extends Core {
|
|||||||
throw new Error("Widget id must be a string.")
|
throw new Error("Widget id must be a string.")
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug(`🧩 Installing widget with id [${widget_id}]`)
|
this.console.debug(`🧩 Installing widget with id [${widget_id}]`)
|
||||||
|
|
||||||
// get manifest
|
// get manifest
|
||||||
let manifest = await WidgetsCore.apiInstance({
|
let manifest = await WidgetsCore.apiInstance({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `/widgets/${widget_id}/manifest`,
|
url: `/widgets/${widget_id}/manifest`,
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error(error)
|
this.console.error(error)
|
||||||
app.message.error("Cannot install widget.")
|
app.message.error("Cannot install widget.")
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@ -125,7 +125,7 @@ export default class WidgetsCore extends Core {
|
|||||||
throw new Error("Widget id must be a string.")
|
throw new Error("Widget id must be a string.")
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug(`🧩 Uninstalling widget with id [${widget_id}]`)
|
this.console.debug(`🧩 Uninstalling widget with id [${widget_id}]`)
|
||||||
|
|
||||||
// check if already installed
|
// check if already installed
|
||||||
if (!this.isInstalled(widget_id)) {
|
if (!this.isInstalled(widget_id)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user