Skip to content

Commit 46ac577

Browse files
committed
fix(frontend/templates): expand featured template when clicked
1 parent f4fe357 commit 46ac577

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

packages/frontend/src/components/menu/about.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ AIOStreams consolidates multiple Stremio addons and debrid services - including
205205
const signInModal = useDisclosure(false);
206206
const templatesModal = useDisclosure(false);
207207
const setupChoiceModal = useDisclosure(false);
208+
const [featuredTemplateToOpen, setFeaturedTemplateToOpen] =
209+
React.useState<Template | null>(null);
208210
const customHtml = status?.settings?.customHtml;
209211
const pathname = usePathname();
210212
const [deepLinkUrl, setDeepLinkUrl] = React.useState<string | undefined>(
@@ -367,7 +369,10 @@ AIOStreams consolidates multiple Stremio addons and debrid services - including
367369
<TemplateMiniCard
368370
key={template.metadata.id}
369371
template={template}
370-
onOpen={templatesModal.open}
372+
onOpen={() => {
373+
setFeaturedTemplateToOpen(template);
374+
templatesModal.open();
375+
}}
371376
/>
372377
))}
373378
</div>
@@ -533,9 +538,16 @@ AIOStreams consolidates multiple Stremio addons and debrid services - including
533538
<ConfirmationDialog {...confirmClearConfig} />
534539
<ConfigTemplatesModal
535540
open={templatesModal.isOpen}
536-
onOpenChange={templatesModal.toggle}
541+
onOpenChange={(v) => {
542+
if (v) templatesModal.open();
543+
else {
544+
templatesModal.close();
545+
setFeaturedTemplateToOpen(null);
546+
}
547+
}}
537548
deepLinkUrl={deepLinkUrl}
538549
deepLinkTemplateId={deepLinkTemplateId}
550+
initialExpandedTemplateId={featuredTemplateToOpen?.metadata.id}
539551
/>
540552
<SetupChoiceModal
541553
open={setupChoiceModal.isOpen}

packages/frontend/src/components/shared/templates/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function ConfigTemplatesModal({
2929
openImportModal = false,
3030
deepLinkUrl,
3131
deepLinkTemplateId,
32+
initialExpandedTemplateId,
3233
}: ConfigTemplatesModalProps) {
3334
const { setUserData, userData } = useUserData();
3435
const { status } = useStatus();
@@ -187,6 +188,13 @@ export function ConfigTemplatesModal({
187188
importer.confirmDeleteTemplate.open();
188189
}}
189190
totalTemplateCount={loader.templates.length}
191+
initialExpandedTemplate={
192+
initialExpandedTemplateId
193+
? (loader.templates.find(
194+
(t) => t.metadata.id === initialExpandedTemplateId
195+
) ?? undefined)
196+
: undefined
197+
}
190198
/>
191199
</div>
192200
</Modal>

packages/frontend/src/components/shared/templates/steps/browse.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ interface TemplateBrowseStepProps {
3737
onImportOpen: () => void;
3838
onDeleteRequest: (t: Template) => void;
3939
totalTemplateCount: number;
40+
initialExpandedTemplate?: Template;
4041
}
4142

4243
interface TemplateCardProps {
@@ -289,11 +290,21 @@ export function TemplateBrowseStep({
289290
onImportOpen,
290291
onDeleteRequest,
291292
totalTemplateCount,
293+
initialExpandedTemplate,
292294
}: TemplateBrowseStepProps) {
293295
const [expandedTemplate, setExpandedTemplate] = useState<Template | null>(
294296
null
295297
);
296298

299+
// Pre-open the description modal when an initialExpandedTemplate is provided.
300+
// Run when the template ID changes (new card clicked) or when it first resolves
301+
// from the loader (templates load async).
302+
useEffect(() => {
303+
if (initialExpandedTemplate) {
304+
setExpandedTemplate(initialExpandedTemplate);
305+
}
306+
}, [initialExpandedTemplate?.metadata.id]);
307+
297308
return (
298309
<>
299310
<div className="space-y-3 min-w-0">

packages/frontend/src/lib/templates/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export interface ConfigTemplatesModalProps {
8686
deepLinkUrl?: string;
8787
/** If set alongside deepLinkUrl, auto-selects the template with this ID from the fetched list. */
8888
deepLinkTemplateId?: string;
89+
/** If set, the browse step will open with the description modal for this template ID pre-expanded. */
90+
initialExpandedTemplateId?: string;
8991
}
9092

9193
export const TEMPLATE_CACHE = new Map<string, Template[]>();

0 commit comments

Comments
 (0)