Audio downloads now work with progress bar, but it requires file conversion at the end. It ends up being around the same speed as the regular method

This commit is contained in:
Tzahi12345
2020-05-03 03:24:25 -04:00
parent 4e6d68d9e6
commit fb23d7c41e
7 changed files with 84 additions and 17 deletions

View File

@@ -7,7 +7,7 @@
</h4>
<div class="container">
<div class="row">
<div *ngFor="let download of session_downloads.value | keyvalue; let i = index;" class="col-12 my-1">
<div *ngFor="let download of session_downloads.value | keyvalue: sort_downloads; let i = index;" class="col-12 my-1">
<mat-card *ngIf="download.value" class="mat-elevation-z3">
<app-download-item [download]="download.value" [queueNumber]="i+1" (cancelDownload)="clearDownload(session_downloads.key, download.value.uid)"></app-download-item>
</mat-card>

View File

@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChildren, QueryList, ElementRef } from '@angular/core';
import { Component, OnInit, ViewChildren, QueryList, ElementRef, OnDestroy } from '@angular/core';
import { PostsService } from 'app/posts.services';
import { trigger, transition, animateChild, stagger, query, style, animate } from '@angular/animations';
import { Router } from '@angular/router';
@@ -32,20 +32,26 @@ import { Router } from '@angular/router';
])
],
})
export class DownloadsComponent implements OnInit {
export class DownloadsComponent implements OnInit, OnDestroy {
downloads_check_interval = 500;
downloads_check_interval = 1000;
downloads = {};
interval_id = null;
keys = Object.keys;
valid_sessions_length = 0;
sort_downloads = (a, b) => {
const result = a.value.timestamp_start < b.value.timestamp_start;
return result;
}
constructor(public postsService: PostsService, private router: Router) { }
ngOnInit(): void {
this.getCurrentDownloads();
setInterval(() => {
this.interval_id = setInterval(() => {
this.getCurrentDownloads();
}, this.downloads_check_interval);
@@ -58,6 +64,10 @@ export class DownloadsComponent implements OnInit {
});
}
ngOnDestroy() {
if (this.interval_id) { clearInterval(this.interval_id) }
}
getCurrentDownloads() {
this.postsService.getCurrentDownloads().subscribe(res => {
if (res['downloads']) {