Work on LiveQuery

This commit is contained in:
Scott Idem
2024-07-02 09:33:16 -04:00
parent ed89c61aed
commit 40aba339f8
2 changed files with 48 additions and 23 deletions

View File

@@ -121,7 +121,7 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
datetime_string = dayjs(raw_datetime).format('dd');
break;
default:
console.log(`The named format passed (${named_format}) did not match a common name. Trying to format with the named format value.`);
// console.log(`The named format passed (${named_format}) did not match a common name. Trying to format with the named format value.`);
datetime_string = dayjs(raw_datetime).format(named_format);
// datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss');
}

View File

@@ -247,6 +247,15 @@ function handle_search__event_session(search_str: string) {
.finally(() => {
console.log('Search done.');
console.log(`test1: ${$lq_kv__event_session_obj_li}`);
event_session_id_random_li = [];
// We need to loop through the array of objects and get the event_session_id_random from each object a new list of event_session_id_randoms. Then we can use this list to get the full objects from the database.
for (let i = 0; i < $events_slct.event_session_obj_li.length; i++) {
event_session_id_random_li.push($events_slct.event_session_obj_li[i].event_session_id_random);
}
console.log(`event_session_id_random_li:`, event_session_id_random_li);
});
}, 250);
} else {
@@ -279,8 +288,7 @@ function handle_search__event_session(search_str: string) {
event_session_id_random_li = [];
// We need to loop through the array of objects and get the event_session_id_random from each object a new list
// of event_session_id_randoms. Then we can use this list to get the full objects from the database.
// We need to loop through the array of objects and get the event_session_id_random from each object a new list of event_session_id_randoms. Then we can use this list to get the full objects from the database.
for (let i = 0; i < $events_slct.event_session_obj_li.length; i++) {
event_session_id_random_li.push($events_slct.event_session_obj_li[i].event_session_id_random);
}
@@ -299,23 +307,6 @@ function handle_search__event_session(search_str: string) {
</script>
<!-- This is to help correct a bug(?) with Dexie and LiveQuery and Svelte -->
{#if event_session_id_random_li.length}
ID count:{event_session_id_random_li.length}
<!-- This needs to be in here so it works correctly with the liveQuery. -->
{#if $lq_kv__event_session_obj_li?.length}
Sess li: {$lq_kv__event_session_obj_li?.length}
<!-- {$lq_kv__event_session_obj_li?.map(session_obj => session_obj?.event_session_id_random)} -->
{:else}
<!-- No sess -->
x: {$lq_kv__event_session_obj_li}
{/if}
{:else}
No IDs found
{/if}
<section
class="ae_events_pres_mgmt_event md:container h-full mx-auto flex flex-col items-center space-y-2 pt-0 pb-8"
>
@@ -461,8 +452,8 @@ function handle_search__event_session(search_str: string) {
{/if}
{/await}
{#if $events_slct?.event_session_obj_li && $events_slct.event_session_obj_li.length > 0}
{#if $events_slct.event_session_obj_li?.length == event_session_id_random_li?.length && event_session_id_random_li.length == $lq_kv__event_session_obj_li?.length}
<!-- {#if $events_slct?.event_session_obj_li && $events_slct.event_session_obj_li.length > 0} -->
<section class="ae_h_scrollfix py-2 space-y-2">
<h2 class="h3">
<span class="text-md">
@@ -489,7 +480,7 @@ function handle_search__event_session(search_str: string) {
</tr>
</thead>
<tbody>
{#each $events_slct.event_session_obj_li as session_obj}
{#each $lq_kv__event_session_obj_li as session_obj}
<tr>
<td>
<a
@@ -709,8 +700,42 @@ function handle_search__event_session(search_str: string) {
<p class="text-center text-2xl bg-gray-100 p-4 rounded-md">
No results to show. Please use the search above to find your session.
</p>
<div>
Query results length: {$events_slct.event_session_obj_li?.length}
ID list length: {event_session_id_random_li?.length}
LQ results length: {$lq_kv__event_session_obj_li?.length}
</div>
{/if}
<!-- This is to help correct a bug(?) with Dexie and LiveQuery and Svelte. The LiveQuery value may not be updated if no results are found. This a problem on the very first run. -->
<!-- This needs to be in here so it works correctly with the liveQuery. -->
{#if $events_slct.event_session_obj_li?.length == event_session_id_random_li?.length && event_session_id_random_li.length == $lq_kv__event_session_obj_li?.length}
Count:
{event_session_id_random_li.length}
<!-- {$lq_kv__event_session_obj_li?.map(event_session_obj => event_session_obj?.event_session_id_random)} -->
<div>
{#each $lq_kv__event_session_obj_li as event_session_obj}
<span>
{event_session_obj?.event_session_id_random}
</span>
{/each}
</div>
{:else}
No match
{/if}
<!-- {#if event_session_id_random_li.length}
ID count: {event_session_id_random_li.length}
{#if $lq_kv__event_session_obj_li?.length}
Sessions: {$lq_kv__event_session_obj_li?.length}
{:else}
x: {$lq_kv__event_session_obj_li}
{/if}
{:else}
No IDs found
{/if} -->
</section>