fix win context on plugins, change titlebar plugin to use object call instead of ipc

This commit is contained in:
vapormusic 2022-01-19 09:53:24 +07:00
parent a51dc79a94
commit eb6d61ea5a
4 changed files with 11 additions and 15 deletions

View file

@ -42,7 +42,7 @@ export default class PluginHandler {
} }
}); });
} }
console.log('loaded plugins:', JSON.stringify(plugins))
return plugins; return plugins;
} }

View file

@ -393,15 +393,6 @@ export class Win {
this.win.webContents.setZoomFactor(parseFloat(scale)); this.win.webContents.setZoomFactor(parseFloat(scale));
}); });
// Titlebar #147 - Implemented as plugin
electron.ipcMain.on('set-titlebar', (e, titlebar) => {
this.win.title = `${titlebar} - Cider`
})
electron.ipcMain.on('reset-titlebar', () => {
this.win.title = `Cider`
})
/* ********************************************************************************************* /* *********************************************************************************************
* Window Events * Window Events
* **********************************************************************************************/ * **********************************************************************************************/

View file

@ -11,7 +11,6 @@ import {AppEvents} from "./base/app";
import PluginHandler from "./base/plugins"; import PluginHandler from "./base/plugins";
// const test = new PluginHandler(); // const test = new PluginHandler();
let win: Promise<void> | null = null;
const config = new ConfigStore(); const config = new ConfigStore();
const App = new AppEvents(config.store); const App = new AppEvents(config.store);
const Cider = new Win(electron.app, config.store) const Cider = new Win(electron.app, config.store)
@ -31,8 +30,10 @@ electron.app.on('ready', () => {
} }
electron.components.whenReady().then(() => { electron.components.whenReady().then(() => {
win = Cider.createWindow(); Cider.createWindow().then((win) => {
plug.callPlugins('onReady', win); plug.callPlugins('onReady', win);
})
}) })

View file

@ -11,11 +11,15 @@ export default class sendSongToTitlebar {
/** /**
* Runs on plugin load (Currently run on application start) * Runs on plugin load (Currently run on application start)
*/ */
private _win: any;
private _app: any;
constructor() {} constructor() {}
/** /**
* Runs on app ready * Runs on app ready
*/ */
onReady(): void {} onReady(win: any): void {
this._win = win;
}
/** /**
* Runs on app stop * Runs on app stop
*/ */
@ -25,7 +29,7 @@ export default class sendSongToTitlebar {
* @param attributes Music Attributes (attributes.state = current state) * @param attributes Music Attributes (attributes.state = current state)
*/ */
onPlaybackStateDidChange(attributes: any): void { onPlaybackStateDidChange(attributes: any): void {
electron.ipcRenderer.send('set-titlebar', attributes.name) this._win.setTitle(`${(attributes != null && attributes.name != null && attributes.name.length > 0) ? (attributes.name + " - ") : ''}Cider`)
} }
/** /**
* Runs on song change * Runs on song change