Last round of prettier: npx prettier --write src/
This commit is contained in:
@@ -175,11 +175,15 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
const updated = processed_obj.updated_on ?? processed_obj.created_on;
|
||||
const name = processed_obj.name ?? '';
|
||||
|
||||
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
(processed_obj as any).tmp_sort_1 =
|
||||
`${group}_${priority}_${sort}_${updated}`;
|
||||
(processed_obj as any).tmp_sort_2 =
|
||||
`${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
processed_obj = await Promise.resolve(
|
||||
specific_processor(processed_obj)
|
||||
);
|
||||
}
|
||||
|
||||
processed_obj_li.push(processed_obj as T);
|
||||
@@ -201,7 +205,9 @@ export async function load_ae_obj_id__sponsorship_cfg({
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_SponsorshipCfg | null> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__sponsorship_cfg() *** [V3] id=${sponsorship_cfg_id} (SWR)`);
|
||||
console.log(
|
||||
`*** load_ae_obj_id__sponsorship_cfg() *** [V3] id=${sponsorship_cfg_id} (SWR)`
|
||||
);
|
||||
}
|
||||
|
||||
// 1. FAST PATH: Cache hit
|
||||
@@ -209,17 +215,32 @@ export async function load_ae_obj_id__sponsorship_cfg({
|
||||
try {
|
||||
const cached = await db_sponsorships.cfg.get(sponsorship_cfg_id);
|
||||
if (cached) {
|
||||
_refresh_sponsorship_cfg_id_background({ api_cfg, sponsorship_cfg_id, try_cache, log_lvl: 0 });
|
||||
_refresh_sponsorship_cfg_id_background({
|
||||
api_cfg,
|
||||
sponsorship_cfg_id,
|
||||
try_cache,
|
||||
log_lvl: 0
|
||||
});
|
||||
return cached as unknown as ae_SponsorshipCfg;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// 2. SLOW PATH: Wait for API
|
||||
return await _refresh_sponsorship_cfg_id_background({ api_cfg, sponsorship_cfg_id, try_cache, log_lvl });
|
||||
return await _refresh_sponsorship_cfg_id_background({
|
||||
api_cfg,
|
||||
sponsorship_cfg_id,
|
||||
try_cache,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
async function _refresh_sponsorship_cfg_id_background({ api_cfg, sponsorship_cfg_id, try_cache, log_lvl }: any) {
|
||||
async function _refresh_sponsorship_cfg_id_background({
|
||||
api_cfg,
|
||||
sponsorship_cfg_id,
|
||||
try_cache,
|
||||
log_lvl
|
||||
}: any) {
|
||||
if (typeof navigator !== 'undefined' && !navigator.onLine) return null;
|
||||
try {
|
||||
const result = await api.get_ae_obj({
|
||||
@@ -230,7 +251,11 @@ async function _refresh_sponsorship_cfg_id_background({ api_cfg, sponsorship_cfg
|
||||
});
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__sponsorship_cfg_props({ obj_li: [result], log_lvl });
|
||||
const processed_obj_li =
|
||||
await process_ae_obj__sponsorship_cfg_props({
|
||||
obj_li: [result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_sponsorships,
|
||||
table_name: 'cfg',
|
||||
@@ -258,25 +283,43 @@ export async function load_ae_obj_id__sponsorship({
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_Sponsorship | null> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__sponsorship() *** [V3] id=${sponsorship_id} (SWR)`);
|
||||
console.log(
|
||||
`*** load_ae_obj_id__sponsorship() *** [V3] id=${sponsorship_id} (SWR)`
|
||||
);
|
||||
}
|
||||
|
||||
// 1. FAST PATH: Cache hit
|
||||
if (try_cache) {
|
||||
try {
|
||||
const cached = await db_sponsorships.sponsorship.get(sponsorship_id);
|
||||
const cached =
|
||||
await db_sponsorships.sponsorship.get(sponsorship_id);
|
||||
if (cached) {
|
||||
_refresh_sponsorship_id_background({ api_cfg, sponsorship_id, try_cache, log_lvl: 0 });
|
||||
_refresh_sponsorship_id_background({
|
||||
api_cfg,
|
||||
sponsorship_id,
|
||||
try_cache,
|
||||
log_lvl: 0
|
||||
});
|
||||
return cached as unknown as ae_Sponsorship;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// 2. SLOW PATH: Wait for API
|
||||
return await _refresh_sponsorship_id_background({ api_cfg, sponsorship_id, try_cache, log_lvl });
|
||||
return await _refresh_sponsorship_id_background({
|
||||
api_cfg,
|
||||
sponsorship_id,
|
||||
try_cache,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
async function _refresh_sponsorship_id_background({ api_cfg, sponsorship_id, try_cache, log_lvl }: any) {
|
||||
async function _refresh_sponsorship_id_background({
|
||||
api_cfg,
|
||||
sponsorship_id,
|
||||
try_cache,
|
||||
log_lvl
|
||||
}: any) {
|
||||
if (typeof navigator !== 'undefined' && !navigator.onLine) return null;
|
||||
try {
|
||||
const result = await api.get_ae_obj({
|
||||
@@ -287,7 +330,11 @@ async function _refresh_sponsorship_id_background({ api_cfg, sponsorship_id, try
|
||||
});
|
||||
if (result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__sponsorship_props({ obj_li: [result], log_lvl });
|
||||
const processed_obj_li =
|
||||
await process_ae_obj__sponsorship_props({
|
||||
obj_li: [result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_sponsorships,
|
||||
table_name: 'sponsorship',
|
||||
@@ -332,7 +379,9 @@ export async function load_ae_obj_li__sponsorship({
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_Sponsorship[]> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__sponsorship() *** [V3] for=${for_obj_type}:${for_obj_id}`);
|
||||
console.log(
|
||||
`*** load_ae_obj_li__sponsorship() *** [V3] for=${for_obj_type}:${for_obj_id}`
|
||||
);
|
||||
}
|
||||
|
||||
const result_li = await api.get_ae_obj_li({
|
||||
@@ -472,4 +521,4 @@ export const spons_func = {
|
||||
update_ae_obj__sponsorship,
|
||||
delete_ae_obj__sponsorship,
|
||||
download_export__sponsorship
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user