mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-30 06:34:35 +02:00
fix: Display patches using new patches JSON format
This commit is contained in:
parent
e290b7c4fd
commit
3c6b6d23f5
@ -10,7 +10,8 @@ import type {
|
|||||||
DonationPlatform,
|
DonationPlatform,
|
||||||
CryptoWallet,
|
CryptoWallet,
|
||||||
Social,
|
Social,
|
||||||
Info
|
Info,
|
||||||
|
CompatiblePackage
|
||||||
} from '$lib/types';
|
} from '$lib/types';
|
||||||
|
|
||||||
export type ReposData = { repositories: Repository[] };
|
export type ReposData = { repositories: Repository[] };
|
||||||
@ -44,7 +45,7 @@ async function patches(): Promise<PatchesData> {
|
|||||||
|
|
||||||
// gets packages and patch count
|
// gets packages and patch count
|
||||||
for (let i = 0; i < json.patches.length; i++) {
|
for (let i = 0; i < json.patches.length; i++) {
|
||||||
json.patches[i].compatiblePackages.forEach((pkg: Patch) => {
|
json.patches[i].compatiblePackages?.forEach((pkg: CompatiblePackage) => {
|
||||||
packagesWithCount[pkg.name] = (packagesWithCount[pkg.name] || 0) + 1;
|
packagesWithCount[pkg.name] = (packagesWithCount[pkg.name] || 0) + 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,10 @@ export interface Repository {
|
|||||||
export interface Patch {
|
export interface Patch {
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
version: string;
|
|
||||||
excluded: boolean;
|
|
||||||
dependencies: string[];
|
|
||||||
options: PatchOption[];
|
|
||||||
compatiblePackages: CompatiblePackage[];
|
compatiblePackages: CompatiblePackage[];
|
||||||
|
use: boolean;
|
||||||
|
requiresIntegrations: boolean;
|
||||||
|
options: PatchOption[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CompatiblePackage {
|
export interface CompatiblePackage {
|
||||||
@ -26,10 +25,10 @@ export interface CompatiblePackage {
|
|||||||
|
|
||||||
export interface PatchOption {
|
export interface PatchOption {
|
||||||
key: string;
|
key: string;
|
||||||
|
default: any;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
required: boolean;
|
required: boolean;
|
||||||
choices: string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Asset {
|
export interface Asset {
|
||||||
|
@ -47,11 +47,11 @@
|
|||||||
if (pkg === '') {
|
if (pkg === '') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !!patch.compatiblePackages.find((compat) => compat.name === pkg);
|
return !!patch.compatiblePackages?.find((compat) => compat.name === pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchString(str: string, term: string, filter: RegExp) {
|
function searchString(str?: string, term: string, filter: RegExp) {
|
||||||
return str.toLowerCase().replace(filter, '').includes(term);
|
return str?.toLowerCase().replace(filter, '').includes(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter(patches: Patch[], pkg: string, search?: string): Patch[] {
|
function filter(patches: Patch[], pkg: string, search?: string): Patch[] {
|
||||||
@ -70,7 +70,7 @@
|
|||||||
return (
|
return (
|
||||||
searchString(patch.description, search, /\s/g) ||
|
searchString(patch.description, search, /\s/g) ||
|
||||||
searchString(patch.name, search, /\s/g) ||
|
searchString(patch.name, search, /\s/g) ||
|
||||||
patch.compatiblePackages.find((x) => searchString(x.name, search, /\./g))
|
patch.compatiblePackages?.find((x) => searchString(x.name, search, /\./g))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
export let patch: Patch;
|
export let patch: Patch;
|
||||||
export let showAllVersions: boolean;
|
export let showAllVersions: boolean;
|
||||||
const hasPatchOptions = !!patch.options.length;
|
const hasPatchOptions = !!patch.options?.length;
|
||||||
let expanded: boolean = false;
|
let expanded: boolean = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -26,28 +26,30 @@
|
|||||||
<img class="expand-arrow" src="/icons/expand_more.svg" alt="dropdown" />
|
<img class="expand-arrow" src="/icons/expand_more.svg" alt="dropdown" />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<h5>{patch.description}</h5>
|
{#if patch.description}
|
||||||
|
<h5>{patch.description}</h5>
|
||||||
|
{/if}
|
||||||
<ul class="info-container">
|
<ul class="info-container">
|
||||||
{#each patch.compatiblePackages as pkg}
|
{#if !patch.compatiblePackages?.length}
|
||||||
<a
|
|
||||||
href="https://play.google.com/store/apps/details?id={pkg.name}"
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
>
|
|
||||||
<li class="patch-info">📦 {pkg.name}</li>
|
|
||||||
</a>
|
|
||||||
{/each}
|
|
||||||
|
|
||||||
{#if !patch.compatiblePackages.length}
|
|
||||||
<li class="patch-info">🌎 Universal patch</li>
|
<li class="patch-info">🌎 Universal patch</li>
|
||||||
|
{:else}
|
||||||
|
{#each patch.compatiblePackages as pkg}
|
||||||
|
<a
|
||||||
|
href="https://play.google.com/store/apps/details?id={pkg.name}"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
<li class="patch-info">📦 {pkg.name}</li>
|
||||||
|
</a>
|
||||||
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if hasPatchOptions}
|
{#if hasPatchOptions}
|
||||||
<li class="patch-info">⚙️ Patch options</li>
|
<li class="patch-info">⚙️ Patch options</li>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<!-- should i hardcode this to get the version of the first package? idk you cant stop me -->
|
<!-- Should this be hardcoded to get the version of the first package? -->
|
||||||
{#if patch.compatiblePackages.length && patch.compatiblePackages[0].versions.length}
|
{#if patch.compatiblePackages?.length && patch.compatiblePackages[0].versions?.length}
|
||||||
{#if showAllVersions}
|
{#if showAllVersions}
|
||||||
{#each patch.compatiblePackages[0].versions
|
{#each patch.compatiblePackages[0].versions
|
||||||
.slice()
|
.slice()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user