diff --git a/src/routes/idaa/(idaa)/archives/+layout.ts b/src/routes/idaa/(idaa)/archives/+layout.ts index d028b4ac..d4dbd029 100644 --- a/src/routes/idaa/(idaa)/archives/+layout.ts +++ b/src/routes/idaa/(idaa)/archives/+layout.ts @@ -16,7 +16,9 @@ export async function load({ fetch, params, parent }) { let ae_acct = data[account_id]; if (!ae_acct) { - console.warn(`ae IDAA Archives +layout.ts: Account ${account_id} not found in data. Initializing ghost acct.`); + console.warn( + `ae IDAA Archives +layout.ts: Account ${account_id} not found in data. Initializing ghost acct.` + ); ae_acct = { api: data.ae_api || {}, slct: { diff --git a/src/routes/idaa/(idaa)/archives/+page.svelte b/src/routes/idaa/(idaa)/archives/+page.svelte index e324c28d..970032b5 100644 --- a/src/routes/idaa/(idaa)/archives/+page.svelte +++ b/src/routes/idaa/(idaa)/archives/+page.svelte @@ -31,7 +31,12 @@ slct_trigger } from '$lib/stores/ae_stores'; import { core_func } from '$lib/ae_core/ae_core_functions'; - import { idaa_loc, idaa_sess, idaa_slct, idaa_trig } from '$lib/stores/ae_idaa_stores'; + import { + idaa_loc, + idaa_sess, + idaa_slct, + idaa_trig + } from '$lib/stores/ae_idaa_stores'; // import { archives_func } from '$lib/ae_archives/ae_archives_functions'; import Comp__archive_obj_li from './ae_idaa_comp__archive_obj_li.svelte'; @@ -109,7 +114,8 @@ allow_access: $ae_loc?.allow_access, last_cache_refresh: $ae_loc?.last_cache_refresh, last_cache_refresh_iso: last_cache_refresh_iso.toISOString(), - last_cache_refresh_locale: last_cache_refresh_iso.toLocaleString(), + last_cache_refresh_locale: + last_cache_refresh_iso.toLocaleString(), access_level: $ae_loc?.access_level, iframe: $ae_loc?.iframe // site_access_key: $ae_loc?.site_access_key, @@ -152,15 +158,20 @@ {#await lq__archive_obj_li}
- - Loading archives... + + Loading archives...
{:then} {#if $lq__archive_obj_li && $lq__archive_obj_li?.length} {:else}
-

No archives found.

+

+ No archives found. +

Archives will appear here once created.

diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte b/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte index 81e29895..2fc59528 100644 --- a/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte +++ b/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte @@ -65,16 +65,26 @@ let lq__archive_obj = $derived( liveQuery(async () => { if (log_lvl) { - console.log(`lq__archive_obj: archive_id = ${$idaa_slct?.archive_id}`); + console.log( + `lq__archive_obj: archive_id = ${$idaa_slct?.archive_id}` + ); } - let results = await db_archives.archive.get($idaa_slct?.archive_id ?? ''); // null or undefined does not reset things like '' does + let results = await db_archives.archive.get( + $idaa_slct?.archive_id ?? '' + ); // null or undefined does not reset things like '' does // Check if results are different than the current $idaa_slct.archive_obj if ($idaa_slct.archive_obj && results) { - if (JSON.stringify($idaa_slct.archive_obj) !== JSON.stringify(results)) { + if ( + JSON.stringify($idaa_slct.archive_obj) !== + JSON.stringify(results) + ) { $idaa_slct.archive_obj = { ...results }; if (log_lvl) { - console.log(`$idaa_slct.archive_obj = `, $idaa_slct.archive_obj); + console.log( + `$idaa_slct.archive_obj = `, + $idaa_slct.archive_obj + ); } } else { if (log_lvl) { @@ -101,20 +111,29 @@ // Dexie will automatically track these table accesses and re-run this query if they change. const [parent_archive, results] = await Promise.all([ db_archives.archive.get(archive_id), - db_archives.content.where('archive_id').equals(archive_id).toArray() + db_archives.content + .where('archive_id') + .equals(archive_id) + .toArray() ]); if (!results || results.length === 0) { - if (log_lvl) console.log('lq__archive_content_obj_li: No content records found in cache.'); + if (log_lvl) + console.log( + 'lq__archive_content_obj_li: No content records found in cache.' + ); return []; } // Determine sort mode from the parent archive configuration - const sort_mode = parent_archive?.cfg_json?.content_group_sort ?? 'ASC'; + const sort_mode = + parent_archive?.cfg_json?.content_group_sort ?? 'ASC'; const is_desc = sort_mode === 'DESC'; if (log_lvl) { - console.log(`lq__archive_content_obj_li: Sorting ${results.length} items using ${sort_mode} mode.`); + console.log( + `lq__archive_content_obj_li: Sorting ${results.length} items using ${sort_mode} mode.` + ); } // Apply multi-step in-memory sort to handle mixed directions (e.g. Group DESC + Sort ASC) @@ -124,17 +143,21 @@ if (is_desc) { // MODE: Newest First (DESC) - Typically used for years or chronological groupings - + // 1. Group (DESC) - e.g. Year "2024" should appear before "2023" if (groupA !== groupB) return groupB.localeCompare(groupA); // 2. Original Datetime (DESC) - Newer items within the same group first - const dateA = a.original_datetime ? new Date(a.original_datetime).getTime() : 0; - const dateB = b.original_datetime ? new Date(b.original_datetime).getTime() : 0; + const dateA = a.original_datetime + ? new Date(a.original_datetime).getTime() + : 0; + const dateB = b.original_datetime + ? new Date(b.original_datetime).getTime() + : 0; if (dateA !== dateB) return dateB - dateA; } else { // MODE: Standard (ASC) - Typically used for Parts, Chapters, or alphabetical groupings - + // 1. Group (ASC) - e.g. "Part 1" before "Part 2" if (groupA !== groupB) return groupA.localeCompare(groupB); } @@ -151,8 +174,12 @@ // 5. Fallback: Original Datetime ASC (if in Standard mode and manual sorts are equal) if (!is_desc) { - const dateA = a.original_datetime ? new Date(a.original_datetime).getTime() : 0; - const dateB = b.original_datetime ? new Date(b.original_datetime).getTime() : 0; + const dateA = a.original_datetime + ? new Date(a.original_datetime).getTime() + : 0; + const dateB = b.original_datetime + ? new Date(b.original_datetime).getTime() + : 0; if (dateA !== dateB) return dateA - dateB; } @@ -172,11 +199,16 @@ ); } // if ($idaa_slct.archive_content_id) { - let results = await db_archives.content.get($idaa_slct.archive_content_id ?? ''); // null or undefined does not reset things like '' does + let results = await db_archives.content.get( + $idaa_slct.archive_content_id ?? '' + ); // null or undefined does not reset things like '' does // Check if results are different than the current $idaa_slct.archive_content_obj if ($idaa_slct.archive_content_obj && results) { - if (JSON.stringify($idaa_slct.archive_content_obj) !== JSON.stringify(results)) { + if ( + JSON.stringify($idaa_slct.archive_content_obj) !== + JSON.stringify(results) + ) { $idaa_slct.archive_content_obj = { ...results }; if (log_lvl) { console.log( @@ -231,8 +263,8 @@ // .delete(); // console.log(`Deleted ${results} disabled archive content.`); - $idaa_prom.load__archive_content_obj_li = archives_func.load_ae_obj_li__archive_content( - { + $idaa_prom.load__archive_content_obj_li = + archives_func.load_ae_obj_li__archive_content({ api_cfg: $ae_api, for_obj_type: 'archive', for_obj_id: $idaa_slct.archive_id, @@ -242,8 +274,7 @@ order_by_li: $idaa_loc.archives.qry__order_by_li, try_cache: true, log_lvl: log_lvl - } - ); + }); } }); @@ -254,7 +285,9 @@ window.parent.postMessage(message, '*'); if ($ae_loc?.iframe) { - console.log('In iframe, sending message to parent window to scroll to top as well'); + console.log( + 'In iframe, sending message to parent window to scroll to top as well' + ); window.parent.postMessage({ scroll_to: 0 }, '*'); // This should be in pixels } } @@ -262,7 +295,9 @@ onDestroy(() => { log_lvl = 1; if (log_lvl) { - console.log(`Destroying archives page for archive_id: ${$idaa_slct?.archive_id}`); + console.log( + `Destroying archives page for archive_id: ${$idaa_slct?.archive_id}` + ); } let message = { archive_id: null }; @@ -338,10 +373,13 @@ max-w-full " > - + {#if $lq__archive_obj?.topic_name} {$lq__archive_obj?.topic_name} + {$lq__archive_obj?.topic_name} {/if} {#if $ae_loc.trusted_access && $lq__archive_obj?.hide} @@ -412,7 +450,8 @@

{#if $ae_loc.trusted_access} - {:else if $ae_loc.trusted_access && $idaa_loc.archives.qry__hidden != 'not_hidden'} - {/if} {#if $ae_loc.edit_mode && $ae_loc.administrator_access && (!$idaa_loc.archives.qry__enabled || $idaa_loc.archives.qry__enabled == 'enabled')} - {:else if $ae_loc.administrator_access && $idaa_loc.archives.qry__enabled != 'enabled'} - {/if}
- -

-