Skip to content

Commit

Permalink
chore: update alerts to use new health service
Browse files Browse the repository at this point in the history
  • Loading branch information
insertish committed Jul 6, 2023
1 parent 9d83d7c commit 0d5ffb4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/pages/RevoltApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
38 changes: 32 additions & 6 deletions src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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" /> &lrm;@fakurian &rlm;·
unsplash.com
</a>
Expand Down
7 changes: 5 additions & 2 deletions src/updateWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0d5ffb4

Please sign in to comment.