mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: use maps to filter base runtimes
This commit is contained in:
@@ -7,11 +7,11 @@ export const runtimesList = derived(
|
||||
async ($page) => (await $page.data.runtimesList) as Models.RuntimeList
|
||||
);
|
||||
|
||||
export const baseRuntimesList = derived(runtimesList, async ($runtimesList) => ({
|
||||
runtimes: (await $runtimesList).runtimes
|
||||
.map((runtime) => {
|
||||
const runtimeBase = runtime.name.split('-')[0];
|
||||
return { ...runtime, name: runtimeBase };
|
||||
})
|
||||
.filter((runtime, index, self) => self.findIndex((n) => n.name === runtime.name) === index)
|
||||
}));
|
||||
export const baseRuntimesList = derived(runtimesList, async ($runtimesList) => {
|
||||
const baseRuntimes = new Map<string, Models.Runtime>();
|
||||
(await $runtimesList).runtimes.forEach((runtime) => {
|
||||
const runtimeBase = runtime.name.split('-')[0];
|
||||
baseRuntimes.set(runtimeBase, runtime);
|
||||
});
|
||||
return { runtimes: [...baseRuntimes.values()] };
|
||||
});
|
||||
|
||||
@@ -42,17 +42,13 @@
|
||||
|
||||
function getBaseRuntimes(runtimes: Runtime[]): Runtime[] {
|
||||
const baseRuntimes = new Map<string, Runtime>();
|
||||
|
||||
for (const runtime of runtimes) {
|
||||
const [baseRuntime] = runtime.name.split('-');
|
||||
if (!baseRuntimes.has(baseRuntime)) {
|
||||
baseRuntimes.set(baseRuntime, {
|
||||
...runtime,
|
||||
name: baseRuntime
|
||||
});
|
||||
}
|
||||
baseRuntimes.set(baseRuntime, {
|
||||
...runtime,
|
||||
name: baseRuntime
|
||||
});
|
||||
}
|
||||
|
||||
return [...baseRuntimes.values()];
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -1,14 +1,17 @@
|
||||
import { page } from '$app/stores';
|
||||
import type { MarketplaceTemplate } from '$lib/stores/marketplace';
|
||||
import type { MarketplaceTemplate, Runtime } from '$lib/stores/marketplace';
|
||||
import { derived } from 'svelte/store';
|
||||
|
||||
export const template = derived(page, ($page) => $page.data.template as MarketplaceTemplate);
|
||||
|
||||
export const baseRuntimes = derived(template, ($template) =>
|
||||
$template.runtimes
|
||||
.map((runtime) => {
|
||||
const runtimeBase = runtime.name.split('-')[0];
|
||||
return { ...runtime, name: runtimeBase };
|
||||
})
|
||||
.filter((runtime, index, self) => self.findIndex((n) => n.name === runtime.name) === index)
|
||||
);
|
||||
export const baseRuntimes = derived(template, ($template) => {
|
||||
const baseRuntimes = new Map<string, Runtime>();
|
||||
$template.runtimes.forEach((runtime) => {
|
||||
const runtimeBase = runtime.name.split('-')[0];
|
||||
baseRuntimes.set(runtimeBase, runtime);
|
||||
});
|
||||
return {
|
||||
...template,
|
||||
runtimes: [...baseRuntimes.values()]
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user