From 912a419bd4e3cd3781bf3b9410680fb7d74bfc45 Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Sun, 26 Apr 2020 17:34:38 -0400 Subject: [PATCH] Getting current download refactored to work and display less errors Player component now sends jwt token if logged in --- src/app/main/main.component.ts | 9 +++------ src/app/player/player.component.ts | 5 +++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 708674b..38339d3 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -1137,18 +1137,15 @@ export class MainComponent implements OnInit { } getCurrentDownload() { - this.postsService.getCurrentDownload(this.postsService.session_id, - this.current_download['ui_uid'] ? this.current_download['ui_uid'] : this.current_download['uid']).subscribe(res => { - const ui_uid = this.current_download['ui_uid'] ? this.current_download['ui_uid'] : this.current_download['uid']; + const ui_uid = this.current_download['ui_uid'] ? this.current_download['ui_uid'] : this.current_download['uid']; + this.postsService.getCurrentDownload(this.postsService.session_id, ui_uid).subscribe(res => { if (res['download']) { - console.log('got new download'); if (ui_uid === res['download']['ui_uid']) { this.current_download = res['download']; this.percentDownloaded = this.current_download.percent_complete; - console.log(this.percentDownloaded); } } else { - console.log('failed to get new download'); + // console.log('failed to get new download'); } }); } diff --git a/src/app/player/player.component.ts b/src/app/player/player.component.ts index 83acebb..07f33fa 100644 --- a/src/app/player/player.component.ts +++ b/src/app/player/player.component.ts @@ -183,6 +183,11 @@ export class PlayerComponent implements OnInit { fullLocation = this.baseStreamPath + baseLocation + encodeURIComponent(fileName) + '?subName=' + this.subscriptionName + '&subPlaylist=' + this.subPlaylist; } + + // adds user token if in multi-user-mode + if (this.postsService.isLoggedIn) { + fullLocation += '?jwt=' + this.postsService.token; + } // if it has a slash (meaning it's in a directory), only get the file name for the label let label = null; const decodedName = decodeURIComponent(fileName);