Fix access restricted after successful invite code

This commit is contained in:
Jon Staab
2025-11-10 15:24:11 -08:00
parent 761e369313
commit e7a2535ece
2 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -10,8 +10,8 @@
await addSpaceMembership(url) await addSpaceMembership(url)
broadcastUserData([url]) broadcastUserData([url])
goto(makeSpacePath(url), {replaceState: true})
relaysMostlyRestricted.update(dissoc(url)) relaysMostlyRestricted.update(dissoc(url))
goto(makeSpacePath(url), {replaceState: true})
pushToast({message: "Welcome to the space!"}) pushToast({message: "Welcome to the space!"})
} }
</script> </script>
+11 -9
View File
@@ -58,14 +58,18 @@ export const trustPolicy = (socket: Socket) => {
export const mostlyRestrictedPolicy = (socket: Socket) => { export const mostlyRestrictedPolicy = (socket: Socket) => {
let total = 0 let total = 0
let restricted = 0 let restricted = 0
let error = ""
const pending = new Set<string>() const pending = new Set<string>()
const updateStatus = () => const updateStatus = (error?: string) => {
relaysMostlyRestricted.update( if (restricted > total / 2) {
restricted > total / 2 ? assoc(socket.url, error) : dissoc(socket.url), if (error) {
) return relaysMostlyRestricted.update(assoc(socket.url, error))
}
} else {
relaysMostlyRestricted.update(dissoc(socket.url))
}
}
const unsubscribers = [ const unsubscribers = [
on(socket, SocketEvent.Receive, (message: RelayMessage) => { on(socket, SocketEvent.Receive, (message: RelayMessage) => {
@@ -83,8 +87,7 @@ export const mostlyRestrictedPolicy = (socket: Socket) => {
if (details.startsWith("restricted: ")) { if (details.startsWith("restricted: ")) {
restricted++ restricted++
error = details updateStatus(details)
updateStatus()
} }
} }
} }
@@ -103,8 +106,7 @@ export const mostlyRestrictedPolicy = (socket: Socket) => {
if (details.startsWith("restricted: ")) { if (details.startsWith("restricted: ")) {
restricted++ restricted++
error = details updateStatus(details)
updateStatus()
} }
} }
} }