refactor: revert socket reset workaround for adapter layer investigation

This commit is contained in:
2026-04-07 00:26:30 +05:30
committed by hodlbod
parent a5506689f7
commit e710fc2561
+4 -24
View File
@@ -23,7 +23,7 @@ import {
getTagValue,
} from "@welshman/util"
import type {Filter, TrustedEvent} from "@welshman/util"
import {request, requestOne, Difference, DifferenceEvent, Pool} from "@welshman/net"
import {request, requestOne, Difference, DifferenceEvent} from "@welshman/net"
import {
pubkey,
loadRelay,
@@ -70,10 +70,6 @@ type SyncOpts = {
onEvent?: (event: TrustedEvent) => void
}
const resetRelaySocket = (url: string) => {
Pool.get().remove(url)
}
const pullOneWithFallback = async (
url: string,
filter: Filter,
@@ -275,15 +271,9 @@ const syncUserData = () => {
const unsubscribeGroupList = derived([userGroupList, documentVisibility], identity).subscribe(
([$userGroupList, $visibility]) => {
if ($visibility === "hidden") {
const urls = new Set(Array.from(unsubscribersByKey.keys()).map(key => key.split("'")[0]))
unsubscribersByKey.forEach(call)
unsubscribersByKey.clear()
for (const url of urls) {
resetRelaySocket(url)
}
return
}
@@ -377,10 +367,6 @@ const syncSpaces = () => {
const unsubscribe = store.subscribe(([$userGroupList, $page, $visibility]) => {
if ($visibility === "hidden") {
// Hidden tabs should drop every live space subscription so we restart from a clean slate on wake.
for (const url of unsubscribersByUrl.keys()) {
resetRelaySocket(url)
}
for (const unsubscribe of unsubscribersByUrl.values()) {
unsubscribe()
}
@@ -402,7 +388,6 @@ const syncSpaces = () => {
unsubscribersByUrl.delete(url)
roomsByUrl.delete(url)
unsubscribe()
resetRelaySocket(url)
}
}
@@ -422,9 +407,8 @@ const syncSpaces = () => {
})
return () => {
for (const [url, unsubscriber] of unsubscribersByUrl.entries()) {
for (const unsubscriber of unsubscribersByUrl.values()) {
unsubscriber()
resetRelaySocket(url)
}
unsubscribe()
@@ -453,14 +437,10 @@ const syncDMs = () => {
// Late relay-list promises can resolve after a hide/show cycle, so keep the last visible state here.
let currentVisibility: DocumentVisibilityState = "visible"
const unsubscribeAll = (resetSockets = false) => {
const unsubscribeAll = () => {
for (const [url, unsubscribe] of unsubscribersByUrl.entries()) {
unsubscribersByUrl.delete(url)
unsubscribe()
if (resetSockets) {
resetRelaySocket(url)
}
}
}
@@ -520,7 +500,7 @@ const syncDMs = () => {
currentVisibility = $visibility
if ($visibility === "hidden") {
unsubscribeAll(true)
unsubscribeAll()
return
}