More code clean up
This commit is contained in:
@@ -45,40 +45,40 @@ export async function load_ae_obj_id__event_location({
|
||||
try {
|
||||
const cached = await db_events.location.get(event_location_id);
|
||||
if (cached) {
|
||||
_refresh_location_id_background({
|
||||
api_cfg, event_location_id, view, try_cache,
|
||||
inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl: 0
|
||||
_refresh_location_id_background({
|
||||
api_cfg, event_location_id, view, try_cache,
|
||||
inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl: 0
|
||||
});
|
||||
return await _handle_nested_loads(cached, {
|
||||
api_cfg, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl
|
||||
return await _handle_nested_loads(cached, {
|
||||
api_cfg, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// 2. SLOW PATH: Wait for API
|
||||
return await _refresh_location_id_background({
|
||||
api_cfg, event_location_id, view, try_cache,
|
||||
inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl
|
||||
return await _refresh_location_id_background({
|
||||
api_cfg, event_location_id, view, try_cache,
|
||||
inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
async function _refresh_location_id_background({ api_cfg, event_location_id, view, try_cache, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li, log_lvl }: any) {
|
||||
if (typeof navigator !== 'undefined' && !navigator.onLine) return null;
|
||||
try {
|
||||
const result = await api.get_ae_obj_v3({ api_cfg, obj_type: 'event_location', obj_id: event_location_id, view, log_lvl });
|
||||
const result = await api.get_ae_obj({ api_cfg, obj_type: 'event_location', obj_id: event_location_id, view, log_lvl });
|
||||
if (result) {
|
||||
const processed = await process_ae_obj__event_location_props({ obj_li: [result], log_lvl });
|
||||
const processed_obj = processed[0];
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__ae_obj({ db_instance: db_events, table_name: 'location', obj_li: [processed_obj], properties_to_save, log_lvl });
|
||||
}
|
||||
return await _handle_nested_loads(processed_obj, {
|
||||
api_cfg, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl
|
||||
return await _handle_nested_loads(processed_obj, {
|
||||
api_cfg, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
@@ -137,16 +137,16 @@ export async function load_ae_obj_li__event_location({
|
||||
try {
|
||||
const cached_li = await db_events.location.where('event_id').equals(for_obj_id).toArray();
|
||||
if (cached_li && cached_li.length > 0) {
|
||||
_refresh_location_li_background({
|
||||
api_cfg, for_obj_type, for_obj_id,
|
||||
inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
enabled, hidden, view, limit, offset, order_by_li, try_cache,
|
||||
log_lvl: 0
|
||||
_refresh_location_li_background({
|
||||
api_cfg, for_obj_type, for_obj_id,
|
||||
inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
enabled, hidden, view, limit, offset, order_by_li, try_cache,
|
||||
log_lvl: 0
|
||||
});
|
||||
for (const loc of cached_li) {
|
||||
_handle_nested_loads(loc, {
|
||||
api_cfg, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl: 0
|
||||
_handle_nested_loads(loc, {
|
||||
api_cfg, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl: 0
|
||||
});
|
||||
}
|
||||
return cached_li;
|
||||
@@ -155,21 +155,21 @@ export async function load_ae_obj_li__event_location({
|
||||
}
|
||||
|
||||
// 2. SLOW PATH: API
|
||||
return await _refresh_location_li_background({
|
||||
api_cfg, for_obj_type, for_obj_id,
|
||||
inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
enabled, hidden, view, limit, offset, order_by_li, try_cache,
|
||||
log_lvl
|
||||
return await _refresh_location_li_background({
|
||||
api_cfg, for_obj_type, for_obj_id,
|
||||
inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
enabled, hidden, view, limit, offset, order_by_li, try_cache,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
async function _refresh_location_li_background({ api_cfg, for_obj_type, for_obj_id, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li, enabled, hidden, view, limit, offset, order_by_li, try_cache, log_lvl }: any) {
|
||||
if (typeof navigator !== 'undefined' && !navigator.onLine) return [];
|
||||
try {
|
||||
const result_li = await api.get_ae_obj_li_v3({ api_cfg, obj_type: 'event_location', for_obj_type, for_obj_id, enabled, hidden, view, limit, offset, order_by_li, log_lvl });
|
||||
const result_li = await api.get_ae_obj_li({ api_cfg, obj_type: 'event_location', for_obj_type, for_obj_id, enabled, hidden, view, limit, offset, order_by_li, log_lvl });
|
||||
if (result_li) {
|
||||
const processed = await process_ae_obj__event_location_props({ obj_li: result_li, log_lvl });
|
||||
|
||||
|
||||
// String-Only ID Vision: Ensure linking ID is set for indexing
|
||||
if (for_obj_type === 'event') {
|
||||
processed.forEach(loc => loc.event_id = for_obj_id);
|
||||
@@ -179,9 +179,9 @@ async function _refresh_location_li_background({ api_cfg, for_obj_type, for_obj_
|
||||
await db_save_ae_obj_li__ae_obj({ db_instance: db_events, table_name: 'location', obj_li: processed, properties_to_save, log_lvl });
|
||||
}
|
||||
for (const loc of processed) {
|
||||
_handle_nested_loads(loc, {
|
||||
api_cfg, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl: 0
|
||||
_handle_nested_loads(loc, {
|
||||
api_cfg, inc_file_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_device_li, inc_all_file_li,
|
||||
log_lvl: 0
|
||||
});
|
||||
}
|
||||
return processed;
|
||||
@@ -208,9 +208,9 @@ async function _handle_nested_loads(location_obj: any, { api_cfg, inc_file_li, i
|
||||
if (inc_session_li) {
|
||||
tasks.push(load_ae_obj_li__event_session({
|
||||
api_cfg, for_obj_type: 'event_location', for_obj_id: current_location_id,
|
||||
inc_file_li: inc_all_file_li,
|
||||
inc_file_li: inc_all_file_li,
|
||||
inc_all_file_li: inc_all_file_li,
|
||||
inc_presentation_li: inc_presentation_li,
|
||||
inc_presentation_li: inc_presentation_li,
|
||||
inc_presenter_li: inc_presenter_li,
|
||||
enabled: 'enabled', hidden: 'not_hidden', limit: 150, log_lvl
|
||||
}).then(res => location_obj.event_session_obj_li = res));
|
||||
@@ -283,7 +283,7 @@ export async function delete_ae_obj_id__event_location({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
const result = await api.delete_nested_ae_obj_v3({
|
||||
const result = await api.delete_nested_ae_obj({
|
||||
api_cfg,
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
@@ -350,7 +350,7 @@ export async function search__event_location({
|
||||
if (hidden === 'hidden') search_query.and.push({ field: 'hide', op: 'eq', value: true });
|
||||
else if (hidden === 'not_hidden') search_query.and.push({ field: 'hide', op: 'eq', value: false });
|
||||
|
||||
const result_li = await api.search_ae_obj_v3({ api_cfg, obj_type: 'event_location', search_query, order_by_li, view, limit, offset, log_lvl });
|
||||
const result_li = await api.search_ae_obj({ api_cfg, obj_type: 'event_location', search_query, order_by_li, view, limit, offset, log_lvl });
|
||||
if (result_li) {
|
||||
const processed = await process_ae_obj__event_location_props({ obj_li: result_li, log_lvl });
|
||||
if (try_cache) {
|
||||
|
||||
Reference in New Issue
Block a user