Fix access restricted after successful invite code
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user