chore: updates

This commit is contained in:
Tristan Yang
2024-04-02 10:06:20 +08:00
parent 828015eafa
commit 86d06f9d82
2 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vocechat-web",
"version": "0.7.5",
"version": "0.7.6",
"homepage": "https://voce.chat",
"dependencies": {
"@metamask/onboarding": "^1.0.1",
+8 -2
View File
@@ -46,6 +46,7 @@ import {
import { getLocalAuthData, isElectronContext } from "@/utils";
import chatMessageHandler from "./chat.handler";
import { shallowEqual } from "react-redux";
import { useLocation } from "react-router-dom";
const getQueryString = (params: { [key: string]: string }) => {
const sp = new URLSearchParams();
@@ -68,6 +69,7 @@ export default function useStreaming() {
const readUsers = useAppSelector((store) => store.footprint.readUsers, shallowEqual);
const readChannels = useAppSelector((store) => store.footprint.readChannels, shallowEqual);
const dispatch = useAppDispatch();
const { pathname } = useLocation();
const loginUid = user?.uid || 0;
const keepAlive = (timeout?: number) => {
@@ -452,13 +454,16 @@ export default function useStreaming() {
// const timeSpan = 60;
const timeSpan = 24 * 60 * 60;
// const timeSpan = 5;
const canReconnect = elapsedTime > timeSpan || !SSE;
const canReconnect = !guest && (elapsedTime > timeSpan || !SSE) && pathname !== "/login";
// const canReconnect = (elapsedTime > timeSpan || !SSE) && pathname !== "/login";
console.info(
"debug SSE: visibility changed elapsedTime",
elapsedTime,
pathname,
hiddenTime,
canReconnect,
!SSE
!SSE,
guest
);
// 超过 1 天或者已断线,强制重连
if (canReconnect) {
@@ -474,6 +479,7 @@ export default function useStreaming() {
}, 1500);
} else {
// 直接重连
console.info("debug SSE: stop directly and reconnect");
startStreaming();
}
}