mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 17:11:55 +00:00
Port Login UI
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { isTouchscreenDevice } from "../lib/isTouchscreenDevice";
|
||||
import { createGlobalStyle } from "styled-components";
|
||||
import { Children } from "../types/Preact";
|
||||
import { createContext } from "preact";
|
||||
import { Helmet } from "react-helmet";
|
||||
|
||||
export type Variables =
|
||||
@@ -111,6 +112,8 @@ const GlobalTheme = createGlobalStyle<{ theme: Theme }>`
|
||||
}
|
||||
`;
|
||||
|
||||
export const ThemeContext = createContext<Theme>({} as any);
|
||||
|
||||
interface Props {
|
||||
children: Children;
|
||||
}
|
||||
@@ -119,7 +122,7 @@ export default function Theme(props: Props) {
|
||||
const theme = PRESETS.dark;
|
||||
|
||||
return (
|
||||
<>
|
||||
<ThemeContext.Provider value={theme}>
|
||||
<Helmet>
|
||||
<meta
|
||||
name="theme-color"
|
||||
@@ -132,6 +135,6 @@ export default function Theme(props: Props) {
|
||||
</Helmet>
|
||||
<GlobalTheme theme={theme} />
|
||||
{props.children}
|
||||
</>
|
||||
</ThemeContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
18
src/context/revoltjs/error.ts
Normal file
18
src/context/revoltjs/error.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export function takeError(
|
||||
error: any
|
||||
): string {
|
||||
const type = error?.response?.data?.type;
|
||||
let id = type;
|
||||
if (!type) {
|
||||
if (error?.response?.status === 403) {
|
||||
return "Unauthorized";
|
||||
} else if (error && (!!error.isAxiosError && !error.response)) {
|
||||
return "NetworkError";
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
return "UnknownError";
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
Reference in New Issue
Block a user