From 15c47b224c667351a54546b2f5469e2d5ada0e58 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Thu, 6 Jul 2023 19:00:30 +0100 Subject: [PATCH] chore: update alerts to use new health service --- src/pages/RevoltApp.tsx | 2 +- src/pages/login/Login.tsx | 38 ++++++++++++++++++++++++++++++++------ src/updateWorker.ts | 7 +++++-- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/pages/RevoltApp.tsx b/src/pages/RevoltApp.tsx index 3f9d2c48..ca4b2f22 100644 --- a/src/pages/RevoltApp.tsx +++ b/src/pages/RevoltApp.tsx @@ -28,7 +28,7 @@ const AppContainer = styled.div` background-position: center center !important; `; -const StatusBar = styled.div` +export const StatusBar = styled.div` height: 40px; width: 100%; display: flex; diff --git a/src/pages/login/Login.tsx b/src/pages/login/Login.tsx index 04fa8195..abd2e882 100644 --- a/src/pages/login/Login.tsx +++ b/src/pages/login/Login.tsx @@ -1,17 +1,19 @@ import { Twitter, Github, Mastodon } from "@styled-icons/boxicons-logos"; import { observer } from "mobx-react-lite"; import { Helmet } from "react-helmet"; -import { Route, Switch } from "react-router-dom"; +import { Link, Route, Switch } from "react-router-dom"; import styles from "./Login.module.scss"; import { Text } from "preact-i18n"; import { useApplicationState } from "../../mobx/State"; -import LocaleSelector from "../../components/common/LocaleSelector"; import wideSVG from "/assets/wide.svg"; +import LocaleSelector from "../../components/common/LocaleSelector"; import { Titlebar } from "../../components/native/Titlebar"; +import { useSystemAlert } from "../../updateWorker"; +import { StatusBar } from "../RevoltApp"; import { FormCreate } from "./forms/FormCreate"; import { FormLogin } from "./forms/FormLogin"; import { FormReset, FormSendReset } from "./forms/FormReset"; @@ -21,11 +23,31 @@ export default observer(() => { const state = useApplicationState(); const theme = state.settings.theme; + const alert = useSystemAlert(); + return ( <> {window.isNative && !window.native.getConfig().frame && ( )} + {alert && ( + +
{alert.text}
+
+ {alert.actions?.map((action) => + action.type === "internal" ? null : action.type === + "external" ? ( + +
{action.text}
{" "} +
+ ) : null, + )} +
+
+ )}
{
+ target="_blank" + rel="noreferrer"> + target="_blank" + rel="noreferrer"> + target="_blank" + rel="noreferrer">
@@ -116,7 +141,8 @@ export default observer(() => { + target="_blank" + rel="noreferrer"> ‎@fakurian ‏ยท unsplash.com diff --git a/src/updateWorker.ts b/src/updateWorker.ts index 5043ef90..8261d8f8 100644 --- a/src/updateWorker.ts +++ b/src/updateWorker.ts @@ -78,7 +78,7 @@ export function useSystemAlert() { */ async function checkVersion() { const { version, poll_rate, alert } = (await fetch( - "https://api.revolt.chat/release", + "https://health.revolt.chat/api/health", ).then((res) => res.json())) as { version: string; poll_rate?: number; @@ -111,7 +111,10 @@ async function checkVersion() { } } -if (import.meta.env.VITE_API_URL === "https://api.revolt.chat") { +if ( + import.meta.env.VITE_API_URL === "https://api.revolt.chat" || + import.meta.env.VITE_API_URL === "https://app.revolt.chat/api" +) { // Check for critical updates hourly schedule(); checkVersion();