Getting current download refactored to work and display less errors

Player component now sends jwt token if logged in
pull/67/head
Isaac Grynsztein 6 years ago
parent a7c810136b
commit 912a419bd4

@ -1137,18 +1137,15 @@ export class MainComponent implements OnInit {
} }
getCurrentDownload() { getCurrentDownload() {
this.postsService.getCurrentDownload(this.postsService.session_id, const ui_uid = this.current_download['ui_uid'] ? this.current_download['ui_uid'] : this.current_download['uid'];
this.current_download['ui_uid'] ? this.current_download['ui_uid'] : this.current_download['uid']).subscribe(res => { this.postsService.getCurrentDownload(this.postsService.session_id, ui_uid).subscribe(res => {
const ui_uid = this.current_download['ui_uid'] ? this.current_download['ui_uid'] : this.current_download['uid'];
if (res['download']) { if (res['download']) {
console.log('got new download');
if (ui_uid === res['download']['ui_uid']) { if (ui_uid === res['download']['ui_uid']) {
this.current_download = res['download']; this.current_download = res['download'];
this.percentDownloaded = this.current_download.percent_complete; this.percentDownloaded = this.current_download.percent_complete;
console.log(this.percentDownloaded);
} }
} else { } else {
console.log('failed to get new download'); // console.log('failed to get new download');
} }
}); });
} }

@ -183,6 +183,11 @@ export class PlayerComponent implements OnInit {
fullLocation = this.baseStreamPath + baseLocation + encodeURIComponent(fileName) + '?subName=' + this.subscriptionName + fullLocation = this.baseStreamPath + baseLocation + encodeURIComponent(fileName) + '?subName=' + this.subscriptionName +
'&subPlaylist=' + this.subPlaylist; '&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 // if it has a slash (meaning it's in a directory), only get the file name for the label
let label = null; let label = null;
const decodedName = decodeURIComponent(fileName); const decodedName = decodeURIComponent(fileName);

Loading…
Cancel
Save