mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-24 06:32:08 -05:00
chore: update alerts to use new health service
This commit is contained in:
parent
9d83d7cc1c
commit
0d5ffb4df8
3 changed files with 38 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -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 && (
|
||||
<Titlebar overlay />
|
||||
)}
|
||||
{alert && (
|
||||
<StatusBar>
|
||||
<div className="title">{alert.text}</div>
|
||||
<div className="actions">
|
||||
{alert.actions?.map((action) =>
|
||||
action.type === "internal" ? null : action.type ===
|
||||
"external" ? (
|
||||
<a
|
||||
href={action.href}
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
<div className="button">{action.text}</div>{" "}
|
||||
</a>
|
||||
) : null,
|
||||
)}
|
||||
</div>
|
||||
</StatusBar>
|
||||
)}
|
||||
<div className={styles.login}>
|
||||
<Helmet>
|
||||
<meta
|
||||
|
@ -77,17 +99,20 @@ export default observer(() => {
|
|||
<div className={styles.socials}>
|
||||
<a
|
||||
href="https://github.com/revoltchat"
|
||||
target="_blank" rel="noreferrer">
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
<Github size={24} />
|
||||
</a>
|
||||
<a
|
||||
href="https://twitter.com/revoltchat"
|
||||
target="_blank" rel="noreferrer">
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
<Twitter size={24} />
|
||||
</a>
|
||||
<a
|
||||
href="https://mastodon.social/@revoltchat"
|
||||
target="_blank" rel="noreferrer">
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
<Mastodon size={24} />
|
||||
</a>
|
||||
</div>
|
||||
|
@ -116,7 +141,8 @@ export default observer(() => {
|
|||
<a
|
||||
className={styles.attribution}
|
||||
href="https://unsplash.com/@fakurian"
|
||||
target="_blank" rel="noreferrer">
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
<Text id="general.image_by" /> ‎@fakurian ‏·
|
||||
unsplash.com
|
||||
</a>
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue