mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
feat(modal): port Error and ShowToken
This commit is contained in:
@@ -12,6 +12,7 @@ import { IconButton, Preloader } from "@revoltchat/ui";
|
||||
import { determineFileSize } from "../../lib/fileSize";
|
||||
|
||||
import { useIntermediate } from "../intermediate/Intermediate";
|
||||
import { modalController } from "../modals";
|
||||
import { AppContext } from "./RevoltClient";
|
||||
import { takeError } from "./util";
|
||||
|
||||
@@ -139,12 +140,19 @@ export function FileUploader(props: Props) {
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
return openScreen({ id: "error", error: takeError(err) });
|
||||
return modalController.push({
|
||||
type: "error",
|
||||
error: takeError(err),
|
||||
});
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
},
|
||||
() => openScreen({ id: "error", error: "FileTooLarge" }),
|
||||
() =>
|
||||
modalController.push({
|
||||
type: "error",
|
||||
error: "FileTooLarge",
|
||||
}),
|
||||
props.behaviour === "multi",
|
||||
);
|
||||
}
|
||||
@@ -180,8 +188,8 @@ export function FileUploader(props: Props) {
|
||||
const blob = item.getAsFile();
|
||||
if (blob) {
|
||||
if (blob.size > props.maxFileSize) {
|
||||
openScreen({
|
||||
id: "error",
|
||||
modalController.push({
|
||||
type: "error",
|
||||
error: "FileTooLarge",
|
||||
});
|
||||
continue;
|
||||
@@ -212,7 +220,10 @@ export function FileUploader(props: Props) {
|
||||
const files = [];
|
||||
for (const item of dropped) {
|
||||
if (item.size > props.maxFileSize) {
|
||||
openScreen({ id: "error", error: "FileTooLarge" });
|
||||
modalController.push({
|
||||
type: "error",
|
||||
error: "FileTooLarge",
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import { Preloader } from "@revoltchat/ui";
|
||||
|
||||
import { useApplicationState } from "../../mobx/State";
|
||||
|
||||
import { useIntermediate } from "../intermediate/Intermediate";
|
||||
import { modalController } from "../modals";
|
||||
import { registerEvents } from "./events";
|
||||
import { takeError } from "./util";
|
||||
@@ -30,7 +29,7 @@ export interface ClientOperations {
|
||||
|
||||
export const AppContext = createContext<Client>(null!);
|
||||
export const StatusContext = createContext<ClientStatus>(null!);
|
||||
export const LogOutContext = createContext((avoidReq?: boolean) => {});
|
||||
export const LogOutContext = createContext<(avoidReq?: boolean) => void>(null!);
|
||||
|
||||
type Props = {
|
||||
children: Children;
|
||||
@@ -38,7 +37,6 @@ type Props = {
|
||||
|
||||
export default observer(({ children }: Props) => {
|
||||
const state = useApplicationState();
|
||||
const { openScreen } = useIntermediate();
|
||||
const [client, setClient] = useState<Client>(null!);
|
||||
const [status, setStatus] = useState(ClientStatus.LOADING);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
@@ -72,7 +70,10 @@ export default observer(({ children }: Props) => {
|
||||
modalController.push({ type: "signed_out" });
|
||||
} else {
|
||||
setStatus(ClientStatus.DISCONNECTED);
|
||||
openScreen({ id: "error", error });
|
||||
modalController.push({
|
||||
type: "error",
|
||||
error,
|
||||
});
|
||||
}
|
||||
})
|
||||
.finally(() => setLoaded(true));
|
||||
|
||||
Reference in New Issue
Block a user