In the subscription page, the subscription is now continuously retrieved at an interval of 1s to update for new videos or the downloading state

- There is now a visual indicator for when a subscription is retrieving videos
This commit is contained in:
Isaac Abadi
2020-12-20 00:30:48 -05:00
parent 2971580f91
commit afb5e3800c
6 changed files with 68 additions and 38 deletions

View File

@@ -374,7 +374,7 @@ export class PostsService implements CanActivate {
}
getAllSubscriptions() {
return this.http.post(this.path + 'getAllSubscriptions', {}, this.httpOptions);
return this.http.post(this.path + 'getSubscriptions', {}, this.httpOptions);
}
// current downloads

View File

@@ -4,6 +4,7 @@
<h2 style="text-align: center;" *ngIf="subscription">
{{subscription.name}}&nbsp;<ng-container *ngIf="subscription.paused" i18n="Paused suffix">(Paused)</ng-container>
</h2>
<mat-progress-bar style="width: 80%; margin: 0 auto; margin-top: 15px;" *ngIf="subscription && subscription.downloading" mode="indeterminate"></mat-progress-bar>
</div>
<mat-divider style="width: 80%; margin: 0 auto"></mat-divider>
<br/>

View File

@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { PostsService } from 'app/posts.services';
import { ActivatedRoute, Router, ParamMap } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
@@ -9,7 +9,7 @@ import { EditSubscriptionDialogComponent } from 'app/dialogs/edit-subscription-d
templateUrl: './subscription.component.html',
styleUrls: ['./subscription.component.scss']
})
export class SubscriptionComponent implements OnInit {
export class SubscriptionComponent implements OnInit, OnDestroy {
id = null;
subscription = null;
@@ -44,22 +44,11 @@ export class SubscriptionComponent implements OnInit {
};
filterProperty = this.filterProperties['upload_date'];
downloading = false;
initialized = false;
sub_interval = null;
constructor(private postsService: PostsService, private route: ActivatedRoute, private router: Router, private dialog: MatDialog) { }
ngOnInit() {
this.route.paramMap.subscribe((params: ParamMap) => {
this.id = params.get('id');
this.postsService.service_initialized.subscribe(init => {
if (init) {
this.initialized = true;
this.getConfig();
this.getSubscription();
}
});
});
if (this.route.snapshot.paramMap.get('id')) {
this.id = this.route.snapshot.paramMap.get('id');
@@ -67,6 +56,7 @@ export class SubscriptionComponent implements OnInit {
if (init) {
this.getConfig();
this.getSubscription();
this.sub_interval = setInterval(() => this.getSubscription(), 1000);
}
});
}
@@ -78,6 +68,13 @@ export class SubscriptionComponent implements OnInit {
}
}
ngOnDestroy() {
// prevents subscription getter from running in the background
if (this.sub_interval) {
clearInterval(this.sub_interval);
}
}
goBack() {
this.router.navigate(['/subscriptions']);
}