(fix): connections
Some checks failed
/ build-web (push) Failing after 1m0s
/ build-desktop (linux) (push) Failing after 1m13s
/ build-mobile (push) Failing after 1m13s
/ release (push) Has been skipped

This commit is contained in:
Alois 2026-07-28 12:45:08 +02:00
commit 676dea2aa4
Signed by: alois
SSH key fingerprint: SHA256:GBzT2DXvAuGV9XIV5W3WrzVpjU54FThmxHXdbz95J24
7 changed files with 92 additions and 127 deletions

View file

@ -27,7 +27,6 @@ import { log } from "@tensamin/shared/log";
import { useStorage } from "@tensamin/storage/context";
import {
PING_INTERVAL,
RECONNECT_RESET,
RECONNECT_TRIES,
RETRY_INTERVAL,
@ -77,8 +76,6 @@ type ContextType = {
subscribePush: (handler: PushHandler) => () => void;
addInterceptor: (interceptor: MTPInterceptor) => () => void;
readyState: number;
ownPing: number;
iotaPing: number;
identified: boolean;
freshContacts: Contacts;
freshCommunities: Communities;
@ -152,9 +149,6 @@ export function Provider(props: {
const [identified, setIdentified] = useState<boolean>(false);
const [identifying, setIdentifying] = useState<boolean>(false);
const [ownPing, setOwnPing] = useState<number>(0);
const [iotaPing, setIotaPing] = useState<number>(0);
const [freshCommunities, setFreshCommunities] = useState<Communities>([]);
const [freshContacts, setFreshContacts] = useState<Contacts>([]);
const [freshCalls, setFreshCalls] = useState<Calls>([]);
@ -232,32 +226,6 @@ export function Provider(props: {
return () => interceptorsRef.current.delete(interceptor);
}, []);
// Custom Pings
useEffect(() => {
if (!connected || !identified) {
return;
}
const interval = setInterval(async () => {
try {
const originalNow = Date.now();
const data = await send("ClientPing", { LastPing: originalNow });
setOwnPing(Date.now() - originalNow);
const remotePing = data.data.PingIota;
if (typeof remotePing === "number") {
setIotaPing(remotePing);
}
} catch (intervalError) {
log(1, "mtp", "yellow", "Ping failed", intervalError);
}
}, PING_INTERVAL);
return () => {
clearInterval(interval);
};
}, [connected, identified, send]);
// Reconnect stuff
const resolveConnectionRef = useRef(() => {});
useEffect(() => {
@ -619,8 +587,6 @@ export function Provider(props: {
subscribePush,
addInterceptor,
readyState,
ownPing,
iotaPing,
identified,
freshContacts,
freshCommunities,