refactor: SEE

This commit is contained in:
Tristan Yang
2024-03-15 21:56:41 +08:00
parent 6e0f225d1c
commit d13b7f86b7
10 changed files with 1936 additions and 1659 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import i18n from "../i18n";
import { Price } from "../types/common";
let prices: Price[] = [
const prices: Price[] = [
{
type: "payment",
limit: 999999,
@@ -13,7 +13,7 @@ let prices: Price[] = [
];
const official_dev = `https://dev.voce.chat`;
const local_dev = `https://dev.voce.chat`;
// const local_dev = `http://localhost:3000`;
// const local_dev = `https://cqvoce.com`;
const dev_origin = process.env.REACT_APP_OFFICIAL_DEMO ? official_dev : local_dev;
// const local_dev = `https://im.ttt.td`;
+2 -1
View File
@@ -6,12 +6,13 @@ function useChatScroll<T extends HTMLElement>() {
if (ref.current) {
const ele = ref.current;
const resizeObserver = new ResizeObserver((entries) => {
for (let entry of entries) {
for (const entry of entries) {
entry.target.scrollTop = entry.target.scrollHeight;
}
});
resizeObserver.observe(ele);
// window.addEventListener("error", (e) => console.log(e.message));
}
}, []);
return ref;
-2
View File
@@ -1,5 +1,3 @@
// just for debug performance problem
// import "./wdyr";
import { Suspense } from "react";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
+2 -2
View File
@@ -10,7 +10,7 @@ export interface ChatSession {
id: number;
mid?: number;
}
type Props = {};
type Props = Record<string, never>;
const SessionList: FC<Props> = () => {
const [sessions, setSessions] = useState<ChatSession[]>([]);
const readChannels = useAppSelector((store) => store.footprint.readChannels, shallowEqual);
@@ -26,7 +26,7 @@ const SessionList: FC<Props> = () => {
if (!mids || mids.length == 0) {
return { key: `channel_${id}`, unreads: 0, id, type: "channel" };
}
const mid = [...mids].sort().pop();
const mid = [...mids].sort((a, b) => +a - +b).pop();
return { key: `channel_${id}`, id, mid, type: "channel" };
});
const tmps = [...(cSessions as ChatSession[])].sort((a, b) => {
+6 -1
View File
@@ -17,6 +17,7 @@ import MagicLinkLogin from "./MagicLinkLogin";
import SignUpLink from "./SignUpLink";
import SocialLoginButtons from "./SocialLoginButtons";
import { shallowEqual } from "react-redux";
import useStreaming from "@/hooks/useStreaming";
const defaultInput = {
email: "",
@@ -26,6 +27,7 @@ export default function LoginPage() {
const { name: serverName, logo } = useAppSelector((store) => store.server, shallowEqual);
const { t } = useTranslation("auth");
const { t: ct } = useTranslation();
const { stopStreaming } = useStreaming();
const { data: enableSMTP, isLoading: loadingSMTPStatus } = useGetSMTPStatusQuery();
const [login, { isSuccess, isLoading, error }] = useLoginMutation();
const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery();
@@ -76,7 +78,7 @@ export default function LoginPage() {
"No associated account found, please contact user admin for an invitation link to join."
);
break;
// 451有解析错误,暂时先客户端处理
// 451 有解析错误,暂时先客户端处理
case "PARSING_ERROR":
break;
default:
@@ -88,6 +90,9 @@ export default function LoginPage() {
}, [error]);
useEffect(() => {
if (isSuccess) {
// 登录页不需要连 SSE(在这里处理可能不是最好的方式,但是能解决当前问题,暂时没找到更好的处理方式)
// 断开已有的 SSE
stopStreaming();
toast.success(ct("tip.login"));
// navigateTo("/");
}
-9
View File
@@ -1,9 +0,0 @@
/// <reference types="@welldone-software/why-did-you-render" />
import React from "react";
if (process.env.NODE_ENV === "development") {
const whyDidYouRender = require("@welldone-software/why-did-you-render");
whyDidYouRender(React, {
trackAllPureComponents: true
});
}