diff --git a/src/main/plugins/playbackNotifications.ts b/src/main/plugins/playbackNotifications.ts index 5dbf750d..9f849f02 100644 --- a/src/main/plugins/playbackNotifications.ts +++ b/src/main/plugins/playbackNotifications.ts @@ -1,6 +1,8 @@ import fetch from "electron-fetch"; -import {nativeImage, Notification} from "electron"; +import {app, nativeImage, Notification} from "electron"; import NativeImage = Electron.NativeImage; +import {createWriteStream} from "fs"; +import {join} from "path"; export default class playbackNotifications { @@ -44,7 +46,8 @@ export default class playbackNotifications { ` }); - // image implementation in windows toasts - //img - this._notification.on('click', (_: any) => { this._utils.getWindow().show() this._utils.getWindow().focus() @@ -99,11 +99,20 @@ export default class playbackNotifications { if (this._artworkImage[a.artwork.url]) { this.createNotification(a); } else { - fetch(a.artwork.url).then(async blob => { - this._artworkImage[a.artwork.url] = nativeImage.createFromBuffer(Buffer.from(await blob.arrayBuffer())); - this._artworkNums[this._artworkNums.length] = a.artwork.url; - this.createNotification(a); - }); + if (process.platform === "win32") { + fetch(a.artwork.url) + .then(res => { + const dest = createWriteStream(join(app.getPath("temp"), `${a.songId}-${a.artwork.url.split('/').pop()}`)); + // @ts-ignore + res.body.pipe(dest) + }) + } else { + fetch(a.artwork.url).then(async blob => { + this._artworkImage[a.artwork.url] = nativeImage.createFromBuffer(Buffer.from(await blob.arrayBuffer())); + this._artworkNums[this._artworkNums.length] = a.artwork.url; + this.createNotification(a); + }); + } } }) }