mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
timestamp sorting
This commit is contained in:
committed by
Aiden McClelland
parent
90b412384a
commit
d7508345eb
@@ -14,6 +14,7 @@ export interface BaseApp {
|
||||
export interface AppAvailablePreview extends BaseApp {
|
||||
versionLatest: string
|
||||
descriptionShort: string
|
||||
latestVersionTimestamp: Date
|
||||
}
|
||||
|
||||
export type AppAvailableFull =
|
||||
|
||||
@@ -74,7 +74,9 @@ export class AppAvailableListPage {
|
||||
async getApps (): Promise<void> {
|
||||
try {
|
||||
this.apps = await this.apiService.getAvailableApps().then(apps =>
|
||||
apps.map(a => ({ id: a.id, subject: initPropertySubject(a) })),
|
||||
apps
|
||||
.sort( (a1, a2) => a2.latestVersionTimestamp.getTime() - a1.latestVersionTimestamp.getTime())
|
||||
.map(a => ({ id: a.id, subject: initPropertySubject(a) })),
|
||||
)
|
||||
this.appModel.getContents().forEach(appInstalled => this.mergeInstalledProps(appInstalled.id))
|
||||
} catch (e) {
|
||||
|
||||
@@ -83,7 +83,12 @@ export class LiveApiService extends ApiService {
|
||||
}
|
||||
|
||||
async getAvailableApps (): Promise<AppAvailablePreview[]> {
|
||||
return this.authRequest<ReqRes.GetAppsAvailableRes>({ method: Method.GET, url: '/apps/store' })
|
||||
const res = await this.authRequest<ReqRes.GetAppsAvailableRes>({ method: Method.GET, url: '/apps/store' })
|
||||
return res.map(a => {
|
||||
const latestVersionTimestamp = new Date(a.latestVersionTimestamp)
|
||||
if (isNaN(latestVersionTimestamp as any)) throw new Error(`Invalid latestVersionTimestamp ${a.latestVersionTimestamp}`)
|
||||
return { ...a, latestVersionTimestamp }
|
||||
})
|
||||
}
|
||||
|
||||
async getAvailableApp (appId: string): Promise<AppAvailableFull> {
|
||||
|
||||
Reference in New Issue
Block a user