Who tf done this

This commit is contained in:
Core 2022-03-10 17:30:57 +00:00
parent ed8e977786
commit ba6f89362d
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
9 changed files with 44 additions and 37 deletions

View file

@ -44,7 +44,7 @@ export class Plugins {
if (plugins[file] || plugin.name in plugins) { if (plugins[file] || plugin.name in plugins) {
console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`); console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`);
} else { } else {
plugins[file] = new plugin(electron.app, utils.getStore()); plugins[file] = new plugin(utils);
} }
} }
}); });
@ -61,7 +61,7 @@ export class Plugins {
if (plugins[file] || plugin in plugins) { if (plugins[file] || plugin in plugins) {
console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`); console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`);
} else { } else {
plugins[file] = new plugin(electron.app, utils.getStore()); plugins[file] = new plugin(utils);
} }
} else { } else {
const plugin = require(path.join(this.userPluginsPath, file)); const plugin = require(path.join(this.userPluginsPath, file));
@ -69,7 +69,7 @@ export class Plugins {
if (plugins[file] || plugin in plugins) { if (plugins[file] || plugin in plugins) {
console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`); console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`);
} else { } else {
plugins[file] = new plugin(electron.app, utils.getStore()); plugins[file] = new plugin(utils);
} }
} }
} }

View file

@ -33,6 +33,14 @@ export class utils {
return this.paths[name]; return this.paths[name];
} }
/**
* Get the app
* @returns {Electron.App}
*/
static getApp(): Electron.App {
return app;
}
/** /**
* Fetches the i18n locale for the given language. * Fetches the i18n locale for the given language.
* @param language {string} The language to fetch the locale for. * @param language {string} The language to fetch the locale for.

View file

@ -289,10 +289,9 @@ export default class ChromecastPlugin {
/** /**
* Runs on plugin load (Currently run on application start) * Runs on plugin load (Currently run on application start)
*/ */
constructor(app: any, store: any) { constructor(utils: { getApp: () => any; getStore: () => any; }) {
this._app = app; this._app = utils.getApp();
this._store = store this._store = utils.getStore()
} }
/** /**

View file

@ -193,10 +193,10 @@ export default class DiscordRichPresence {
/** /**
* Runs on plugin load (Currently run on application start) * Runs on plugin load (Currently run on application start)
*/ */
constructor(app: any, store: any) { constructor(utils: { getStore: () => any; getApp: () => any; }) {
DiscordRichPresence._store = store DiscordRichPresence._store = utils.getStore();
console.debug(`[Plugin][${this.name}] Loading Complete.`); console.debug(`[Plugin][${this.name}] Loading Complete.`);
this._app = app; this._app = utils.getApp();
} }
/** /**

View file

@ -207,10 +207,10 @@ export default class LastFMPlugin {
/** /**
* Runs on plugin load (Currently run on application start) * Runs on plugin load (Currently run on application start)
*/ */
constructor(app: any, store: any) { constructor(utils: { getApp: () => any; getStore: () => any; }) {
this._app = app; this._app = utils.getApp();
this._store = store this._store = utils.getStore()
electron.app.on('second-instance', (_e: any, argv: any) => { utils.getApp().on('second-instance', (_e: any, argv: any) => {
// Checks if first instance is authorized and if second instance has protocol args // Checks if first instance is authorized and if second instance has protocol args
argv.forEach((value: any) => { argv.forEach((value: any) => {
if (value.includes('auth')) { if (value.includes('auth')) {

View file

@ -214,9 +214,9 @@ export default class Thumbar {
/** /**
* Runs on plugin load (Currently run on application start) * Runs on plugin load (Currently run on application start)
*/ */
constructor(app: any, store: any) { constructor(utils: { getApp: () => any; getStore: () => any; }) {
this._app = app; this._app = utils.getApp();
this._store = store this._store = utils.getStore();
console.debug(`[Plugin][${this.name}] Loading Complete.`); console.debug(`[Plugin][${this.name}] Loading Complete.`);
} }

View file

@ -7,6 +7,7 @@ export default class MPRIS {
*/ */
private _win: any; private _win: any;
private _app: any; private _app: any;
private static utils: any;
/** /**
* Base Plugin Details (Eventually implemented into a GUI in settings) * Base Plugin Details (Eventually implemented into a GUI in settings)
@ -37,10 +38,8 @@ export default class MPRIS {
* @param type - pausePlay, nextTrack, PreviousTrack * @param type - pausePlay, nextTrack, PreviousTrack
* @private * @private
*/ */
private runMediaEvent(type: string) { private static runMediaEvent(type: string) {
if (this._win) { MPRIS.utils.getWindow().webContents.executeJavaScript(`MusicKitInterop.${type}()`).catch(console.error)
this._win.webContents.executeJavaScript(`MusicKitInterop.${type}()`).catch(console.error)
}
} }
/** /**
@ -88,7 +87,7 @@ export default class MPRIS {
for (const [key, value] of Object.entries(this.mprisEvents)) { for (const [key, value] of Object.entries(this.mprisEvents)) {
this.mpris.on(key, () => { this.mpris.on(key, () => {
this.runMediaEvent(value) MPRIS.runMediaEvent(value)
}); });
} }
} }
@ -113,8 +112,7 @@ export default class MPRIS {
return return
} }
this.mpris.metadata = MetaData this.mpris.metadata = MetaData;
} }
/** /**
@ -155,8 +153,9 @@ export default class MPRIS {
/** /**
* Runs on plugin load (Currently run on application start) * Runs on plugin load (Currently run on application start)
*/ */
constructor(app: any, _store: any) { constructor(utils: { getApp: () => any; }) {
this._app = app; MPRIS.utils = utils
this._app = utils.getApp();
console.debug(`[Plugin][${this.name}] Loading Complete.`); console.debug(`[Plugin][${this.name}] Loading Complete.`);
} }
@ -176,7 +175,7 @@ export default class MPRIS {
console.debug(`[Plugin][${this.name}] Stopped.`); console.debug(`[Plugin][${this.name}] Stopped.`);
try { try {
this.clearState() this.clearState()
}catch(e) { } catch (e) {
console.error(e) console.error(e)
} }
} }

View file

@ -94,8 +94,8 @@ export default class Thumbar {
/** /**
* Runs on plugin load (Currently run on application start) * Runs on plugin load (Currently run on application start)
*/ */
constructor(app: any, _store: any) { constructor(utils: { getApp: () => any; }) {
this._app = app; this._app = utils.getApp();
console.debug(`[Plugin][${this.name}] Loading Complete.`); console.debug(`[Plugin][${this.name}] Loading Complete.`);
} }

View file

@ -136,17 +136,18 @@ const MusicKitInterop = {
}, },
next: () => { next: () => {
try { // try {
app.prevButtonBackIndicator = false; // app.prevButtonBackIndicator = false;
} catch (e) { } // } catch (e) { }
if (MusicKit.getInstance().queue.nextPlayableItemIndex != -1 && MusicKit.getInstance().queue.nextPlayableItemIndex != null) // if (MusicKit.getInstance().queue.nextPlayableItemIndex != -1 && MusicKit.getInstance().queue.nextPlayableItemIndex != null)
MusicKit.getInstance().changeToMediaAtIndex(MusicKit.getInstance().queue.nextPlayableItemIndex); // MusicKit.getInstance().changeToMediaAtIndex(MusicKit.getInstance().queue.nextPlayableItemIndex);
// MusicKit.getInstance().skipToNextItem().then(r => console.log(`[MusicKitInterop.next] Skipping to Next ${r}`)); MusicKit.getInstance().skipToNextItem().then(r => console.log(`[MusicKitInterop.next] Skipping to Next ${r}`));
}, },
previous: () => { previous: () => {
if (MusicKit.getInstance().queue.previousPlayableItemIndex != -1 && MusicKit.getInstance().queue.previousPlayableItemIndex != null) // if (MusicKit.getInstance().queue.previousPlayableItemIndex != -1 && MusicKit.getInstance().queue.previousPlayableItemIndex != null)
MusicKit.getInstance().changeToMediaAtIndex(MusicKit.getInstance().queue.previousPlayableItemIndex); // MusicKit.getInstance().changeToMediaAtIndex(MusicKit.getInstance().queue.previousPlayableItemIndex);
MusicKit.getInstance().skipToPreviousItem().then(r => console.log(`[MusicKitInterop.previous] Skipping to Previous ${r}`));
} }
} }