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) {
console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`);
} 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) {
console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`);
} else {
plugins[file] = new plugin(electron.app, utils.getStore());
plugins[file] = new plugin(utils);
}
} else {
const plugin = require(path.join(this.userPluginsPath, file));
@ -69,7 +69,7 @@ export class Plugins {
if (plugins[file] || plugin in plugins) {
console.log(`[${plugin.name}] Plugin already loaded / Duplicate Class Name`);
} 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];
}
/**
* Get the app
* @returns {Electron.App}
*/
static getApp(): Electron.App {
return app;
}
/**
* Fetches the i18n locale for the given language.
* @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)
*/
constructor(app: any, store: any) {
this._app = app;
this._store = store
constructor(utils: { getApp: () => any; getStore: () => any; }) {
this._app = utils.getApp();
this._store = utils.getStore()
}
/**

View file

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

View file

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

View file

@ -7,6 +7,7 @@ export default class MPRIS {
*/
private _win: any;
private _app: any;
private static utils: any;
/**
* Base Plugin Details (Eventually implemented into a GUI in settings)
@ -37,10 +38,8 @@ export default class MPRIS {
* @param type - pausePlay, nextTrack, PreviousTrack
* @private
*/
private runMediaEvent(type: string) {
if (this._win) {
this._win.webContents.executeJavaScript(`MusicKitInterop.${type}()`).catch(console.error)
}
private static runMediaEvent(type: string) {
MPRIS.utils.getWindow().webContents.executeJavaScript(`MusicKitInterop.${type}()`).catch(console.error)
}
/**
@ -88,7 +87,7 @@ export default class MPRIS {
for (const [key, value] of Object.entries(this.mprisEvents)) {
this.mpris.on(key, () => {
this.runMediaEvent(value)
MPRIS.runMediaEvent(value)
});
}
}
@ -113,8 +112,7 @@ export default class MPRIS {
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)
*/
constructor(app: any, _store: any) {
this._app = app;
constructor(utils: { getApp: () => any; }) {
MPRIS.utils = utils
this._app = utils.getApp();
console.debug(`[Plugin][${this.name}] Loading Complete.`);
}

View file

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

View file

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