mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-24 22:52:09 -05:00
fix: bump revolt.js and add pong timeout
This commit is contained in:
parent
dfd9043ca0
commit
a5a6833c2c
4 changed files with 10 additions and 35 deletions
|
@ -144,7 +144,7 @@
|
|||
"react-virtualized-auto-sizer": "^1.0.5",
|
||||
"react-virtuoso": "^1.10.4",
|
||||
"revolt-api": "0.5.3-alpha.10",
|
||||
"revolt.js": "5.2.2",
|
||||
"revolt.js": "5.2.3",
|
||||
"rimraf": "^3.0.2",
|
||||
"sass": "^1.35.1",
|
||||
"shade-blend-color": "^1.0.0",
|
||||
|
|
|
@ -7,13 +7,6 @@ import Auth from "../../mobx/stores/Auth";
|
|||
import { resetMemberSidebarFetched } from "../../components/navigation/right/MemberSidebar";
|
||||
import { ClientStatus } from "./RevoltClient";
|
||||
|
||||
export let preventReconnect = false;
|
||||
let preventUntil = 0;
|
||||
|
||||
export function setReconnectDisallowed(allowed: boolean) {
|
||||
preventReconnect = allowed;
|
||||
}
|
||||
|
||||
export function registerEvents(
|
||||
auth: Auth,
|
||||
setStatus: StateUpdater<ClientStatus>,
|
||||
|
@ -21,28 +14,10 @@ export function registerEvents(
|
|||
) {
|
||||
if (!client) return;
|
||||
|
||||
function attemptReconnect() {
|
||||
if (preventReconnect) return;
|
||||
function reconnect() {
|
||||
preventUntil = +new Date() + 2000;
|
||||
client.websocket.connect().catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
if (+new Date() > preventUntil) {
|
||||
setTimeout(reconnect, 2000);
|
||||
} else {
|
||||
reconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let listeners: Record<string, (...args: any[]) => void> = {
|
||||
connecting: () => setStatus(ClientStatus.CONNECTING),
|
||||
|
||||
dropped: () => {
|
||||
setStatus(ClientStatus.DISCONNECTED);
|
||||
attemptReconnect();
|
||||
},
|
||||
dropped: () => setStatus(ClientStatus.DISCONNECTED),
|
||||
|
||||
ready: () => {
|
||||
resetMemberSidebarFetched();
|
||||
|
@ -73,14 +48,13 @@ export function registerEvents(
|
|||
|
||||
const online = () => {
|
||||
setStatus(ClientStatus.RECONNECTING);
|
||||
setReconnectDisallowed(false);
|
||||
attemptReconnect();
|
||||
client.options.autoReconnect = false;
|
||||
client.websocket.connect();
|
||||
};
|
||||
|
||||
const offline = () => {
|
||||
setReconnectDisallowed(true);
|
||||
client.options.autoReconnect = false;
|
||||
client.websocket.disconnect();
|
||||
setStatus(ClientStatus.OFFLINE);
|
||||
};
|
||||
|
||||
window.addEventListener("online", online);
|
||||
|
|
|
@ -46,6 +46,7 @@ export default class ServerConfig
|
|||
autoReconnect: false,
|
||||
apiURL: import.meta.env.VITE_API_URL,
|
||||
debug: isDebug(),
|
||||
onPongTimeout: "RECONNECT",
|
||||
});
|
||||
|
||||
if (this.config !== null) {
|
||||
|
|
|
@ -3815,10 +3815,10 @@ revolt-api@^0.5.3-alpha.9:
|
|||
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-alpha.9.tgz#46e75b7d8f9c6702df39039b829dddbb7897f237"
|
||||
integrity sha512-L8K9uPV3ME8bLdtWm8L9iPQvFM0GghA+5LzmWFjd6Gbn56u22ZYub2lABi4iHrWgeA2X41dGSsuSBgHSlts9Og==
|
||||
|
||||
revolt.js@5.2.2:
|
||||
version "5.2.2"
|
||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.2.2.tgz#e6becef157722c4ce2c9668d7d2ed79188329f75"
|
||||
integrity sha512-KfU4goDKZJwb10z/kuDKq/J4xpBpcIXmBpzryeQPo/5UCxlc90OflPonPJKfp8d6ykSnZs95tLdB7AloUXpYxg==
|
||||
revolt.js@5.2.3:
|
||||
version "5.2.3"
|
||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.2.3.tgz#770e7fc3256d7d153fadf143acd00f4c3377f4ef"
|
||||
integrity sha512-tFGt1yij56A1y3EDjTf1HoPmwHskQ0xoks58tWNCPdMvyCyrTih9qBKdHNDDOMUWdGF0qn1pWZmdVSxHriAuOA==
|
||||
dependencies:
|
||||
"@insertish/exponential-backoff" "3.1.0-patch.0"
|
||||
"@insertish/isomorphic-ws" "^4.0.1"
|
||||
|
|
Loading…
Reference in a new issue