feat: nicer patches + filtering, use stores again

This commit is contained in:
afn
2022-10-23 00:27:41 -04:00
parent 30d9f076ff
commit 831c4d9d47
18 changed files with 484 additions and 296 deletions

View File

@@ -0,0 +1,14 @@
import { readable } from 'svelte/store';
import type { Repository } from '$lib/types';
export type ContribData = { repositories: Repository[] };
const fetchContributors = async (): Promise<ContribData> => {
const response = await fetch('https://releases.rvcd.win/contributors');
const data = await response.json();
return data;
};
export const ContributorsStore = readable(fetchContributors());

23
src/data/PatchesStore.ts Normal file
View File

@@ -0,0 +1,23 @@
import { readable } from 'svelte/store';
import type { Patch } from '$lib/types';
export type PatchesData = { patches: Patch[]; packages: string[] };
const fetchPatches = async (): Promise<PatchesData> => {
const response = await fetch('https://releases.rvcd.win/patches');
const patches = await response.json();
let packages: string[] = [];
// gets packages
for (let i = 0; i < patches.length; i++) {
patches[i].compatiblePackages.forEach((pkg: Patch) => {
let index = packages.findIndex((x) => x == pkg.name);
if (index === -1) {
packages.push(pkg.name);
}
});
}
return { patches, packages };
};
export const PatchesStore = readable(fetchPatches());