diff --git a/src/app/components/Chat.svelte b/src/app/components/Chat.svelte index 91853ab..25f9db4 100644 --- a/src/app/components/Chat.svelte +++ b/src/app/components/Chat.svelte @@ -33,7 +33,7 @@ import ProfileList from "@app/components/ProfileList.svelte" import ChatMessage from "@app/components/ChatMessage.svelte" import ChatCompose from "@app/components/ChannelCompose.svelte" - import {deriveChat, splitChatId, PLATFORM_NAME, pubkeyLink} from "@app/state" + import {userSettingValues, deriveChat, splitChatId, PLATFORM_NAME, pubkeyLink} from "@app/state" import {pushModal} from "@app/modal" import {sendWrapped} from "@app/commands" @@ -57,7 +57,7 @@ const onSubmit = async ({content, ...params}: EventContent) => { const tags = [...params.tags, ...remove($pubkey!, pubkeys).map(tagPubkey)] const template = createEvent(DIRECT_MESSAGE, {content, tags}) - const thunk = await sendWrapped({template, pubkeys, delay: 3000}) + const thunk = await sendWrapped({template, pubkeys, delay: $userSettingValues.send_delay}) thunks.update(assoc(thunk.thunks[0].event.id, thunk)) } diff --git a/src/app/components/ThunkStatus.svelte b/src/app/components/ThunkStatus.svelte index ef35fd8..0d3472a 100644 --- a/src/app/components/ThunkStatus.svelte +++ b/src/app/components/ThunkStatus.svelte @@ -7,6 +7,7 @@ import Tippy from "@lib/components/Tippy.svelte" import Button from "@lib/components/Button.svelte" import ThunkStatusDetail from "@app/components/ThunkStatusDetail.svelte" + import {userSettingValues} from '@app/state' export let thunk: Thunk | MergedThunk @@ -20,12 +21,22 @@ : publishThunk((thunk as Thunk).request) } + let isPending = true + $: status = throttled(300, thunk.status) $: ps = Object.values($status) - $: canCancel = ps.length === 0 + $: canCancel = ps.length === 0 && $userSettingValues.send_delay > 0 $: isFailure = !canCancel && ps.every(s => [Failure, Timeout].includes(s.status)) - $: isPending = !isFailure && ps.some(s => s.status === Pending) $: failure = Object.entries($status).find(([url, s]) => [Failure, Timeout].includes(s.status)) + + $: { + // Delay updating isPending so users can see that the message is sent + if (isFailure || !ps.some(s => s.status == Pending)) { + setTimeout(() => { + isPending = false + }, 2000) + } + }