Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
fix: fix #30
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBrick committed Oct 4, 2023
1 parent 371a7eb commit 92a3a55
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
8 changes: 2 additions & 6 deletions plugins/notifications/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import getSongControls from '../../providers/song-controls';
import registerCallback, { SongInfo } from '../../providers/song-info';
import { changeProtocolHandler } from '../../providers/protocol-handler';
import { setTrayOnClick, setTrayOnDoubleClick } from '../../tray';
import { getMediaIconLocation } from '../utils';

let songControls: ReturnType<typeof getSongControls>;
let savedNotification: Notification | undefined;
Expand Down Expand Up @@ -151,19 +152,14 @@ const getXml = (songInfo: SongInfo, iconSrc: string) => {
}
}
};

const iconLocation = app.isPackaged
? path.resolve(app.getPath('userData'), 'icons')
: path.resolve(__dirname, 'assets', 'media-icons-black');

const display = (kind: keyof typeof icons) => {
if (config.get('toastStyle') === ToastStyles.legacy) {
return `content="${icons[kind]}"`;
}

return `\
content="${config.get('hideButtonText') ? '' : kind.charAt(0).toUpperCase() + kind.slice(1)}"\
imageUri="file:///${path.resolve(__dirname, iconLocation, `${kind}.png`)}"
imageUri="file:///${path.resolve(getMediaIconLocation(), `${kind}.png`)}"
`;
};

Expand Down
6 changes: 3 additions & 3 deletions plugins/notifications/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import config from './config';

import { cache } from '../../providers/decorators';
import { SongInfo } from '../../providers/song-info';
import { getMediaIconLocation } from '../utils';

const icon = 'assets/youtube-music.png';
const userData = app.getPath('userData');
Expand Down Expand Up @@ -88,10 +89,9 @@ export const saveTempIcon = () => {
continue;
}

const iconPath = path.resolve(__dirname, 'assets', 'media-icons-black', `${kind}.png`);
const iconPath = path.resolve(getMediaIconLocation(), `${kind}.png`);
fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
fs.copyFile(iconPath, destinationPath, () => {
});
fs.copyFile(iconPath, destinationPath, () => {});
}
};

Expand Down
3 changes: 2 additions & 1 deletion plugins/taskbar-mediacontrol/back.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BrowserWindow, nativeImage } from 'electron';

import getSongControls from '../../providers/song-controls';
import registerCallback, { SongInfo } from '../../providers/song-info';
import { getMediaIconLocation } from '../utils';

export default (win: BrowserWindow) => {
let currentSongInfo: SongInfo;
Expand Down Expand Up @@ -43,7 +44,7 @@ export default (win: BrowserWindow) => {

// Util
const get = (kind: string) => {
return path.join(__dirname, '../../assets/media-icons-black', `${kind}.png`);
return path.join(getMediaIconLocation(), `${kind}.png`);
};

registerCallback((songInfo) => {
Expand Down
7 changes: 6 additions & 1 deletion plugins/utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import fs from 'node:fs';
import path from 'node:path';

import { ipcMain, ipcRenderer } from 'electron';
import { app, ipcMain, ipcRenderer } from 'electron';

import is from 'electron-is';

import { ValueOf } from '../utils/type-utils';
import defaultConfig from '../config/defaults';

export const getMediaIconLocation = () =>
app.isPackaged
? path.resolve(app.getPath('userData'), 'icons')
: path.resolve(__dirname, 'assets', 'media-icons-black');

// Creates a DOM element from an HTML string
export const ElementFromHtml = (html: string): HTMLElement => {
const template = document.createElement('template');
Expand Down

0 comments on commit 92a3a55

Please sign in to comment.