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) { async function onMessage (event: CustomEvent) {
loading = true loading = true
await createAttachments() try {
dispatch('message', { message: event.detail, attachments: attachments.size }) await createAttachments()
dispatch('message', { message: event.detail, attachments: attachments.size })
} finally {
loading = false
}
} }
async function onUpdate (event: CustomEvent) { async function onUpdate (event: CustomEvent) {

View File

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

View File

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

View File

@ -165,6 +165,7 @@
attachments: newAttachments attachments: newAttachments
}) })
isEditing = false isEditing = false
loading = false
} }
function getEmployee (message: WithLookup<ChunterMessage>): Employee | undefined { function getEmployee (message: WithLookup<ChunterMessage>): Employee | undefined {
@ -245,6 +246,7 @@
}) })
return res return res
} }
let loading = false
</script> </script>
<div class="container" class:highlighted={isHighlighted} id={message._id}> <div class="container" class:highlighted={isHighlighted} id={message._id}>
@ -270,6 +272,7 @@
content={message.content} content={message.content}
showSend={false} showSend={false}
on:message={onMessageEdit} on:message={onMessageEdit}
bind:loading
/> />
<div class="flex-row-reverse gap-2 reverse"> <div class="flex-row-reverse gap-2 reverse">
<Button label={chunter.string.EditCancel} on:click={() => (isEditing = false)} /> <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) await createBacklinks(client, parent.space, chunter.class.ChunterSpace, commentId, message)
commentId = generateId() commentId = generateId()
loading = false
} }
let comments: ThreadMessage[] = [] let comments: ThreadMessage[] = []
async function getChannel (_id: Ref<ChunterSpace>): Promise<ChunterSpace | undefined> { async function getChannel (_id: Ref<ChunterSpace>): Promise<ChunterSpace | undefined> {
return await client.findOne(chunter.class.ChunterSpace, { _id }) return await client.findOne(chunter.class.ChunterSpace, { _id })
} }
let loading = false
</script> </script>
<div class="ml-8 mt-4"> <div class="ml-8 mt-4">
@ -202,6 +204,7 @@
_class={chunter.class.ThreadMessage} _class={chunter.class.ThreadMessage}
objectId={commentId} objectId={commentId}
on:message={onMessage} on:message={onMessage}
bind:loading
/> />
</div> </div>
{/if} {/if}

View File

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

View File

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

View File

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

View File

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