- {latestRelease.timestamp &&
+ updated {latestRelease.timestamp &&
formatDistance(
new Date(latestRelease.timestamp * 1000),
new Date(),
diff --git a/src/env.ts b/src/env.ts
index 378c93c4..e6853fb7 100644
--- a/src/env.ts
+++ b/src/env.ts
@@ -16,6 +16,8 @@ export const EDITORS_PICKS_APPS_URL: string = `${BASE_URI}/picks/apps`
export const RECENTLY_UPDATED_URL: string = `${BASE_URI}/collection/recently-updated`
export const CATEGORY_URL = (category: keyof typeof Category): string =>
`${BASE_URI}/category/${category}`
+export const ADDONS_URL = (appid: string): string =>
+ `${BASE_URI}/addon/${appid}`
export const FEED_RECENTLY_UPDATED_URL: string = `${BASE_URI}/feed/recently-updated`
export const FEED_NEW_URL: string = `${BASE_URI}/feed/new`
diff --git a/src/fetchers.ts b/src/fetchers.ts
index 3e607569..592b637b 100644
--- a/src/fetchers.ts
+++ b/src/fetchers.ts
@@ -1,4 +1,4 @@
-import { Appstream } from './types/Appstream'
+import { AddonAppstream, Appstream, DesktopAppstream } from './types/Appstream'
import { Collection, Collections } from './types/Collection'
import { Category } from './types/Category'
@@ -13,13 +13,14 @@ import {
SUMMARY_DETAILS,
STATS_DETAILS,
STATS,
+ ADDONS_URL,
} from './env'
import { Summary } from './types/Summary'
import { AppStats } from './types/AppStats'
import { Stats } from './types/Stats'
-export async function fetchAppstream(appId: string): Promise
{
- let entryJson: Appstream
+export async function fetchAppstream(appId: string): Promise {
+ let entryJson: DesktopAppstream
try {
const entryData = await fetch(`${APP_DETAILS(appId)}`)
entryJson = await entryData.json()
@@ -135,6 +136,17 @@ export async function fetchCategory(category: keyof typeof Category) {
return items.filter((item) => Boolean(item))
}
+export async function fetchAddons(appid: string) {
+ const appListRes = await fetch(ADDONS_URL(appid))
+ const appList = await appListRes.json()
+
+ const items: AddonAppstream[] = await Promise.all(appList.map(fetchAppstream))
+
+ console.log('\nAddons for ', appid, ' fetched')
+
+ return items.filter((item) => Boolean(item))
+}
+
export async function fetchSearchQuery(query: string) {
const appListRes = await fetch(SEARCH_APP(query))
const appList = await appListRes.json()
diff --git a/src/types/Appstream.ts b/src/types/Appstream.ts
index 23efa239..8c90a10b 100644
--- a/src/types/Appstream.ts
+++ b/src/types/Appstream.ts
@@ -1,4 +1,7 @@
-export interface Appstream {
+export type Appstream = DesktopAppstream | AddonAppstream
+
+export interface DesktopAppstream {
+ type: "desktop"
description: string
screenshots?: Screenshot[]
releases: Release[]
@@ -18,6 +21,19 @@ export interface Appstream {
bundle: Bundle
}
+export interface AddonAppstream {
+ type: "addon"
+ releases: Release[];
+ urls: Urls;
+ icon?: any;
+ id: string;
+ name: string;
+ summary: string;
+ project_license?: string;
+ extends: string;
+ bundle: Bundle;
+}
+
interface ContentRating {
type: string
'violence-cartoon': ContentRatingLevel