Skip to content

Commit 81c11b0

Browse files
committed
Refresh build list on picker open and filter by platform
1 parent 9e113a8 commit 81c11b0

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

src/app/dashboard/apps/[appId]/store-listing/_components/build-section.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ export function BuildSection({
2525
versionBuild,
2626
versionString,
2727
onBuildChange,
28+
onRefresh,
2829
readOnly,
2930
}: {
3031
allBuilds: TFBuild[];
3132
selectedBuildId: string | null;
3233
versionBuild: AscBuild | null;
3334
versionString: string | undefined;
3435
onBuildChange: (buildId: string) => void;
36+
onRefresh: () => void;
3537
readOnly: boolean;
3638
}) {
3739
const selectedBuild = selectedBuildId
@@ -78,7 +80,7 @@ export function BuildSection({
7880
}
7981

8082
const picker = (
81-
<DropdownMenu>
83+
<DropdownMenu onOpenChange={(open) => { if (open) onRefresh(); }}>
8284
<DropdownMenuTrigger asChild>
8385
<Button variant="outline" size="sm">
8486
{selectedBuild ? "Change" : "Select build"}

src/app/dashboard/apps/[appId]/store-listing/page.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { useState, useEffect, useMemo, useRef } from "react";
3+
import { useState, useEffect, useMemo, useRef, useCallback } from "react";
44
import { useParams, useSearchParams } from "next/navigation";
55
import { Lock } from "@phosphor-icons/react";
66
import { Spinner } from "@/components/ui/spinner";
@@ -124,14 +124,28 @@ export default function StoreListingPage() {
124124
const [selectedBuildId, setSelectedBuildId] = useState<string | null>(null);
125125
const originalBuildIdRef = useRef<string | null>(null);
126126

127-
// Fetch all app builds for the picker
127+
const platform = selectedVersion?.attributes.platform;
128+
129+
// Fetch builds for the picker, filtered by platform
130+
const fetchBuilds = useCallback(
131+
(refresh = false) => {
132+
if (!appId) return;
133+
const params = new URLSearchParams();
134+
if (refresh) params.set("refresh", "1");
135+
if (platform) params.set("platform", platform);
136+
const qs = params.toString();
137+
fetch(`/api/apps/${appId}/testflight/builds${qs ? `?${qs}` : ""}`)
138+
.then((res) => (res.ok ? res.json() : { builds: [] }))
139+
.then((data) => setAllBuilds(data.builds ?? []))
140+
.catch(() => setAllBuilds([]));
141+
},
142+
[appId, platform],
143+
);
144+
145+
// Initial fetch when app/platform changes
128146
useEffect(() => {
129-
if (!appId) return;
130-
fetch(`/api/apps/${appId}/testflight/builds`)
131-
.then((res) => (res.ok ? res.json() : { builds: [] }))
132-
.then((data) => setAllBuilds(data.builds ?? []))
133-
.catch(() => setAllBuilds([]));
134-
}, [appId]);
147+
fetchBuilds();
148+
}, [fetchBuilds]);
135149

136150
const [releaseType, setReleaseType] = useState("manually");
137151
const [scheduledDate, setScheduledDate] = useState<Date | undefined>(undefined);
@@ -575,6 +589,7 @@ export default function StoreListingPage() {
575589
versionBuild={selectedVersion?.build ?? null}
576590
versionString={selectedVersion?.attributes.versionString}
577591
onBuildChange={(id) => { setSelectedBuildId(id); setDirty(true); }}
592+
onRefresh={() => fetchBuilds(true)}
578593
readOnly={readOnly}
579594
/>
580595

0 commit comments

Comments
 (0)