I guess this is better than it was...
This commit is contained in:
@@ -48,6 +48,9 @@ if (ae_no_account_id) {
|
||||
|
||||
ae_api_init['headers'] = ae_api_headers;
|
||||
|
||||
let ae_loc_init: key_val = {
|
||||
};
|
||||
|
||||
// export const prerender = false;
|
||||
|
||||
// There is not an initial data store from SvelteKit for this, so we will just use the API to get the data.
|
||||
@@ -79,7 +82,7 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
||||
// let ae_api_tmp = get(ae_api);
|
||||
// console.log(`ae_api = `, ae_api_tmp);
|
||||
|
||||
let ds_code_li: null|key_val = null;
|
||||
let ds_code_li: null|key_val = {};
|
||||
// if (ae_loc_tmp && ae_loc_tmp.ds) {
|
||||
// ds_code_li = ae_loc_tmp.ds;
|
||||
// }
|
||||
@@ -93,7 +96,7 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
||||
// '_XY7DXtc9MY': ae_acct,
|
||||
},
|
||||
|
||||
ae_loc: ae_loc_tmp,
|
||||
ae_loc: {},
|
||||
ae_api: ae_api_init,
|
||||
ae_ds: {},
|
||||
ae_hub: {}, // was ae_core
|
||||
@@ -121,14 +124,7 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
||||
submenu: {},
|
||||
};
|
||||
|
||||
// let loading_results = null;
|
||||
|
||||
|
||||
// First do a site_domain look up to check if it is valid and get the account_id.
|
||||
if (!url.host) {
|
||||
console.log(`ERROR: No host found in the URL!!!`);
|
||||
return false;
|
||||
}
|
||||
// ae_loc.url_host = data.url.host; // Use this to look up? sub.example.com:123
|
||||
// ae_loc.fqdn = url.host; // Use this to look up? sub.example.com:123
|
||||
// ae_loc.url_hostname = data.url.hostname; // sub.example.com
|
||||
@@ -136,13 +132,7 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
||||
// ae_loc.site_domain = data.url.origin;
|
||||
// console.log(`ae_loc = `, ae_loc);
|
||||
|
||||
// const res = await fetch(`https://api.example.com/data`);
|
||||
|
||||
ae_api_tmp['account_id'] = null;
|
||||
ae_api_tmp['headers']['x-account-id'] = '';
|
||||
ae_api_tmp['headers']['x-no-account-id'] = 'nothing to see here'
|
||||
|
||||
account_id = await core_func.handle_load_ae_obj_id__site_domain({api_cfg: ae_api_tmp, fqdn: url.host, try_cache: false})
|
||||
account_id = await core_func.handle_load_ae_obj_id__site_domain({api_cfg: ae_api_init, fqdn: url.host, try_cache: false})
|
||||
|
||||
.then(function (site_domain_results) {
|
||||
if (site_domain_results) {
|
||||
@@ -152,19 +142,17 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
||||
|
||||
ae_acct.account_id = site_domain_results.account_id_random;
|
||||
|
||||
// ae_api_tmp = get(ae_api);
|
||||
ae_api_init['account_id'] = site_domain_results.account_id_random;
|
||||
ae_api_init['headers']['x-account-id'] = site_domain_results.account_id_random;
|
||||
ae_api_init['headers']['x-no-account-id'] = null;
|
||||
|
||||
ae_api_tmp['account_id'] = site_domain_results.account_id_random;
|
||||
ae_api_tmp['headers']['x-account-id'] = site_domain_results.account_id_random;
|
||||
ae_api_tmp['headers']['x-no-account-id'] = null;
|
||||
|
||||
ae_loc_tmp['account_id'] = site_domain_results.account_id_random;
|
||||
ae_loc_tmp['site_id'] = site_domain_results.site_id_random;
|
||||
ae_loc_tmp['site_domain_id'] = site_domain_results.site_domain_id_random;
|
||||
ae_loc_tmp['site_enable'] = site_domain_results.enable;
|
||||
ae_loc_tmp['site_style_href'] = site_domain_results.style_href;
|
||||
ae_loc_tmp['site_google_tracking_id'] = site_domain_results.google_tracking_id;
|
||||
ae_loc_tmp['site_cfg_json'] = site_domain_results.cfg_json;
|
||||
ae_loc_init['account_id'] = site_domain_results.account_id_random;
|
||||
ae_loc_init['site_id'] = site_domain_results.site_id_random;
|
||||
ae_loc_init['site_domain_id'] = site_domain_results.site_domain_id_random;
|
||||
ae_loc_init['site_enable'] = site_domain_results.enable;
|
||||
ae_loc_init['site_style_href'] = site_domain_results.style_href;
|
||||
ae_loc_init['site_google_tracking_id'] = site_domain_results.google_tracking_id;
|
||||
ae_loc_init['site_cfg_json'] = site_domain_results.cfg_json;
|
||||
|
||||
console.log(`root layout.ts: Returning account_id = `, site_domain_results.account_id_random);
|
||||
|
||||
@@ -180,52 +168,69 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
||||
// return true;
|
||||
// });
|
||||
|
||||
console.log(ae_loc_init);
|
||||
|
||||
// if (browser) {
|
||||
// localStorage.setItem('ae_account_id', await account_id);
|
||||
// }
|
||||
|
||||
// NOTE: We need to wait for the account_id to be returned before we can continue. It is required for the api_cfg.
|
||||
|
||||
let ds_type: null|string = 'json';
|
||||
ds_code = 'hub__page__access_code_li_json';
|
||||
if (account_id) {
|
||||
console.log(`INFO: ae_ account_id = `, account_id);
|
||||
ds_code_li[ds_code] = core_func.handle_load_ae_obj_code__data_store({api_cfg: ae_api_tmp, code: ds_code, data_type: ds_type})
|
||||
.then(function (ds_results) {
|
||||
if (ds_results) {
|
||||
// console.log(`ae_ ds_results = `, ds_results);
|
||||
return ds_results;
|
||||
}
|
||||
|
||||
console.log(`INFO: ae_ account_id = `, account_id);
|
||||
// ae_acct['ds'][ds_code]
|
||||
ds_code_li[ds_code] = await core_func.handle_load_ae_obj_code__data_store({api_cfg: ae_api_init, code: ds_code, data_type: ds_type, save_idb: false})
|
||||
.then(function (ds_results) {
|
||||
if (ds_results) {
|
||||
console.log(`ae_ ds_results = `, ds_results);
|
||||
// if (browser) {
|
||||
// console.log(`ae_ds__ key: ${ds_code}, value:`, ds_results);
|
||||
// localStorage.setItem(`ae_ds__${ds_code}`, JSON.stringify(ds_results));
|
||||
// } else {
|
||||
// console.log('No browser!!!');
|
||||
// }
|
||||
return ds_results;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
console.log(`ERROR: No account_id was returned!!!`);
|
||||
// return false;
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
// ds_type = 'text';
|
||||
// ds_code = 'hub__site__appshell_header';
|
||||
// ds_code_li[ds_code] = await core_func.handle_load_ae_obj_code__data_store({api_cfg: ae_api_tmp, code: ds_code, data_type: ds_type})
|
||||
// .then(function (ds_results) {
|
||||
// if (ds_results) {
|
||||
// console.log(`ae_ ds_results = `, ds_results);
|
||||
// return ds_results;
|
||||
// }
|
||||
ae_loc_init['page_access_code_li'] = ds_code_li['hub__page__access_code_li_json'];
|
||||
|
||||
// }
|
||||
// );
|
||||
|
||||
|
||||
ae_loc_tmp['page_access_code_li'] = ds_code_li['hub__page__access_code_li_json'];
|
||||
|
||||
ae_acct['api'] = ae_api_tmp;
|
||||
ae_acct['loc'] = ae_loc_tmp;
|
||||
ae_acct['api'] = ae_api_init;
|
||||
ae_acct['loc'] = ae_loc_init;
|
||||
ae_acct['ds'] = ds_code_li;
|
||||
ae_acct['slct'] = {
|
||||
'account_id': account_id,
|
||||
'site_domain_id': ae_loc_init.site_domain_id,
|
||||
'site_id': ae_loc_init.site_id,
|
||||
|
||||
// For events_leads, events_badges, events_speakers
|
||||
'event_id': ae_loc_init.site_cfg_json.slct__event_id,
|
||||
'event_badge_template': ae_loc_init.site_cfg_json.slct__event_badge_template,
|
||||
|
||||
// For sponsorships
|
||||
'sponsorship_cfg_id': ae_loc_init.site_cfg_json.slct__sponsorship_cfg_id,
|
||||
}
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
data_struct.ae_acct[ae_loc_tmp.account_id] = ae_acct;
|
||||
// data_struct.ae_acct = ae_acct;
|
||||
// WARNING: Precaution against shared data between sites and sessions.
|
||||
// data_struct.ae_acct[ae_loc_init.account_id] = ae_acct;
|
||||
|
||||
data_struct[ae_loc_init.account_id] = ae_acct;
|
||||
|
||||
return data_struct;
|
||||
}
|
||||
|
||||
|
||||
// ds_type = 'text';
|
||||
// ds_code = 'hub__site__appshell_header';
|
||||
// ds_code_li[ds_code] = await core_func.handle_load_ae_obj_code__data_store({api_cfg: ae_api_tmp, code: ds_code, data_type: ds_type})
|
||||
// .then(function (ds_results) {
|
||||
// if (ds_results) {
|
||||
// console.log(`ae_ ds_results = `, ds_results);
|
||||
// return ds_results;
|
||||
// }
|
||||
|
||||
// }
|
||||
// );
|
||||
|
||||
Reference in New Issue
Block a user