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[]> {
return packageData$.pipe(
map(packageData =>
Object.keys(packageBackups).map(id => ({
...packageBackups[id],
id,
installed: !!packageData[id],
checked: false,
'newer-eos': this.compare(packageBackups[id]['os-version']),
})),
Object.keys(packageBackups)
.map(id => ({
...packageBackups[id],
id,
installed: !!packageData[id],
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 { DataModel, PackageState } from 'src/app/services/patch-db/data-model'
import { PatchDB } from 'patch-db-client'
import { firstValueFrom } from 'rxjs'
@Component({
selector: 'backup-select',
@@ -25,25 +26,27 @@ export class BackupSelectPage {
private readonly patch: PatchDB<DataModel>,
) {}
ngOnInit() {
this.patch
.watch$('package-data')
.pipe(
async ngOnInit() {
this.pkgs = await firstValueFrom(
this.patch.watch$('package-data').pipe(
map(pkgs => {
return Object.values(pkgs).map(pkg => {
const { id, title } = pkg.manifest
return {
id,
title,
icon: pkg['static-files'].icon,
disabled: pkg.state !== PackageState.Installed,
checked: pkg.state === PackageState.Installed,
}
})
return Object.values(pkgs)
.map(pkg => {
const { id, title } = pkg.manifest
return {
id,
title,
icon: pkg['static-files'].icon,
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) {