File size: 1,020 Bytes
11452ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Component, OnInit } from '@angular/core';
import { PostsService } from 'app/posts.services';
import { UpdaterStatus } from '../../../api-types';

@Component({
  selector: 'app-update-progress-dialog',
  templateUrl: './update-progress-dialog.component.html',
  styleUrls: ['./update-progress-dialog.component.scss']
})
export class UpdateProgressDialogComponent implements OnInit {

  updateStatus: UpdaterStatus = null;
  updateInterval = 250;
  errored = false;

  constructor(private postsService: PostsService) { }

  ngOnInit(): void {
    this.getUpdateProgress();
    setInterval(() => {
      if (this.updateStatus['updating']) { this.getUpdateProgress(); }
    }, 250);
  }

  getUpdateProgress() {
    this.postsService.getUpdaterStatus().subscribe(res => {
      if (res) {
        this.updateStatus = res;
        if (this.updateStatus && this.updateStatus['error']) {
          this.postsService.openSnackBar($localize`Update failed. Check logs for more details.`);
        }
      }
    });
  }
}