alphabetize backup select and recovery select (#2113)

This commit is contained in:
Matt Hill
2023-01-13 14:23:23 -07:00
committed by Aiden McClelland
parent 928de47d1d
commit 76b5234f7b
2 changed files with 31 additions and 24 deletions

View File

@@ -28,13 +28,17 @@ export class ToOptionsPipe implements PipeTransform {
): Observable<AppRecoverOption[]> { ): Observable<AppRecoverOption[]> {
return packageData$.pipe( return packageData$.pipe(
map(packageData => map(packageData =>
Object.keys(packageBackups).map(id => ({ Object.keys(packageBackups)
...packageBackups[id], .map(id => ({
id, ...packageBackups[id],
installed: !!packageData[id], id,
checked: false, installed: !!packageData[id],
'newer-eos': this.compare(packageBackups[id]['os-version']), checked: false,
})), 'newer-eos': this.compare(packageBackups[id]['os-version']),
}))
.sort((a, b) =>
b.title.toLowerCase() > a.title.toLowerCase() ? -1 : 1,
),
), ),
) )
} }

View File

@@ -3,6 +3,7 @@ import { ModalController } from '@ionic/angular'
import { map, take } from 'rxjs/operators' import { map, take } from 'rxjs/operators'
import { DataModel, PackageState } from 'src/app/services/patch-db/data-model' import { DataModel, PackageState } from 'src/app/services/patch-db/data-model'
import { PatchDB } from 'patch-db-client' import { PatchDB } from 'patch-db-client'
import { firstValueFrom } from 'rxjs'
@Component({ @Component({
selector: 'backup-select', selector: 'backup-select',
@@ -25,25 +26,27 @@ export class BackupSelectPage {
private readonly patch: PatchDB<DataModel>, private readonly patch: PatchDB<DataModel>,
) {} ) {}
ngOnInit() { async ngOnInit() {
this.patch this.pkgs = await firstValueFrom(
.watch$('package-data') this.patch.watch$('package-data').pipe(
.pipe(
map(pkgs => { map(pkgs => {
return Object.values(pkgs).map(pkg => { return Object.values(pkgs)
const { id, title } = pkg.manifest .map(pkg => {
return { const { id, title } = pkg.manifest
id, return {
title, id,
icon: pkg['static-files'].icon, title,
disabled: pkg.state !== PackageState.Installed, icon: pkg['static-files'].icon,
checked: pkg.state === PackageState.Installed, disabled: pkg.state !== PackageState.Installed,
} checked: pkg.state === PackageState.Installed,
}) }
})
.sort((a, b) =>
b.title.toLowerCase() > a.title.toLowerCase() ? -1 : 1,
)
}), }),
take(1), ),
) )
.subscribe(pkgs => (this.pkgs = pkgs))
} }
dismiss(success = false) { dismiss(success = false) {