{#if !embedded}
{$i18n.t('Comments')}{#if total !== null && total > 0}
{total}
{/if}
{/if} {#if modal && resource && title}
{$i18n.t(resourceLabels[resource.resource_type])}
{title}
{/if}
{#if loading}
{/if} {#if error}
{error}
{$i18n.t('Retry')}
{/if} {#if resource && !loading} {#if !items.length}
{$i18n.t('No comments yet')}
{/if} {#each items as comment (comment.id)}
{#if replyTo?.id === comment.id}
{#key replyTo.id}
(replyTo = null)} onSubmitted={(id) => { if (replyTo?.id === id) replyTo = null; }} onPosted={postedReply} />{/key}
{/if}
(replyTo = null)} onSubmitted={(id) => { if (replyTo?.id === id) replyTo = null; }} onPosted={postedReply} linkedCommentId={linkedRootId === comment.id && linkedCommentId !== comment.id ? linkedCommentId : null} onReply={reply} onChange={refresh} onError={fail} onLoaded={revealInitialPosition} />
{/each} {#if cursor}
{$i18n.t('Load more')}
{/if} {/if}
{#if resource && !loading}
{#key `${resourceQuery(resource)}:${composerVersion}`}
{ composerVersion++; await tick(); if (alive) composer?.focus(); if (alive && linkedCommentId) document .getElementById(`comment-${linkedCommentId}`) ?.scrollIntoView({ block: 'nearest' }); }} {resource} draftKey={`${$user?.id}:${resourceQuery(resource)}:root`} contextLabel={view.target_id ? $i18n.t( view.target_type === 'note_page' ? 'Comment on this page' : 'Comment on this message' ) : ''} quote={view.anchor?.quote ?? ''} onClearContext={clearContext} onSubmit={async (content, temp_id) => { const created = await commentsRequest
('/', 'POST', { ...resource, content, temp_id, target_type: view.target_type, target_id: view.target_id, anchor: view.anchor }); if (!alive) return; linkedRootId = created.id; linkedCommentId = created.id; clearContext(); await refresh(); }} /> {/key}
{/if}