Hardened Journals and IDAA module load functions for offline resilience and ghost account support.
This commit is contained in:
@@ -13,7 +13,17 @@ export async function load({ fetch, params, parent }) {
|
||||
data.log_lvl = log_lvl;
|
||||
|
||||
const account_id = data.account_id;
|
||||
const ae_acct = data[account_id];
|
||||
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.`);
|
||||
ae_acct = {
|
||||
api: data.ae_api || {},
|
||||
slct: {
|
||||
account_id: account_id
|
||||
}
|
||||
};
|
||||
}
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
// if (!account_id) {
|
||||
|
||||
@@ -14,7 +14,17 @@ export const load = (async ({ params, parent }) => {
|
||||
data.log_lvl = log_lvl;
|
||||
|
||||
const account_id = data.account_id;
|
||||
const ae_acct = data[account_id];
|
||||
let ae_acct = data[account_id];
|
||||
|
||||
if (!ae_acct) {
|
||||
console.warn(`ae IDAA Bulletin Board +page.ts: Account ${account_id} not found in parent data. Initializing ghost acct.`);
|
||||
ae_acct = {
|
||||
api: data.ae_api || {},
|
||||
slct: {
|
||||
account_id: account_id
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
const load_post_obj_li = posts_func.load_ae_obj_li__post({
|
||||
|
||||
@@ -13,7 +13,17 @@ export async function load({ params, parent }) {
|
||||
data.log_lvl = log_lvl;
|
||||
|
||||
const account_id = data.account_id;
|
||||
const ae_acct = data[account_id];
|
||||
let ae_acct = data[account_id];
|
||||
|
||||
if (!ae_acct) {
|
||||
console.warn(`ae IDAA Recovery Meetings +layout.ts: Account ${account_id} not found in data. Initializing ghost acct.`);
|
||||
ae_acct = {
|
||||
api: data.ae_api || {},
|
||||
slct: {
|
||||
account_id: account_id
|
||||
}
|
||||
};
|
||||
}
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
// if (!account_id) {
|
||||
|
||||
@@ -14,7 +14,17 @@ export const load = (async ({ params, parent }) => {
|
||||
data.log_lvl = log_lvl;
|
||||
|
||||
const account_id = data.account_id;
|
||||
const ae_acct = data[account_id];
|
||||
let ae_acct = data[account_id];
|
||||
|
||||
if (!ae_acct) {
|
||||
console.warn(`ae IDAA Recovery Meeting [event_id] +page.ts: Account ${account_id} not found in data. Initializing ghost acct.`);
|
||||
ae_acct = {
|
||||
api: data.ae_api || {},
|
||||
slct: {
|
||||
account_id: account_id
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const event_id = params.event_id;
|
||||
|
||||
@@ -30,21 +40,26 @@ export const load = (async ({ params, parent }) => {
|
||||
api_cfg: ae_acct.api,
|
||||
event_id: event_id,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((results) => {
|
||||
if (!results) {
|
||||
error(404, {
|
||||
message: 'IDAA Recovery Meetings - Event not found'
|
||||
});
|
||||
} else {
|
||||
// ae_acct.slct.event_obj = results;
|
||||
}
|
||||
});
|
||||
// .then((results) => {
|
||||
// if (!results) {
|
||||
// error(404, {
|
||||
// message: 'IDAA Recovery Meetings - Event not found'
|
||||
// });
|
||||
// } else {
|
||||
// // ae_acct.slct.event_obj = results;
|
||||
// }
|
||||
// });
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_obj = `, load_event_obj);
|
||||
}
|
||||
ae_acct.slct.event_obj = load_event_obj;
|
||||
|
||||
if (!load_event_obj) {
|
||||
console.warn(`ae IDAA Recovery Meeting [event_id] +page.ts: Event ${event_id} not found via API or Cache.`);
|
||||
} else {
|
||||
ae_acct.slct.event_obj = load_event_obj;
|
||||
}
|
||||
}
|
||||
|
||||
// WARNING: Precaution against shared data between sites and presentations.
|
||||
|
||||
@@ -17,7 +17,18 @@ export async function load({ params, parent }) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ae_acct = parent_data[account_id];
|
||||
let ae_acct = parent_data[account_id];
|
||||
|
||||
if (!ae_acct) {
|
||||
console.warn(`ae Journals +layout.ts: Account ${account_id} not found in parent data. Initializing ghost acct.`);
|
||||
ae_acct = {
|
||||
api: parent_data.ae_api || {},
|
||||
slct: {
|
||||
account_id: account_id
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,18 @@ export async function load({ fetch, parent }) {
|
||||
|
||||
const account_id = parent_data.account_id;
|
||||
|
||||
const ae_acct = parent_data[account_id];
|
||||
let ae_acct = parent_data[account_id];
|
||||
|
||||
if (!ae_acct) {
|
||||
console.warn(`ae Journals +page.ts: Account ${account_id} not found in parent data. Initializing ghost acct.`);
|
||||
ae_acct = {
|
||||
api: parent_data.ae_api || {},
|
||||
loc: {},
|
||||
slct: {
|
||||
account_id: account_id
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const journal_id = ae_acct.slct.journal_id; // From root +layout.ts
|
||||
if (!journal_id) {
|
||||
|
||||
@@ -14,7 +14,17 @@ export async function load({ params, parent }) {
|
||||
data.log_lvl = log_lvl;
|
||||
|
||||
const account_id = data.account_id;
|
||||
const ae_acct = data[account_id];
|
||||
let ae_acct = data[account_id];
|
||||
|
||||
if (!ae_acct) {
|
||||
console.warn(`ae Journals [journal_id] +layout.ts: Account ${account_id} not found. Initializing ghost acct.`);
|
||||
ae_acct = {
|
||||
api: data.ae_api || {},
|
||||
slct: {
|
||||
account_id: account_id
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const journal_id = params.journal_id;
|
||||
if (!journal_id) {
|
||||
@@ -72,9 +82,10 @@ export async function load({ params, parent }) {
|
||||
// });
|
||||
|
||||
if (!load_journal_obj) {
|
||||
error(404, {
|
||||
message: 'Journals - Journal Entry not found'
|
||||
});
|
||||
console.warn(`ae Journals [journal_id] +layout.ts: Journal ${journal_id} not found via API or Cache.`);
|
||||
// error(404, {
|
||||
// message: 'Journals - Journal Entry not found'
|
||||
// });
|
||||
} else {
|
||||
ae_acct.slct.load_journal_obj = load_journal_obj;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,17 @@ export async function load({ params, parent }) {
|
||||
data.log_lvl = log_lvl;
|
||||
|
||||
const account_id = data.account_id;
|
||||
const ae_acct = data[account_id];
|
||||
let ae_acct = data[account_id];
|
||||
|
||||
if (!ae_acct) {
|
||||
console.warn(`ae Journals [journal_entry_id] +page.ts: Account ${account_id} not found. Initializing ghost acct.`);
|
||||
ae_acct = {
|
||||
api: data.ae_api || {},
|
||||
slct: {
|
||||
account_id: account_id
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const journal_id = params.journal_id;
|
||||
ae_acct.slct.journal_id = journal_id;
|
||||
@@ -52,7 +62,7 @@ export async function load({ params, parent }) {
|
||||
// log_lvl: log_lvl
|
||||
// });
|
||||
|
||||
const load_journal_entry_obj = load_ae_obj_id({
|
||||
const load_journal_entry_obj = await load_ae_obj_id({
|
||||
api_cfg: ae_acct.api,
|
||||
obj_type: 'journal_entry',
|
||||
obj_id: journal_entry_id,
|
||||
@@ -62,9 +72,10 @@ export async function load({ params, parent }) {
|
||||
});
|
||||
|
||||
if (!load_journal_entry_obj) {
|
||||
error(404, {
|
||||
message: 'Journals - Journal Entry not found'
|
||||
});
|
||||
console.warn(`ae Journals [journal_entry_id] +page.ts: Entry ${journal_entry_id} not found via API or Cache.`);
|
||||
// error(404, {
|
||||
// message: 'Journals - Journal Entry not found'
|
||||
// });
|
||||
} else {
|
||||
ae_acct.slct.load_journal_entry_obj = load_journal_entry_obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user