fix: progress not updating (#1055)

This commit is contained in:
Alex Inkin
2022-01-12 19:40:26 +03:00
committed by Aiden McClelland
parent 502b179eef
commit f9628f0230
9 changed files with 42 additions and 28 deletions

View File

@@ -1,9 +1,17 @@
import { NgModule } from '@angular/core' import { NgModule } from '@angular/core'
import { EmverComparesPipe, EmverSatisfiesPipe, EmverDisplayPipe } from '../pipes/emver.pipe' import {
EmverComparesPipe,
EmverSatisfiesPipe,
EmverDisplayPipe,
} from '../pipes/emver.pipe'
import { IncludesPipe } from '../pipes/includes.pipe' import { IncludesPipe } from '../pipes/includes.pipe'
import { TypeofPipe } from '../pipes/typeof.pipe' import { TypeofPipe } from '../pipes/typeof.pipe'
import { MarkdownPipe } from '../pipes/markdown.pipe' import { MarkdownPipe } from '../pipes/markdown.pipe'
import { TruncateCenterPipe, TruncateEndPipe, TruncateTailPipe } from '../pipes/truncate.pipe' import {
TruncateCenterPipe,
TruncateEndPipe,
TruncateTailPipe,
} from '../pipes/truncate.pipe'
import { MaskPipe } from '../pipes/mask.pipe' import { MaskPipe } from '../pipes/mask.pipe'
import { HasUiPipe, LaunchablePipe } from '../pipes/ui.pipe' import { HasUiPipe, LaunchablePipe } from '../pipes/ui.pipe'
import { EmptyPipe } from '../pipes/empty.pipe' import { EmptyPipe } from '../pipes/empty.pipe'
@@ -12,6 +20,7 @@ import { InstallState } from '../pipes/install-state.pipe'
import { TextSpinnerComponentModule } from '../components/text-spinner/text-spinner.component.module' import { TextSpinnerComponentModule } from '../components/text-spinner/text-spinner.component.module'
import { ConvertBytesPipe } from '../pipes/convert-bytes.pipe' import { ConvertBytesPipe } from '../pipes/convert-bytes.pipe'
import { DurationToSecondsPipe } from '../pipes/unit-conversion.pipe' import { DurationToSecondsPipe } from '../pipes/unit-conversion.pipe'
import { InstallProgressPipe } from '../pipes/install-progress.pipe'
@NgModule({ @NgModule({
declarations: [ declarations: [
@@ -19,6 +28,7 @@ import { DurationToSecondsPipe } from '../pipes/unit-conversion.pipe'
EmverSatisfiesPipe, EmverSatisfiesPipe,
TypeofPipe, TypeofPipe,
IncludesPipe, IncludesPipe,
InstallProgressPipe,
InstallState, InstallState,
MarkdownPipe, MarkdownPipe,
TruncateCenterPipe, TruncateCenterPipe,
@@ -33,9 +43,7 @@ import { DurationToSecondsPipe } from '../pipes/unit-conversion.pipe'
ConvertBytesPipe, ConvertBytesPipe,
DurationToSecondsPipe, DurationToSecondsPipe,
], ],
imports: [ imports: [TextSpinnerComponentModule],
TextSpinnerComponentModule,
],
exports: [ exports: [
EmverComparesPipe, EmverComparesPipe,
EmverSatisfiesPipe, EmverSatisfiesPipe,
@@ -48,6 +56,7 @@ import { DurationToSecondsPipe } from '../pipes/unit-conversion.pipe'
MaskPipe, MaskPipe,
EmverDisplayPipe, EmverDisplayPipe,
HasUiPipe, HasUiPipe,
InstallProgressPipe,
InstallState, InstallState,
LaunchablePipe, LaunchablePipe,
EmptyPipe, EmptyPipe,
@@ -58,4 +67,4 @@ import { DurationToSecondsPipe } from '../pipes/unit-conversion.pipe'
TextSpinnerComponentModule, TextSpinnerComponentModule,
], ],
}) })
export class SharingModule { } export class SharingModule {}

View File

@@ -31,7 +31,7 @@
<!-- ** installing, updating, restoring ** --> <!-- ** installing, updating, restoring ** -->
<ion-content *ngIf="showProgress(pkg)"> <ion-content *ngIf="showProgress(pkg)">
<app-show-progress <app-show-progress
*ngIf="pkg['install-progress'] | installState as installProgress" *ngIf="pkg | installState as installProgress"
[pkg]="pkg" [pkg]="pkg"
[installProgress]="installProgress" [installProgress]="installProgress"
></app-show-progress> ></app-show-progress>

View File

@@ -5,7 +5,7 @@
size="x-large" size="x-large"
weight="500" weight="500"
[disconnected]="connectionFailure" [disconnected]="connectionFailure"
[installProgress]="(progress | installState)?.totalProgress" [installProgress]="(pkg | installState)?.totalProgress"
[rendering]="PR[status.primary]" [rendering]="PR[status.primary]"
[sigtermTimeout]="pkg.manifest.main['sigterm-timeout']" [sigtermTimeout]="pkg.manifest.main['sigterm-timeout']"
></status> ></status>

View File

@@ -1,12 +1,6 @@
import { import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
ChangeDetectionStrategy,
Component,
Inject,
Input,
} from '@angular/core'
import { UiLauncherService } from 'src/app/services/ui-launcher.service' import { UiLauncherService } from 'src/app/services/ui-launcher.service'
import { import {
InstallProgress,
InterfaceDef, InterfaceDef,
PackageDataEntry, PackageDataEntry,
PackageState, PackageState,
@@ -68,10 +62,6 @@ export class AppShowStatusComponent {
return this.pkg.manifest.interfaces return this.pkg.manifest.interfaces
} }
get progress(): InstallProgress | undefined {
return this.pkg['install-progress']
}
get pkgStatus(): Status { get pkgStatus(): Status {
return this.pkg.installed.status return this.pkg.installed.status
} }

View File

@@ -2,7 +2,7 @@ import { Pipe, PipeTransform } from '@angular/core'
import { NavigationExtras } from '@angular/router' import { NavigationExtras } from '@angular/router'
import { NavController } from '@ionic/angular' import { NavController } from '@ionic/angular'
import { combineLatest, Observable } from 'rxjs' import { combineLatest, Observable } from 'rxjs'
import { filter, map } from 'rxjs/operators' import { filter, map, startWith } from 'rxjs/operators'
import { DependentInfo, exists } from 'src/app/util/misc.util' import { DependentInfo, exists } from 'src/app/util/misc.util'
import { import {
DependencyError, DependencyError,
@@ -48,12 +48,13 @@ export class ToDependenciesPipe implements PipeTransform {
'dependency-errors', 'dependency-errors',
), ),
]).pipe( ]).pipe(
filter(deps => deps.every(exists)), filter(deps => deps.every(exists) && !!pkg.installed),
map(([currentDeps, depErrors]) => map(([currentDeps, depErrors]) =>
Object.keys(currentDeps) Object.keys(currentDeps)
.filter(id => !!pkg.manifest.dependencies[id]) .filter(id => !!pkg.manifest.dependencies[id])
.map(id => this.setDepValues(pkg, id, depErrors)), .map(id => this.setDepValues(pkg, id, depErrors)),
), ),
startWith([]),
) )
} }

View File

@@ -117,9 +117,9 @@
<ion-text *ngIf="(pkg.manifest.version | compareEmver : localPkg.manifest.version) === 1" color="warning">Update Available</ion-text> <ion-text *ngIf="(pkg.manifest.version | compareEmver : localPkg.manifest.version) === 1" color="warning">Update Available</ion-text>
</p> </p>
<p *ngIf="[PackageState.Installing, PackageState.Updating] | includes : localPkg.state"> <p *ngIf="[PackageState.Installing, PackageState.Updating] | includes : localPkg.state">
<ion-text color="primary" *ngIf="(localPkg['install-progress'] | installState) as progress"> <ion-text color="primary" *ngIf="(localPkg['install-progress'] | installProgress) as progress">
Installing Installing
<span class="loading-dots"></span>{{ progress.totalProgress < 99 ? progress.totalProgress + '%' : 'finalizing' }} <span class="loading-dots"></span>{{ progress }}
</ion-text> </ion-text>
</p> </p>
<p *ngIf="localPkg.state === PackageState.Removing"> <p *ngIf="localPkg.state === PackageState.Removing">

View File

@@ -32,9 +32,9 @@
</p> </p>
<!-- installing, updating --> <!-- installing, updating -->
<p *ngIf="[PackageState.Installing, PackageState.Updating] | includes : localPkg.state"> <p *ngIf="[PackageState.Installing, PackageState.Updating] | includes : localPkg.state">
<ion-text color="primary" *ngIf="(localPkg['install-progress'] | installState) as progress"> <ion-text color="primary" *ngIf="(localPkg['install-progress'] | installProgress) as progress">
Installing Installing
<span class="loading-dots"></span>{{ progress.totalProgress < 99 ? progress.totalProgress + '%' : 'finalizing' }} <span class="loading-dots"></span>{{ progress }}
</ion-text> </ion-text>
</p> </p>
<!-- removing --> <!-- removing -->

View File

@@ -0,0 +1,14 @@
import { Pipe, PipeTransform } from '@angular/core'
import { InstallProgress } from '../services/patch-db/data-model'
import { packageLoadingProgress } from '../util/package-loading-progress'
@Pipe({
name: 'installProgress',
})
export class InstallProgressPipe implements PipeTransform {
transform(loadData: InstallProgress): string {
const { totalProgress } = packageLoadingProgress(loadData)
return totalProgress < 99 ? totalProgress + '%' : 'finalizing'
}
}

View File

@@ -1,5 +1,5 @@
import { Pipe, PipeTransform } from '@angular/core' import { Pipe, PipeTransform } from '@angular/core'
import { InstallProgress } from '../services/patch-db/data-model' import { PackageDataEntry } from '../services/patch-db/data-model'
import { import {
packageLoadingProgress, packageLoadingProgress,
ProgressData, ProgressData,
@@ -9,7 +9,7 @@ import {
name: 'installState', name: 'installState',
}) })
export class InstallState implements PipeTransform { export class InstallState implements PipeTransform {
transform(loadData: InstallProgress): ProgressData | null { transform(pkg: PackageDataEntry): ProgressData | null {
return packageLoadingProgress(loadData) return packageLoadingProgress(pkg['install-progress'])
} }
} }