{#if dragged && x && y}
{folders[folderId].name}
{/if}
{#if draggedOver}
{/if}
{ dispatch('open', state); }} >
{ e.stopPropagation(); e.stopImmediatePropagation(); open = !open; isExpandedUpdateDebounceHandler(); }} > {#if folders[folderId]?.meta?.icon}
{#if open}
{:else}
{/if}
{:else}
{#if open}
{:else}
{/if}
{/if}
{#if edit}
{ console.log('Blur'); updateHandler({ name }); edit = false; }} on:click={(e) => { // Prevent accidental collapse toggling when clicking inside input e.stopPropagation(); }} on:mousedown={(e) => { // Prevent accidental collapse toggling when clicking inside input e.stopPropagation(); }} on:keydown={(e) => { if (e.key === 'Enter') { e.currentTarget.blur(); } }} class="w-full h-full bg-transparent outline-hidden" /> {:else}
{ if (!isWritable || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return; if (clickTimer) { clearTimeout(clickTimer); // cancel the single-click action clickTimer = null; } renameHandler(); }} onclick={(e) => { openPreview = false; e.stopPropagation(); if (e.button !== 0 || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return; e.preventDefault(); if (clickTimer) { clearTimeout(clickTimer); clickTimer = null; } clickTimer = setTimeout(async () => { await openFolderHandler(); clickTimer = null; }, 100); // 100ms delay (typical double-click threshold) }} onkeydown={(e) => { if (e.currentTarget !== e.target) return; if (e.key === ' ' && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey) { e.preventDefault(); openFolderHandler(); } }} >
{folders[folderId].name}
{#if !folders[folderId]?.shared && (folders[folderId]?.unread_count ?? 0) > 0}
{formatUnreadCount(folders[folderId].unread_count)}
{/if}
{#if openPreview}
{ openPreview = false; showFolderModal = true; }} /> {/if}
{/if}
{#if isWritable}
(openPreview = false)} >
{ showFolderModal = true; }} onDelete={() => { showDeleteConfirm = true; }} onExport={() => { exportHandler(); }} onCreateSubFolder={() => { createSubFolderParentId = folderId; showCreateSubFolderModal = true; }} onMarkAllRead={markAllReadHandler} >
{/if}
{#if (folders[folderId]?.childrenIds ?? []).length > 0 || chats !== null || hasMoreChats || chatsLoading}
{#if folders[folderId]?.childrenIds} {@const children = folders[folderId]?.childrenIds .map((id) => folders[id]) .sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }) )} {#each children as childFolder (`${folderId}-${childFolder.id}`)}
{ dispatch('import', e.detail); }} on:update={(e) => { dispatch('update', e.detail); }} on:change={(e) => { dispatch('change', e.detail); }} /> {/each} {/if} {#if chats === null && chatsLoading}
{/if} {#if chats !== null && chats.length === 0 && !chatsLoading}
{$i18n.t('No chats')}
{/if} {#each chats ?? [] as chat (chat.id)}
{ dispatch('change', e.detail); }} /> {/each} {#if hasMoreChats}
setFolderItems(true)} > {#if chatsLoading}
{:else} {$i18n.t('Show more')} {/if}
{/if}
{/if}