feat(footer): use info endpoint

This commit is contained in:
Ushie 2023-08-20 00:42:06 +03:00
parent eb31b942f4
commit d1c763c1d3
No known key found for this signature in database
GPG Key ID: B3AAD18842E34632
3 changed files with 67 additions and 34 deletions

View File

@ -9,13 +9,15 @@ import type {
TeamMember,
DonationPlatform,
CryptoWallet,
Social
Social,
Info
} from '$lib/types';
export type ReposData = { repositories: Repository[] };
export type PatchesData = { patches: Patch[]; packages: string[] };
export type ReleaseData = { metadata: Metadata; assets: Asset[] };
export type TeamData = { members: TeamMember[] };
export type InfoData = { info: Info };
export type DonationData = { wallets: CryptoWallet[]; platforms: DonationPlatform[] };
export type SocialsData = { socials: Social[] };
@ -49,7 +51,7 @@ async function patches(): Promise<PatchesData> {
// sort packages by patch count to get most relevant apps on top
const packages = Object.keys(packagesWithCount);
packages.sort((a, b) => packagesWithCount[b] - packagesWithCount[a]);
packages.sort((a, b) => packagesWithCount[b] - packagesWithCount[a]);
return { patches: json.patches, packages };
}
@ -59,6 +61,11 @@ async function team(): Promise<TeamData> {
return { members: json.members };
}
async function info(): Promise<InfoData> {
const json = await get_json('v2/info');
return { info: json.info };
}
async function donate(): Promise<DonationData> {
const json = await get_json('v2/donations');
return { wallets: json.donations.wallets, platforms: json.donations.links };
@ -91,6 +98,11 @@ export const queries = {
queryFn: team,
staleTime
},
info: {
queryKey: ['info'],
queryFn: info,
staleTime
},
donate: {
queryKey: ['donate'],
queryFn: donate,

View File

@ -11,6 +11,7 @@
import FooterSection from './FooterSection.svelte';
const repoQuery = createQuery(['repositories'], queries.repositories);
const infoQuery = createQuery(['info'], queries.info);
const socialsQuery = createQuery(['socials'], queries.socials);
</script>
@ -37,15 +38,15 @@
<div class="footer-top">
<section class="main-content">
<img src="/logo.svg" class="logo-image" alt="ReVanced Logo" />
<div>
<p>
ReVanced was born out of Vanced's discontinuation and it is our goal to continue the
legacy of what Vanced left behind. Thanks to ReVanced Patcher, it's possible to create
long-lasting patches for nearly any Android app. ReVanced's patching system is designed to
allow patches to work on new versions of the apps automatically with bare minimum
maintenance.
</p>
</div>
<Query query={infoQuery} let:data>
{#if data}
<div>
<p>
{data.info.about}
</p>
</div>
{/if}
</Query>
</section>
<section class="links-container">
@ -56,9 +57,9 @@
<li><a href="/contributors">Contributors</a></li>
<li><a href="/donate">Donate</a></li>
</FooterSection>
<FooterSection title="Repositories">
<Query query={repoQuery} let:data>
{#if data}
<Query query={repoQuery} let:data>
{#if data}
<FooterSection title="Repositories">
{#each data.repositories as { name }}
<li>
<a href="https://github.com/{name}" target="_blank" rel="noreferrer">
@ -66,27 +67,31 @@
</a>
</li>
{/each}
{/if}
</Query>
</FooterSection>
<FooterSection title="Socials">
<Query query={socialsQuery} let:data>
{#if data}
</FooterSection>
{/if}
</Query>
<Query query={socialsQuery} let:data>
{#if data}
<FooterSection title="Socials">
{#each data.socials as { name, url }}
<li>
<a href={url} target="_blank" rel="noreferrer">{friendlyName(name)}</a>
<a href={url} target="_blank" rel="noreferrer">{name}</a>
</li>
{/each}
{/if}
</Query>
</FooterSection>
</FooterSection>
{/if}
</Query>
</section>
</div>
<div class="footer-bottom">
<div id="logo-name"><span>Re</span>Vanced</div>
<a href="/donate"><div>Donate</div></a>
<a href="mailto:contact@revanced.app"><div>Email</div></a>
</div>
<Query query={infoQuery} let:data>
{#if data}
<div class="footer-bottom">
<div id="logo-name"><span>Re</span>Vanced</div>
<a href="/donate"><div>Donate</div></a>
<a href="mailto:{data.info.contact.email}"><div>Email</div></a>
</div>
{/if}
</Query>
</footer>
<style>

View File

@ -68,8 +68,24 @@ export interface DonationPlatform {
preferred: boolean;
}
export interface Social {
name: string
url: string
name: string;
url: string;
}
interface Donations {
wallets: CryptoWallet[];
links: DonationPlatform[];
}
interface Contact {
email: string;
}
export interface Info {
name: string;
about: string;
contact: Contact;
socials: Social[];
donations: Donations;
}