UBER-787 Add loading spinner for support button (#3691)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2023-09-14 10:28:28 +07:00 committed by GitHub
parent 8b1a488725
commit af94b640c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 7 deletions

View File

@ -15,20 +15,33 @@
<script lang="ts">
import type { Asset, IntlString } from '@hcengineering/platform'
import type { AnySvelteComponent } from '@hcengineering/ui'
import { Icon, tooltip } from '@hcengineering/ui'
import { Icon, Loading, tooltip } from '@hcengineering/ui'
export let label: IntlString
export let icon: Asset | AnySvelteComponent
export let selected: boolean = false
export let size: 'small' | 'medium' | 'large' = 'large'
export let loading: boolean = false
export let notify: boolean = false
</script>
<button class="app {size}" class:selected id={'app-' + label} use:tooltip={{ label }} on:click>
<div class="flex-center icon-container" class:noty={notify}>
<Icon {icon} size={size === 'small' ? 'small' : 'medium'} />
</div>
{#if notify}<div class="marker" />{/if}
<button
class="app {size}"
class:loading
class:selected
id={'app-' + label}
disabled={loading}
use:tooltip={{ label }}
on:click
>
{#if loading}
<Loading />
{:else}
<div class="flex-center icon-container" class:noty={notify}>
<Icon {icon} size={size === 'small' ? 'small' : 'medium'} />
</div>
{#if notify}<div class="marker" />{/if}
{/if}
</button>
<style lang="scss">
@ -42,6 +55,10 @@
cursor: pointer;
outline: none;
&.loading {
pointer-events: none;
}
&.large {
width: 2.25rem;
height: 2.25rem;

View File

@ -590,6 +590,19 @@
await supportClient?.then((support) => support.destroy())
})
let supportWidgetLoading = false
async function handleToggleSupportWidget (): Promise<void> {
const timer = setTimeout(() => {
supportWidgetLoading = true
}, 100)
const support = await supportClient
await support.toggleWidget()
clearTimeout(timer)
supportWidgetLoading = false
}
$: checkInbox($popupstore)
let inboxPopup: PopupResult | undefined = undefined
@ -682,7 +695,8 @@
size={appsMini ? 'small' : 'large'}
notify={supportStatus?.hasUnreadMessages}
selected={supportStatus?.visible}
on:click={() => client.toggleWidget()}
loading={supportWidgetLoading}
on:click={() => handleToggleSupportWidget()}
/>
{/if}
{/await}