refactor: revert socket reset workaround for adapter layer investigation
This commit is contained in:
+4
-24
@@ -23,7 +23,7 @@ import {
|
|||||||
getTagValue,
|
getTagValue,
|
||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
import type {Filter, TrustedEvent} 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 {
|
import {
|
||||||
pubkey,
|
pubkey,
|
||||||
loadRelay,
|
loadRelay,
|
||||||
@@ -70,10 +70,6 @@ type SyncOpts = {
|
|||||||
onEvent?: (event: TrustedEvent) => void
|
onEvent?: (event: TrustedEvent) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const resetRelaySocket = (url: string) => {
|
|
||||||
Pool.get().remove(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
const pullOneWithFallback = async (
|
const pullOneWithFallback = async (
|
||||||
url: string,
|
url: string,
|
||||||
filter: Filter,
|
filter: Filter,
|
||||||
@@ -275,15 +271,9 @@ const syncUserData = () => {
|
|||||||
const unsubscribeGroupList = derived([userGroupList, documentVisibility], identity).subscribe(
|
const unsubscribeGroupList = derived([userGroupList, documentVisibility], identity).subscribe(
|
||||||
([$userGroupList, $visibility]) => {
|
([$userGroupList, $visibility]) => {
|
||||||
if ($visibility === "hidden") {
|
if ($visibility === "hidden") {
|
||||||
const urls = new Set(Array.from(unsubscribersByKey.keys()).map(key => key.split("'")[0]))
|
|
||||||
|
|
||||||
unsubscribersByKey.forEach(call)
|
unsubscribersByKey.forEach(call)
|
||||||
unsubscribersByKey.clear()
|
unsubscribersByKey.clear()
|
||||||
|
|
||||||
for (const url of urls) {
|
|
||||||
resetRelaySocket(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,10 +367,6 @@ const syncSpaces = () => {
|
|||||||
const unsubscribe = store.subscribe(([$userGroupList, $page, $visibility]) => {
|
const unsubscribe = store.subscribe(([$userGroupList, $page, $visibility]) => {
|
||||||
if ($visibility === "hidden") {
|
if ($visibility === "hidden") {
|
||||||
// Hidden tabs should drop every live space subscription so we restart from a clean slate on wake.
|
// 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()) {
|
for (const unsubscribe of unsubscribersByUrl.values()) {
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
}
|
}
|
||||||
@@ -402,7 +388,6 @@ const syncSpaces = () => {
|
|||||||
unsubscribersByUrl.delete(url)
|
unsubscribersByUrl.delete(url)
|
||||||
roomsByUrl.delete(url)
|
roomsByUrl.delete(url)
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
resetRelaySocket(url)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,9 +407,8 @@ const syncSpaces = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
for (const [url, unsubscriber] of unsubscribersByUrl.entries()) {
|
for (const unsubscriber of unsubscribersByUrl.values()) {
|
||||||
unsubscriber()
|
unsubscriber()
|
||||||
resetRelaySocket(url)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsubscribe()
|
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.
|
// Late relay-list promises can resolve after a hide/show cycle, so keep the last visible state here.
|
||||||
let currentVisibility: DocumentVisibilityState = "visible"
|
let currentVisibility: DocumentVisibilityState = "visible"
|
||||||
|
|
||||||
const unsubscribeAll = (resetSockets = false) => {
|
const unsubscribeAll = () => {
|
||||||
for (const [url, unsubscribe] of unsubscribersByUrl.entries()) {
|
for (const [url, unsubscribe] of unsubscribersByUrl.entries()) {
|
||||||
unsubscribersByUrl.delete(url)
|
unsubscribersByUrl.delete(url)
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|
||||||
if (resetSockets) {
|
|
||||||
resetRelaySocket(url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,7 +500,7 @@ const syncDMs = () => {
|
|||||||
currentVisibility = $visibility
|
currentVisibility = $visibility
|
||||||
|
|
||||||
if ($visibility === "hidden") {
|
if ($visibility === "hidden") {
|
||||||
unsubscribeAll(true)
|
unsubscribeAll()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user