forked from coracle/flotilla
Wait for thunk errors
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
import type {Filter} from "@welshman/util"
|
import type {Filter} from "@welshman/util"
|
||||||
import {makeIntersectionFeed, makeRelayFeed, feedFromFilters} from "@welshman/feeds"
|
import {makeIntersectionFeed, makeRelayFeed, feedFromFilters} from "@welshman/feeds"
|
||||||
import {pubkey, signer, getThunkError} from "@welshman/app"
|
import {pubkey, signer, waitForThunkError} from "@welshman/app"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import FieldInline from "@lib/components/FieldInline.svelte"
|
import FieldInline from "@lib/components/FieldInline.svelte"
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
await attemptAuth(NOTIFIER_RELAY)
|
await attemptAuth(NOTIFIER_RELAY)
|
||||||
|
|
||||||
const thunk = await publishAlert(params)
|
const thunk = await publishAlert(params)
|
||||||
const error = await getThunkError(thunk)
|
const error = await waitForThunkError(thunk)
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return pushToast({
|
return pushToast({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import {goto} from "$app/navigation"
|
import {goto} from "$app/navigation"
|
||||||
import {uniqBy, nth} from "@welshman/lib"
|
import {uniqBy, nth} from "@welshman/lib"
|
||||||
import {displayRelayUrl, makeRoomMeta} from "@welshman/util"
|
import {displayRelayUrl, makeRoomMeta} from "@welshman/util"
|
||||||
import {deriveRelay, getThunkError, createRoom, editRoom, joinRoom} from "@welshman/app"
|
import {deriveRelay, waitForThunkError, createRoom, editRoom, joinRoom} from "@welshman/app"
|
||||||
import {preventDefault} from "@lib/html"
|
import {preventDefault} from "@lib/html"
|
||||||
import Field from "@lib/components/Field.svelte"
|
import Field from "@lib/components/Field.svelte"
|
||||||
import Spinner from "@lib/components/Spinner.svelte"
|
import Spinner from "@lib/components/Spinner.svelte"
|
||||||
@@ -24,19 +24,19 @@
|
|||||||
const tryCreate = async () => {
|
const tryCreate = async () => {
|
||||||
room.tags = uniqBy(nth(0), [...room.tags, ["name", name]])
|
room.tags = uniqBy(nth(0), [...room.tags, ["name", name]])
|
||||||
|
|
||||||
const createMessage = await getThunkError(createRoom(url, room))
|
const createMessage = await waitForThunkError(createRoom(url, room))
|
||||||
|
|
||||||
if (createMessage && !createMessage.match(/^duplicate:|already a member/)) {
|
if (createMessage && !createMessage.match(/^duplicate:|already a member/)) {
|
||||||
return pushToast({theme: "error", message: createMessage})
|
return pushToast({theme: "error", message: createMessage})
|
||||||
}
|
}
|
||||||
|
|
||||||
const editMessage = await getThunkError(editRoom(url, room))
|
const editMessage = await waitForThunkError(editRoom(url, room))
|
||||||
|
|
||||||
if (editMessage) {
|
if (editMessage) {
|
||||||
return pushToast({theme: "error", message: editMessage})
|
return pushToast({theme: "error", message: editMessage})
|
||||||
}
|
}
|
||||||
|
|
||||||
const joinMessage = await getThunkError(joinRoom(url, room))
|
const joinMessage = await waitForThunkError(joinRoom(url, room))
|
||||||
|
|
||||||
if (joinMessage && !joinMessage.includes("already")) {
|
if (joinMessage && !joinMessage.includes("already")) {
|
||||||
return pushToast({theme: "error", message: joinMessage})
|
return pushToast({theme: "error", message: joinMessage})
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||||
|
import {clearModals} from "@app/util/modal"
|
||||||
import {PROTECTED} from "@app/core/state"
|
import {PROTECTED} from "@app/core/state"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -31,6 +32,8 @@
|
|||||||
|
|
||||||
// Don't publish anywhere yet, wait until they join a space
|
// Don't publish anywhere yet, wait until they join a space
|
||||||
publishThunk({event, relays: []})
|
publishThunk({event, relays: []})
|
||||||
|
|
||||||
|
clearModals()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ import {
|
|||||||
dropSession,
|
dropSession,
|
||||||
tagEventForComment,
|
tagEventForComment,
|
||||||
tagEventForQuote,
|
tagEventForQuote,
|
||||||
getThunkError,
|
waitForThunkError,
|
||||||
} from "@welshman/app"
|
} from "@welshman/app"
|
||||||
import type {SettingsValues} from "@app/core/state"
|
import type {SettingsValues} from "@app/core/state"
|
||||||
import {
|
import {
|
||||||
@@ -249,7 +249,7 @@ export const checkRelayAccess = async (url: string, claim = "") => {
|
|||||||
await attemptAuth(url)
|
await attemptAuth(url)
|
||||||
|
|
||||||
const thunk = publishJoinRequest({url, claim})
|
const thunk = publishJoinRequest({url, claim})
|
||||||
const error = await getThunkError(thunk)
|
const error = await waitForThunkError(thunk)
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
const message =
|
const message =
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
ROOM_ADD_USER,
|
ROOM_ADD_USER,
|
||||||
ROOM_REMOVE_USER,
|
ROOM_REMOVE_USER,
|
||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
import {pubkey, publishThunk, getThunkError, joinRoom, leaveRoom} from "@welshman/app"
|
import {pubkey, publishThunk, waitForThunkError, joinRoom, leaveRoom} from "@welshman/app"
|
||||||
import {slide, fade, fly} from "@lib/transition"
|
import {slide, fade, fly} from "@lib/transition"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
joining = true
|
joining = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const message = await getThunkError(joinRoom(url, makeRoomMeta({id: room})))
|
const message = await waitForThunkError(joinRoom(url, makeRoomMeta({id: room})))
|
||||||
|
|
||||||
if (message && !message.startsWith("duplicate:")) {
|
if (message && !message.startsWith("duplicate:")) {
|
||||||
return pushToast({theme: "error", message})
|
return pushToast({theme: "error", message})
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
const leave = async () => {
|
const leave = async () => {
|
||||||
leaving = true
|
leaving = true
|
||||||
try {
|
try {
|
||||||
const message = await getThunkError(leaveRoom(url, makeRoomMeta({id: room})))
|
const message = await waitForThunkError(leaveRoom(url, makeRoomMeta({id: room})))
|
||||||
|
|
||||||
if (message && !message.startsWith("duplicate:")) {
|
if (message && !message.startsWith("duplicate:")) {
|
||||||
pushToast({theme: "error", message})
|
pushToast({theme: "error", message})
|
||||||
|
|||||||
Reference in New Issue
Block a user