mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-07-28 00:22:26 +02:00
added several dev improvements
This commit is contained in:
@@ -10,4 +10,5 @@ export const globalEvents = {
|
||||
showSettings: "showSettings",
|
||||
storeChanged: "storeChanged",
|
||||
error: "error",
|
||||
log: "log",
|
||||
};
|
||||
|
33
src/features/logger.ts
Normal file
33
src/features/logger.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { IpcMain, IpcRenderer } from "electron";
|
||||
import { globalEvents } from "../constants/globalEvents";
|
||||
|
||||
export class Logger {
|
||||
/**
|
||||
*
|
||||
* @param ipcRenderer renderer IPC client so we can send messages to the main thread
|
||||
*/
|
||||
constructor(private ipcRenderer: IpcRenderer) {}
|
||||
|
||||
/**
|
||||
* Subscribe to watch for logs from the IPC client
|
||||
* @param ipcMain main thread IPC client so we can subscribe to events
|
||||
*/
|
||||
public static watch(ipcMain: IpcMain) {
|
||||
ipcMain.on(globalEvents.log, (event, content, object) => {
|
||||
console.log(content, JSON.stringify(object, null, 2));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Log content to STDOut
|
||||
* @param content
|
||||
* @param object js(on) object that will be prettyPrinted
|
||||
*/
|
||||
public log(content: string, object: object = {}) {
|
||||
if (this.ipcRenderer) {
|
||||
this.ipcRenderer.send(globalEvents.log, { content, object });
|
||||
} else {
|
||||
console.log(`${content} \n ${JSON.stringify(object, null, 2)}`);
|
||||
}
|
||||
}
|
||||
}
|
@@ -26,6 +26,7 @@ import {
|
||||
import { settings } from "./constants/settings";
|
||||
import { addTray, refreshTray } from "./scripts/tray";
|
||||
import { MediaInfo } from "./models/mediaInfo";
|
||||
import { Logger } from "./features/logger";
|
||||
const tidalUrl = "https://listen.tidal.com";
|
||||
|
||||
initialize();
|
||||
@@ -220,3 +221,5 @@ ipcMain.on(globalEvents.storeChanged, () => {
|
||||
ipcMain.on(globalEvents.error, (event) => {
|
||||
console.log(event);
|
||||
});
|
||||
|
||||
Logger.watch(ipcMain);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import remote, { app } from "@electron/remote";
|
||||
import { app } from "@electron/remote";
|
||||
import { ipcRenderer, shell } from "electron";
|
||||
import fs from "fs";
|
||||
import { globalEvents } from "../../constants/globalEvents";
|
||||
@@ -107,8 +107,8 @@ function hide() {
|
||||
* Restart tidal-hifi after changes
|
||||
*/
|
||||
function restart() {
|
||||
remote.app.relaunch();
|
||||
remote.app.exit();
|
||||
app.relaunch();
|
||||
app.exit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user