chore(cleanup): add journal AI shortcut and align posts tmp_sort

This commit is contained in:
Scott Idem
2026-06-02 14:43:16 -04:00
parent 84a9d0fffc
commit 1de87b6c5f
6 changed files with 64 additions and 32 deletions

View File

@@ -73,14 +73,14 @@ let lq__post_comment_obj_li = $derived.by(() => {
return liveQuery(async () => {
if (!post_id) return [];
// .reverse() before .sortBy() is a Dexie no-op — reverse the array after instead.
// tmp_sort_1 here uses legacy encoding (priority=true→'1') designed for DESC order.
// tmp_sort_1 is built with build_tmp_sort() and is designed for ASC sort:
// priority=true -> '0', so priority records naturally sort first.
const comments = await db_posts.comment
.where('post_id')
.equals(post_id)
.limit(limit)
.sortBy('tmp_sort_1');
return comments.reverse();
return comments;
});
});

View File

@@ -432,6 +432,20 @@ async function handle_force_reset() {
let show_append_modal = $state(false);
let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
function handle_show_ai_tools() {
show_config_modal = false;
if (typeof window === 'undefined') return;
const entry_id = $lq__journal_entry_obj?.journal_entry_id ?? 'default';
const ai_tools_anchor_id = `journal_entry_ai_tools_${entry_id}`;
queueMicrotask(() => {
const ai_tools_el = document.getElementById(ai_tools_anchor_id);
ai_tools_el?.scrollIntoView({ behavior: 'smooth', block: 'center' });
});
}
</script>
<div class="group/entry-view relative w-full min-w-0">
@@ -488,13 +502,16 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
? 'ring-primary-500/40 ring-2 ring-inset'
: ''}">
{#if $ae_loc.edit_mode && $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] === 'current'}
<AE_Comp_Journal_Entry_AiTools
content={typeof tmp_entry_obj.content === 'string'
? tmp_entry_obj.content
: ''}
bind:summary={tmp_entry_obj.summary}
on_save={() => update_journal_entry()}
{log_lvl} />
<div
id={`journal_entry_ai_tools_${$lq__journal_entry_obj?.journal_entry_id ?? 'default'}`}>
<AE_Comp_Journal_Entry_AiTools
content={typeof tmp_entry_obj.content === 'string'
? tmp_entry_obj.content
: ''}
bind:summary={tmp_entry_obj.summary}
on_save={() => update_journal_entry()}
{log_lvl} />
</div>
{/if}
<AE_Comp_Journal_Entry_Editor
@@ -539,6 +556,7 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
on_save={() => update_journal_entry()}
on_force_reset={handle_force_reset}
{on_show_export}
on_show_ai={handle_show_ai_tools}
on_append={() => {
modal_mode = 'append';
show_append_modal = true;

View File

@@ -37,6 +37,7 @@ interface Props {
on_save: () => void;
on_force_reset?: () => void;
on_show_export?: () => void;
on_show_ai?: () => void;
on_append?: () => void;
on_prepend?: () => void;
}
@@ -49,6 +50,7 @@ let {
on_save,
on_force_reset,
on_show_export,
on_show_ai,
on_append,
on_prepend
}: Props = $props();
@@ -254,6 +256,16 @@ async function handle_admin_delete_action() {
<FileDown size="1.2em" />
Export Entry
</button>
<button
type="button"
class="btn preset-tonal-primary w-full justify-start gap-2"
onclick={() => {
show = false;
on_show_ai?.();
}}>
<Zap size="1.2em" />
Summary AI
</button>
<button
type="button"
class="btn preset-tonal-surface w-full justify-start gap-2"