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)
broadcastUserData([url])
goto(makeSpacePath(url), {replaceState: true})
relaysMostlyRestricted.update(dissoc(url))
goto(makeSpacePath(url), {replaceState: true})
pushToast({message: "Welcome to the space!"})
}
</script>
+11 -9
View File
@@ -58,14 +58,18 @@ export const trustPolicy = (socket: Socket) => {
export const mostlyRestrictedPolicy = (socket: Socket) => {
let total = 0
let restricted = 0
let error = ""
const pending = new Set<string>()
const updateStatus = () =>
relaysMostlyRestricted.update(
restricted > total / 2 ? assoc(socket.url, error) : dissoc(socket.url),
)
const updateStatus = (error?: string) => {
if (restricted > total / 2) {
if (error) {
return relaysMostlyRestricted.update(assoc(socket.url, error))
}
} else {
relaysMostlyRestricted.update(dissoc(socket.url))
}
}
const unsubscribers = [
on(socket, SocketEvent.Receive, (message: RelayMessage) => {
@@ -83,8 +87,7 @@ export const mostlyRestrictedPolicy = (socket: Socket) => {
if (details.startsWith("restricted: ")) {
restricted++
error = details
updateStatus()
updateStatus(details)
}
}
}
@@ -103,8 +106,7 @@ export const mostlyRestrictedPolicy = (socket: Socket) => {
if (details.startsWith("restricted: ")) {
restricted++
error = details
updateStatus()
updateStatus(details)
}
}
}