{#if chatList && chatList.length > 0}
{#if showUserInfo} {#if onSort}
onSort?.('user_name')} >
{$i18n.t('User')} {#if orderBy === 'user_name'}
{#if direction === 'asc'}
{:else}
{/if}
{:else}
{/if}
{:else}
{$i18n.t('User')}
{/if} {/if} {#if onSort}
onSort?.('title')} >
{$i18n.t('Title')} {#if orderBy === 'title'}
{#if direction === 'asc'}
{:else}
{/if}
{:else}
{/if}
onSort?.('updated_at')} >
{$i18n.t('Updated at')} {#if orderBy === 'updated_at'}
{#if direction === 'asc'}
{:else}
{/if}
{:else}
{/if}
{:else}
{$i18n.t('Title')}
{$i18n.t('Updated at')}
{/if}
{/if}
{#if loading && (!chatList || chatList.length === 0)}
{:else if !chatList || chatList.length === 0}
{$i18n.t(emptyMessage)}
{:else} {#each chatList as chat, idx (chat.id)} {#if chat.time_range && (idx === 0 || chat.time_range !== chatList[idx - 1]?.time_range)}
{$i18n.t(chat.time_range)}
{/if}
{#if showUserInfo && chat.user_id}
{chat.user_name || 'Unknown'}
{/if}
onChatClick?.(chat.id)} >
{chat.title}
{dayjs(chat.updated_at * 1000).calendar(null, { sameDay: '[Today] h:mm A', lastDay: '[Yesterday] h:mm A', lastWeek: 'MMM D', sameElse: 'MMM D, YYYY' })}
{/each} {#if !allLoaded && onLoadMore}
{ if (!loading) { onLoadMore(); } }} >
{$i18n.t('Loading...')}
{/if} {/if}