Fix Chunter infinite spinner. (#2585)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-02-03 19:23:19 +07:00 committed by GitHub
parent 31c5504be4
commit e789207138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 5 deletions

View File

@ -210,8 +210,12 @@
async function onMessage (event: CustomEvent) {
loading = true
await createAttachments()
dispatch('message', { message: event.detail, attachments: attachments.size })
try {
await createAttachments()
dispatch('message', { message: event.detail, attachments: attachments.size })
} finally {
loading = false
}
}
async function onUpdate (event: CustomEvent) {

View File

@ -75,6 +75,7 @@
_id = generateId()
isScrollForced = true
loading = false
}
function openThread (_id: Ref<Message>) {
@ -106,6 +107,7 @@
savedAttachmentsQuery.query(attachment.class.SavedAttachments, {}, (res) => {
savedAttachmentsIds = res.map((r) => r.attachedTo)
})
let loading = false
</script>
<PinnedMessages {space} {pinnedIds} />
@ -120,7 +122,7 @@
{savedAttachmentsIds}
/>
<div class="reference">
<AttachmentRefInput {space} {_class} objectId={_id} on:message={onMessage} />
<AttachmentRefInput bind:loading {space} {_class} objectId={_id} on:message={onMessage} />
</div>
<style lang="scss">

View File

@ -147,5 +147,5 @@
{shouldSaveDraft}
on:message={onMessage}
on:update={onUpdate}
{loading}
bind:loading
/>

View File

@ -165,6 +165,7 @@
attachments: newAttachments
})
isEditing = false
loading = false
}
function getEmployee (message: WithLookup<ChunterMessage>): Employee | undefined {
@ -245,6 +246,7 @@
})
return res
}
let loading = false
</script>
<div class="container" class:highlighted={isHighlighted} id={message._id}>
@ -270,6 +272,7 @@
content={message.content}
showSend={false}
on:message={onMessageEdit}
bind:loading
/>
<div class="flex-row-reverse gap-2 reverse">
<Button label={chunter.string.EditCancel} on:click={() => (isEditing = false)} />

View File

@ -157,12 +157,14 @@
await createBacklinks(client, parent.space, chunter.class.ChunterSpace, commentId, message)
commentId = generateId()
loading = false
}
let comments: ThreadMessage[] = []
async function getChannel (_id: Ref<ChunterSpace>): Promise<ChunterSpace | undefined> {
return await client.findOne(chunter.class.ChunterSpace, { _id })
}
let loading = false
</script>
<div class="ml-8 mt-4">
@ -202,6 +204,7 @@
_class={chunter.class.ThreadMessage}
objectId={commentId}
on:message={onMessage}
bind:loading
/>
</div>
{/if}

View File

@ -172,6 +172,7 @@
commentId = generateId()
isScrollForced = true
loading = false
}
let comments: ThreadMessage[] = []
@ -193,6 +194,7 @@
}
}
let newMessagesPos: number = -1
let loading = false
</script>
<div class="header">
@ -234,6 +236,7 @@
_class={chunter.class.ThreadMessage}
objectId={commentId}
on:message={onMessage}
bind:loading
/>
</div>

View File

@ -62,7 +62,7 @@
<div class:editing class="content-accent-color">
{#if edit}
<AttachmentRefInput
{loading}
bind:loading
bind:this={refInput}
_class={value._class}
objectId={value._id}

View File

@ -71,6 +71,7 @@
// We need to update backlinks before and after.
await updateBacklinks(client, value.attachedTo, value.attachedToClass, value._id, message)
refInput.submit()
loading = false
}
function commentIsEmpty (message: string, attachments: number | undefined): boolean {
@ -97,6 +98,7 @@
disabled
}
]
let loading = false
</script>
{#if value.status === RequestStatus.Active}
@ -111,6 +113,7 @@
on:update={onUpdate}
placeholder={request.string.PleaseTypeMessage}
extraActions={approvable ? extraActions : undefined}
bind:loading
/>
</div>
{/if}

View File

@ -128,6 +128,7 @@
)
objectId = generateId()
loading = false
}
function getName (message: TelegramMessage, accounts: EmployeeAccount[]): string {
@ -185,6 +186,7 @@
})
}
}
let loading = false
</script>
{#if object !== undefined}
@ -270,6 +272,7 @@
_class={telegram.class.NewMessage}
{objectId}
on:message={onMessage}
bind:loading
/>
{/if}
</div>