one click install playlist working

This commit is contained in:
MathieuG-P
2022-12-23 00:29:15 +01:00
parent d556350eef
commit e18caca70f
10 changed files with 54 additions and 54 deletions
-7
View File
@@ -34,17 +34,10 @@ export class IpcService {
}
public watch<T>(channel: string): Observable<IpcResponse<T>>{
console.log("watch", channel);
if(this.channelObservables.has(channel)){ return this.channelObservables.get(channel) as Observable<IpcResponse<T>>; }
console.log("allo");
window.electron.ipcRenderer.on(channel, (res: IpcResponse<T>) => {
console.log("oui", res);
});
const obs = new Observable<IpcResponse<T>>(observer => {
window.electron.ipcRenderer.on(channel, (res: IpcResponse<T>) => {
console.log("oui", res);
observer.next(res);
});
})
@@ -1,4 +1,4 @@
import { map, multicast, tap } from "rxjs/operators";
import { map } from "rxjs/operators";
import { Observable, Subject } from "rxjs";
import { DownloadPlaylistProgression } from "shared/models/playlists/playlist.interface";
import { IpcService } from "./ipc.service";
@@ -34,18 +34,31 @@ export class PlaylistDownloaderService{
}));
}
public get progress$(): Observable<DownloadPlaylistProgression>{
return this.progressWatcher$.asObservable();
}
public oneClickInstallPlaylist(bpListUrl: string): Observable<DownloadPlaylistProgression>{
if(!this.progress.require()){ return null; }
this.progressWatcher$.next(null);
const res = new Subject<DownloadPlaylistProgression>();
this.progress.show(this.downloadProgression$, true);
const sub = this.progressWatcher$.subscribe(progress => {console.log("progress"); res.next(progress)})
const sub = this.progressWatcher$.subscribe(progress => {
res.next(progress);
if(progress.progression === 100){
this.progress.showFake(0.08);
}
})
this.ipc.send<void, string>("one-click-install-playlist", {args: bpListUrl}).then(oneClickRes => {
sub.unsubscribe();
this.progress.hide(true);
this.progressWatcher$.next(null);
if(!oneClickRes.success){
return res.error(oneClickRes.error);
}