fix: network offline tip

This commit is contained in:
Tristan Yang
2022-08-03 22:54:00 +08:00
parent eba6d1de52
commit d99a3428f8
5 changed files with 18 additions and 10 deletions
@@ -82,3 +82,4 @@ const MarkdownEditor: FC<Props> = ({
);
};
export default MarkdownEditor;
// prosemirror-mode version error https://github.com/ueberdosis/tiptap/issues/577
+12 -3
View File
@@ -1,4 +1,4 @@
import { useRef, useEffect, useState, useCallback, ClipboardEvent } from "react";
import { useRef, useEffect, useState, useCallback, ClipboardEvent, FC } from "react";
import { useKey } from "rooks";
import { Editor, Transforms } from "slate";
import {
@@ -30,10 +30,19 @@ let components = createPlateUI({
// customize your components by plugin key
});
const initials = [{ type: ELEMENT_PARAGRAPH, children: [{ text: "" }] }];
const Plugins = ({
type ctx = "channel" | "user";
type Props = {
updateDraft: (draft: any) => void | null;
initialValue?: any;
id: `${ctx}_${number}`;
placeholder: string;
sendMessages: any;
members: number[];
};
const Plugins: FC<Props> = ({
updateDraft = null,
initialValue = initials,
id = "",
id,
placeholder = "Write some markdown...",
sendMessages,
members = []
+1 -2
View File
@@ -62,7 +62,6 @@ export default function useStreaming() {
} = store.getState();
let api_token = token;
const tokenAlmostExpire = dayjs().isAfter(new Date(expireTime - 20 * 1000));
console.log("check token expire time", tokenAlmostExpire);
if (tokenAlmostExpire) {
const resp = await renewToken({
token,
@@ -285,7 +284,7 @@ export default function useStreaming() {
},
onerror(err) {
initializing = false;
if (err instanceof FatalError) {
if (err instanceof FatalError || err.toString().indexOf("network error") > -1) {
console.log("sse debug: error fatal", err);
throw err; // rethrow to stop the operation
} else {
+3 -4
View File
@@ -26,7 +26,7 @@ import HomePage from "./home";
import ChatPage from "./chat";
import Loading from "../common/component/Loading";
import store, { useAppSelector } from "../app/store";
let toastId: string;
const PageRoutes = () => {
const {
ui: { online },
@@ -37,10 +37,9 @@ const PageRoutes = () => {
// 掉线检测
useEffect(() => {
let toastId = "0";
if (!online) {
toast.error("Network Offline!", { duration: Infinity });
} else {
toastId = toast.error("Network Offline!", { duration: Infinity });
} else if (toastId) {
toast.dismiss(toastId);
}
}, [online]);
+1 -1
View File
@@ -23,7 +23,7 @@ export default function ConfigAgora() {
return { ...prev, [type]: newValue };
});
};
// if (!values) return null;
if (!values) return null;
const {
url,
project_id,