Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/deriveLinkDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function endpointParams(endpoint: string, params: unknown[]): Record<string, unk

function patchDataSet(title: string, color: string) {
return (dg: DataGroup | null) => {
console.log(dg);
if (!dg) {
return null;
}
Expand All @@ -120,6 +121,7 @@ export function initialLoader(datasets: ILinkConfig['datasets']) {
}
const key = `${endpoint}:${JSON.stringify(params)}`;
const existing = loadingDataSets.get(key);
console.log(!existing, key);
if (existing) {
resolvedDataSets.push(existing.then(patchDataSet(title, color)));
} else {
Expand Down Expand Up @@ -156,7 +158,13 @@ export function initialLoader(datasets: ILinkConfig['datasets']) {
return Promise.all(resolvedDataSets).then((data) => {
const cleaned = data.filter((d): d is DataSet => d != null);
cleaned.forEach((d) => {
if (d.params && !Array.isArray(d.params) && d.params._endpoint) {
console.log(d)
console.log(JSON.stringify(d))
Comment on lines +161 to +162
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point in the execution, d.params no longer includes a number of the keys+values that are passed in via the base64-encoded url string, as you might expect... Its because (as best as i can tell) only the parameters that match function argument names are allowed through the call in loadImpl() that sneakily proxies to an appropriate importXYZendpoint() method. However, _endpoint is added back to the params map where loadDataSet() calls loadEpidata().

The current state of code in this PR might work work if we modify the kludge patchDataSet() above to accept another argument for a custom title that can then be added back into the .params of the DataSet returned (it is already populating the .color attribute). A less hacky way to handle this would be to make the custom title into a proper first-order member of the DataSet class, the way .color and .params are -- but so much of this code is already unsightly, i dont know how much i care about that.

if (d.params && !Array.isArray(d.params) && d.params._custom_title) {
// use custom title string if provided in encoded parameters
d.title = d.params._custom_title;
} else if (d.params && !Array.isArray(d.params) && d.params._endpoint) {
// otherwise, construct title from relevant parameters
/* eslint-disable @typescript-eslint/restrict-template-expressions */
const col_name = d.title;
d.title = `${d.params._endpoint}`;
Expand Down
Loading