Skip to content

Commit 7f12c38

Browse files
committed
feat: Improve downtime status banner description
1 parent 04ab5cf commit 7f12c38

File tree

7 files changed

+41
-35
lines changed

7 files changed

+41
-35
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
RV_API_URL=https://api.revanced.app
22
RV_STATUS_URL=https://status.revanced.app
3+
34
RV_GOOGLE_TAG_MANAGER_ID=
45
RV_DMCA_GUID=

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
RV_GOOGLE_TAG_MANAGER_ID: ${{ vars.RV_GOOGLE_TAG_MANAGER_ID }}
3636
RV_DMCA_GUID: ${{ vars.RV_DMCA_GUID }}
3737
RV_STATUS_URL: ${{ vars.RV_STATUS_URL }}
38+
RV_EMAIL: ${{ vars.RV_EMAIL }}
3839
run: npm run build
3940

4041
- name: Deploy

src/data/api/settings.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
import { browser } from '$app/environment';
2-
import { RV_API_URL, RV_STATUS_URL } from '$env/static/public';
2+
import { RV_API_URL, RV_EMAIL, RV_STATUS_URL } from '$env/static/public';
33

44
export const default_api_url = RV_API_URL;
55
export const default_status_url = RV_STATUS_URL;
6+
export const default_email = RV_EMAIL;
67

78
const URL_KEY = 'revanced_api_url';
89
const STATUS_KEY = 'revanced_status_url';
9-
10-
function set_status_url(apiUrl: string) {
11-
fetch(`${apiUrl}/v4/about`)
12-
.then((response) => (response.ok ? response.json() : null))
13-
.then((data) => {
14-
if (data?.status) {
15-
localStorage.setItem(STATUS_KEY, data.status);
16-
console.log('Status is now:', localStorage.getItem(STATUS_KEY));
17-
}
18-
});
19-
}
10+
const EMAIL_KEY = 'revanced_email';
2011

2112
export const API_VERSION = 'v4';
2213

@@ -25,9 +16,7 @@ export function api_base_url(): string {
2516
if (browser) {
2617
const apiUrl = localStorage.getItem(URL_KEY) || default_api_url;
2718

28-
if (!localStorage.getItem(STATUS_KEY)) {
29-
set_status_url(apiUrl);
30-
}
19+
set_about_info(apiUrl);
3120

3221
return apiUrl;
3322
}
@@ -43,12 +32,35 @@ export function status_url(): string {
4332
return default_status_url;
4433
}
4534

35+
export function email(): string {
36+
if (browser) {
37+
return localStorage.getItem(EMAIL_KEY) || default_email;
38+
}
39+
40+
return default_email;
41+
}
42+
4643
// (re)set base URL.
4744
export function set_api_base_url(url?: string) {
4845
if (!url) {
4946
localStorage.removeItem(URL_KEY);
5047
} else {
5148
localStorage.setItem(URL_KEY, url);
52-
set_status_url(url);
49+
set_about_info(url);
50+
}
51+
}
52+
53+
function set_about_info(apiUrl: string) {
54+
if (!localStorage.getItem(STATUS_KEY) || !localStorage.getItem(EMAIL_KEY)) {
55+
fetch(`${apiUrl}/v4/about`)
56+
.then((response) => (response.ok ? response.json() : null))
57+
.then((data) => {
58+
if (data?.status) {
59+
localStorage.setItem(STATUS_KEY, data.status);
60+
localStorage.setItem(EMAIL_KEY, data.contact.email);
61+
console.log('Status is now:', localStorage.getItem(STATUS_KEY));
62+
console.log('Email is now:', localStorage.getItem(EMAIL_KEY));
63+
}
64+
});
5365
}
5466
}

src/layout/Banners/StatusBanner.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { goto } from '$app/navigation';
3+
import { email } from '$data/api/settings';
34
import Banner from '$layout/Banners/Banner.svelte';
45
56
export let statusUrl: string | null = null;
@@ -9,7 +10,7 @@
910

1011
<Banner
1112
title="API service is currently down"
12-
description="We're actively investigating and will update you shortly. We appreciate your patience."
13+
description="Some features of the site might be impacted. If this issue persists, reach out to mailto:{email()}"
1314
buttonText={statusUrl ? 'View status' : undefined}
1415
buttonOnClick={statusUrl ? handleClick : undefined}
1516
level="caution"

src/layout/Footer/FooterHost.svelte

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { RV_DMCA_GUID } from '$env/static/public';
1111
import { onMount } from 'svelte';
1212
import Divider from '$lib/components/Divider.svelte';
13+
import { email } from '$data/api/settings';
1314
1415
const aboutQuery = createQuery(queries.about());
1516
@@ -27,13 +28,11 @@
2728
<section class="main-content">
2829
<img src="/logo.svg" class="logo-image" alt="ReVanced Logo" />
2930
<Query query={aboutQuery} let:data>
30-
{#if data}
31-
<div>
32-
<p>
33-
{data.about.about}
34-
</p>
35-
</div>
36-
{/if}
31+
<div>
32+
<p>
33+
{data.about.about}
34+
</p>
35+
</div>
3736
</Query>
3837
</section>
3938

@@ -62,11 +61,7 @@
6261
<div class="bottom">
6362
<div id="logo-name"><span>Re</span>Vanced</div>
6463
<a href="/donate"><div>Donate</div></a>
65-
<Query query={aboutQuery} let:data>
66-
{#if data}
67-
<a href="mailto:{data.about.contact.email}"><div>Email</div></a>
68-
{/if}
69-
</Query>
64+
<a href="mailto:{email()}"><div>Email</div></a>
7065
<!-- DMCA Protection Badge -->
7166
<a
7267
href="//www.dmca.com/Protection/Status.aspx?ID={RV_DMCA_GUID}&refurl={location}"

src/routes/announcements/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
</div>
9898
<main class="wrapper" in:fly={{ y: 10, easing: quintOut, duration: 750 }}>
9999
<Query query={tagsQuery} let:data>
100-
<TagsHost tags={data.tags} expandable={true} />
100+
<TagsHost tags={data.tags} />
101101
</Query>
102102

103103
<Query {query} let:data>

src/routes/announcements/AnnouncementCard.svelte

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@
8585
{/if}
8686
{#if announcement.tags && announcement.tags.length > 0}
8787
<hr />
88-
<TagsHost
89-
tags={announcement.tags.map((tag) => ({ name: tag }))}
90-
expandable={false}
91-
clickable={false}
92-
/>
88+
<TagsHost tags={announcement.tags.map((tag) => ({ name: tag }))} clickable={false} />
9389
{/if}
9490
</div>
9591
</div>

0 commit comments

Comments
 (0)