Skip to content

Commit

Permalink
Fix infinite loading of quickstart templates
Browse files Browse the repository at this point in the history
This happens when Appwrite deosn't have the runtime from the quickstart
template enabled. This change:

1. filters the quickstart templates to only include enabled runtimes
2. only shows the "more" template card if there were more than 5
   filtered templates
  • Loading branch information
stnguyen90 committed Sep 1, 2023
1 parent 88b6d59 commit 842daed
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/lib/wizards/functions/cover.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -107,31 +107,30 @@
</li>
{/each}
{:then response}
{@const runtimes = response.runtimes}
{#each quickStart.runtimes.filter((_template, index) => index < 6) as runtime}
{@const runtimeDetail = runtimes.find(
(r) => r.$id === runtime.name
)}
{@const runtimes = new Map(response.runtimes.map((r) => [r.$id, r]))}
{@const templates = quickStart.runtimes.filter(_template => runtimes.has(_template.name))}
{#each templates.slice(0, 6) as template}
{@const runtimeDetail = runtimes.get(template.name)}
<li>
<button
on:click={() => {
trackEvent('click_connect_template', {
from: 'cover',
template: quickStart.id,
runtime: runtime.name
runtime: template.name
});
}}
on:click={() => connectTemplate(quickStart, runtime.name)}
on:click={() => connectTemplate(quickStart, template.name)}
class="box u-width-full-line u-flex u-cross-center u-gap-8"
style:--box-padding="1rem"
style:--box-border-radius="var(--border-radius-small)">
<div class="avatar is-size-small">
<img
style:--p-text-size="1.25rem"
src={`${base}/icons/${$app.themeInUse}/color/${
runtime.name.split('-')[0]
template.name.split('-')[0]
}.svg`}
alt={runtime.name} />
alt={template.name} />
</div>
<div class="body-text-2">
{runtimeDetail.name}
Expand All @@ -140,7 +139,7 @@
</li>
{/each}

{#if quickStart.runtimes.length < 6}
{#if templates.length > 5}
<li>
<Box
class="u-width-full-line u-flex u-cross-center u-gap-8"
Expand Down

0 comments on commit 842daed

Please sign in to comment.