Skip to content

Commit

Permalink
Preserve highlighted apps order (#1157)ca
Browse files Browse the repository at this point in the history
* Preserve highlighted apps order

* updat enext
  • Loading branch information
andy-t-wang authored Jan 31, 2025
1 parent 7fdebea commit 9fd32dc
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 65 deletions.
10 changes: 8 additions & 2 deletions web/api/v2/public/apps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const GET = async (request: NextRequest) => {
const country = headers.get("CloudFront-Viewer-Country");
const locale = parseLocale(headers.get("x-accept-language") ?? "");

const { page, limit, app_mode } = parsedParams;
const { page, limit } = parsedParams;
const client = await getAPIServiceGraphqlClient();

let highlightsIds: string[] = [];
Expand Down Expand Up @@ -192,11 +192,17 @@ export const GET = async (request: NextRequest) => {
return app;
});

highlightedApps = highlightedApps.sort((a, b) => {
const aIndex = highlightsIds.indexOf(a.app_id);
const bIndex = highlightsIds.indexOf(b.app_id);
return aIndex - bIndex;
});

return NextResponse.json(
{
app_rankings: {
top_apps: rankApps(formattedTopApps, metricsData),
highlights: rankApps(highlightedApps, metricsData),
highlights: highlightedApps,
},
categories: getAllLocalisedCategories(locale), // TODO: Localise
},
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"jotai": "^2.9.1",
"jsdom": "^25.0.1",
"json5": "^2.2.3",
"next": "14.2.13",
"next": "14.2.15",
"next-safe": "^3.5.0",
"next-useragent": "^2.8.0",
"playwright-qase-reporter": "^2.0.6",
Expand Down
123 changes: 61 additions & 62 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9fd32dc

Please sign in to comment.