I quite for the night! The presentation list shows now...

This commit is contained in:
Scott Idem
2024-08-08 20:42:04 -04:00
parent 14fc1ee146
commit 30e6384772
4 changed files with 121 additions and 31 deletions

View File

@@ -3,6 +3,8 @@ import { api } from '$lib/api';
import { db_events } from "$lib/db_events";
import { handle_load_ae_obj_li__event_presentation } from "$lib/ae_events__event_presentation";
let ae_promises: key_val = {};
@@ -11,11 +13,15 @@ export async function handle_load_ae_obj_id__event_session(
{
api_cfg,
event_session_id,
inc_file_li = false,
inc_presenter_li = false, // Actually presentations and presenters
try_cache = true,
log_lvl = 0
}: {
api_cfg: any,
event_session_id: string,
inc_file_li?: boolean,
inc_presenter_li?: boolean,
try_cache?: boolean,
log_lvl?: number
}
@@ -53,6 +59,41 @@ export async function handle_load_ae_obj_id__event_session(
console.log('No results returned or failed.', error);
});
if (inc_presenter_li) {
// Load the presentations for the session
if (log_lvl) {
console.log(`Need to load the presentation list now`);
}
let load_event_presentation_obj_li = handle_load_ae_obj_li__event_presentation({
api_cfg: api_cfg,
event_session_id: event_session_id,
params: {enabled: 'all', qry__limit: 15},
try_cache: try_cache,
log_lvl: log_lvl
})
.then((event_presentation_obj_li) => {
if (log_lvl) {
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
}
if (try_cache) {
ae_promises.load__event_session_obj.event_presentation_li = event_presentation_obj_li;
// Re-save the session object with the new presentation list
handle_db_save_ae_obj_li__event_session({
obj_type: 'event_session',
obj_li: ae_promises.load__event_session_obj
});
}
return event_presentation_obj_li;
});
if (log_lvl) {
console.log(`event_presentation_obj_li = `, load_event_presentation_obj_li);
}
ae_promises.load__event_session_obj.event_presentation_li = load_event_presentation_obj_li;
}
return ae_promises.load__event_session_obj;
}
@@ -63,6 +104,8 @@ export async function handle_load_ae_obj_li__event_session(
api_cfg,
for_obj_type,
for_obj_id,
inc_file_li = false,
inc_presenter_li = false, // Actually presentations and presenters
params={},
try_cache=true,
log_lvl=0
@@ -70,6 +113,8 @@ export async function handle_load_ae_obj_li__event_session(
api_cfg: any,
for_obj_type: string,
for_obj_id: string,
inc_file_li?: boolean,
inc_presenter_li?: boolean,
params?: key_val,
try_cache?: boolean,
log_lvl?: number
@@ -122,6 +167,40 @@ export async function handle_load_ae_obj_li__event_session(
if (log_lvl) {
console.log('ae_promises.load__event_session_obj_li:', ae_promises.load__event_session_obj_li);
}
if (inc_presenter_li) {
// Load the presentations for the sessions
for (let i = 0; i < ae_promises.load__event_session_obj_li.length; i++) {
let event_session_obj = ae_promises.load__event_session_obj_li[i];
let event_session_id = event_session_obj.event_session_id_random;
let load_event_presentation_obj_li = handle_load_ae_obj_li__event_presentation({
api_cfg: api_cfg,
event_session_id: event_session_id,
params: {enabled: 'all', qry__limit: 15},
try_cache: try_cache,
log_lvl: log_lvl
})
.then((event_presentation_obj_li) => {
if (try_cache) {
event_session_obj.event_presentation_li = event_presentation_obj_li;
// Re-save the session object with the new presentation list
handle_db_save_ae_obj_li__event_session({
obj_type: 'event_session',
obj_li: event_session_obj
});
}
});
if (log_lvl) {
console.log(`load_event_presentation_obj_li = `, load_event_presentation_obj_li);
}
// event_session_obj.event_presentation_li = load_event_presentation_obj_li;
}
}
return ae_promises.load__event_session_obj_li;
}
@@ -328,6 +407,7 @@ export function handle_db_save_ae_obj_li__event_session(
// A key value list of the presentations
event_presentation_kv: obj.event_presentation_kv,
event_presentation_li: obj.event_presentation_li,
});
// console.log(`Put obj with ID: ${obj.event_session_id_random} or ${id_random}`);
} catch (error) {

View File

@@ -370,8 +370,10 @@ export interface Session {
// A key value list of the presentations
event_presentation_kv?: null|key_val;
event_presentation_li?: null|list;
// A key value list of the files
event_file_kv?: null|key_val;
event_file_li?: null|list;
}
@@ -427,6 +429,7 @@ export interface Presentation {
// A key value list of the presenters
event_presenter_kv?: null|key_val;
event_presenter_li?: null|list;
}

View File

@@ -59,6 +59,7 @@ let lq__event_presentation_obj_li = liveQuery(
.sortBy('name')
);
// FIX! This id list needs to be updated. It is currently commented out in the menu_session_list.svelte file.
let lq_get__event_presentation_obj_li = liveQuery(
() => db_events.presentations
.bulkGet($events_slct.id_li__event_presentation)
@@ -134,12 +135,14 @@ let link_to_id: null|string = null;
<div><strong>Presentations:</strong></div>
{$lq_get__event_presentation_obj_li?.length}
{$lq__event_presentation_obj_li?.length}
{#if $lq_get__event_presentation_obj_li}
{$lq__event_session_obj?.event_presentation_li?.length ?? 'loading...?'}
{#if $lq__event_presentation_obj_li}
Presentations:
<ul class="event_presentation_list">
{#each $lq_get__event_presentation_obj_li as event_presentation_obj}
{#each $lq__event_presentation_obj_li as event_presentation_obj}
<li>
<div class="event_presentation_datetime_name">
{#if event_presentation_obj?.start_datetime}
@@ -149,6 +152,7 @@ let link_to_id: null|string = null;
<span class="event_presentation_name">{event_presentation_obj?.name}</span>
</div>
<!-- {#if 1==3 && event_presentation_obj?.event_presenter_list.length}
<ul>
{#each event_presentation_obj?.event_presenter_list as event_presenter_obj, index}

View File

@@ -60,7 +60,9 @@ let ae_promises: key_val = {
ae_promises.slct_event_session_id = await events_func.handle_load_ae_obj_id__event_session({
api_cfg: $ae_api,
event_session_id: event_session_obj?.id,
try_cache: true
inc_presenter_li: true,
try_cache: true,
log_lvl: 1
})
.then(async (load_results) => {
console.log(`load_results = `, load_results);
@@ -70,41 +72,42 @@ let ae_promises: key_val = {
goto(new_url, {replaceState: false});
});
ae_promises.slct_event_presentation_li = await events_func.handle_load_ae_obj_li__event_presentation({
api_cfg: $ae_api,
event_session_id: event_session_obj?.id,
try_cache: true,
log_lvl: 1
})
.then(async (load_results) => {
console.log(`load_results = `, load_results);
// ae_promises.slct_event_presentation_li = await events_func.handle_load_ae_obj_li__event_presentation({
// api_cfg: $ae_api,
// event_session_id: event_session_obj?.id,
// try_cache: true,
// log_lvl: 1
// })
// .then(async (load_results) => {
// console.log(`load_results = `, load_results);
let event_presentation_id_li = [];
// let event_presentation_id_li = [];
let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
// let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
for (let i = 0; i < load_results.length; i++) {
let event_presentation_obj = load_results[i];
let event_presentation_id_random = event_presentation_obj.event_presentation_id_random;
tmp_li.push(event_presentation_id_random);
}
event_presentation_id_li = tmp_li;
console.log(`event_presentation_id_li:`, event_presentation_id_li);
$events_slct.id_li__event_presentation = event_presentation_id_li;
// for (let i = 0; i < load_results.length; i++) {
// let event_presentation_obj = load_results[i];
// let event_presentation_id_random = event_presentation_obj.event_presentation_id_random;
// tmp_li.push(event_presentation_id_random);
// }
// event_presentation_id_li = tmp_li;
// console.log(`event_presentation_id_li:`, event_presentation_id_li);
// $events_slct.id_li__event_presentation = event_presentation_id_li;
data_url.searchParams.set('presentation_li', event_presentation_id_li);
// data_url.searchParams.set('presentation_li', event_presentation_id_li);
// let new_url = data_url.toString();
// console.log(new_url);
// goto(new_url, {replaceState: false});
// // let new_url = data_url.toString();
// // console.log(new_url);
// // goto(new_url, {replaceState: false});
// return load_results;
// // return load_results;
// });
});
// await tick();
let new_url = data_url.toString();
console.log(new_url);
goto(new_url, {replaceState: false});
// let new_url = data_url.toString();
// console.log(new_url);
// goto(new_url, {replaceState: false});
}}
>
{event_session_obj?.name}