From 7f12c3819ebb3cc6631b7f337f3580090e44c517 Mon Sep 17 00:00:00 2001 From: Ushie Date: Thu, 26 Jun 2025 05:09:22 +0300 Subject: [PATCH] feat: Improve downtime status banner description --- .env.example | 1 + .github/workflows/deploy.yml | 1 + src/data/api/settings.ts | 44 ++++++++++++------- src/layout/Banners/StatusBanner.svelte | 3 +- src/layout/Footer/FooterHost.svelte | 19 +++----- src/routes/announcements/+page.svelte | 2 +- .../announcements/AnnouncementCard.svelte | 6 +-- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/.env.example b/.env.example index e61e61d..8abff3f 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ RV_API_URL=https://api.revanced.app RV_STATUS_URL=https://status.revanced.app +RV_EMAIL=contact@revanced.app RV_GOOGLE_TAG_MANAGER_ID= RV_DMCA_GUID= \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1afc7de..8cd1ba5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,6 +35,7 @@ jobs: RV_GOOGLE_TAG_MANAGER_ID: ${{ vars.RV_GOOGLE_TAG_MANAGER_ID }} RV_DMCA_GUID: ${{ vars.RV_DMCA_GUID }} RV_STATUS_URL: ${{ vars.RV_STATUS_URL }} + RV_EMAIL: ${{ vars.RV_EMAIL }} run: npm run build - name: Deploy diff --git a/src/data/api/settings.ts b/src/data/api/settings.ts index e95498b..b509d57 100644 --- a/src/data/api/settings.ts +++ b/src/data/api/settings.ts @@ -1,22 +1,13 @@ import { browser } from '$app/environment'; -import { RV_API_URL, RV_STATUS_URL } from '$env/static/public'; +import { RV_API_URL, RV_EMAIL, RV_STATUS_URL } from '$env/static/public'; export const default_api_url = RV_API_URL; export const default_status_url = RV_STATUS_URL; +export const default_email = RV_EMAIL; const URL_KEY = 'revanced_api_url'; const STATUS_KEY = 'revanced_status_url'; - -function set_status_url(apiUrl: string) { - fetch(`${apiUrl}/v4/about`) - .then((response) => (response.ok ? response.json() : null)) - .then((data) => { - if (data?.status) { - localStorage.setItem(STATUS_KEY, data.status); - console.log('Status is now:', localStorage.getItem(STATUS_KEY)); - } - }); -} +const EMAIL_KEY = 'revanced_email'; export const API_VERSION = 'v4'; @@ -25,9 +16,7 @@ export function api_base_url(): string { if (browser) { const apiUrl = localStorage.getItem(URL_KEY) || default_api_url; - if (!localStorage.getItem(STATUS_KEY)) { - set_status_url(apiUrl); - } + set_about_info(apiUrl); return apiUrl; } @@ -43,12 +32,35 @@ export function status_url(): string { return default_status_url; } +export function email(): string { + if (browser) { + return localStorage.getItem(EMAIL_KEY) || default_email; + } + + return default_email; +} + // (re)set base URL. export function set_api_base_url(url?: string) { if (!url) { localStorage.removeItem(URL_KEY); } else { localStorage.setItem(URL_KEY, url); - set_status_url(url); + set_about_info(url); + } +} + +function set_about_info(apiUrl: string) { + if (!localStorage.getItem(STATUS_KEY) || !localStorage.getItem(EMAIL_KEY)) { + fetch(`${apiUrl}/v4/about`) + .then((response) => (response.ok ? response.json() : null)) + .then((data) => { + if (data?.status) { + localStorage.setItem(STATUS_KEY, data.status); + localStorage.setItem(EMAIL_KEY, data.contact.email); + console.log('Status is now:', localStorage.getItem(STATUS_KEY)); + console.log('Email is now:', localStorage.getItem(EMAIL_KEY)); + } + }); } } diff --git a/src/layout/Banners/StatusBanner.svelte b/src/layout/Banners/StatusBanner.svelte index ee2985f..db32556 100644 --- a/src/layout/Banners/StatusBanner.svelte +++ b/src/layout/Banners/StatusBanner.svelte @@ -1,5 +1,6 @@