Make send delay configurable
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex justify-end px-1 text-xs">
|
||||
|
||||
Reference in New Issue
Block a user