Skip to content

Commit 10aaee3

Browse files
committed
dont overwrite 'title' with 'customtitle' to hopefully fix reshare
1 parent 4558e63 commit 10aaee3

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

src/components/Chart.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@
751751
let labelOffset = 0;
752752
for (const ds of datasets) {
753753
ctx.fillStyle = ds.color;
754-
const label = `— ${ds.title}`;
754+
const label = `— ${ds.displayTitle()}`;
755755
drawText(ctx, label, width - 10, height - 10 - labelOffset, 0, Align.right, Align.bottom);
756756
labelOffset += 12;
757757
}

src/components/LeftMenu.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<side class="left" {style} data-tour="browser">
1414
<ImportDataSetsMenu />
1515
<div class="tree">
16-
{#each $datasetTree.datasets as child (child.title)}
16+
{#each $datasetTree.datasets as child (child.displayTitle())}
1717
{#if child instanceof DataSet}
1818
<TreeLeafNode {chart} node={child} />
1919
{:else}

src/components/tree/TreeInnerNode.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
<span on:click={toggleExpanded}>
2525
<Fa icon={expanded ? faChevronDown : faChevronRight} style="width: 0.9em; margin-right: 0.5em" />
2626
<span>
27-
{node.title}
27+
{node.displayTitle()}
2828
</span>
2929
</span>
3030
{#if expanded}
31-
{#each node.datasets as child (child.title)}
31+
{#each node.datasets as child (child.displayTitle())}
3232
{#if child instanceof DataSet}
3333
<TreeLeafNode {chart} node={child} />
3434
{:else}

src/components/tree/TreeLeafNode.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
>
3636
<Fa icon={selected ? faEye : faEyeSlash} {color} style="width: 1em; margin-right: 0.5em" />
3737
<span>
38-
{node.title}
38+
{node.displayTitle()}
3939
</span>
4040
</div>
4141

src/data/DataSet.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export default class DataSet {
3434
this.gap = computeGap(data);
3535
}
3636

37+
displayTitle(): string {
38+
return this.customTitle || this.title;
39+
}
40+
3741
randomize(): void {
3842
this.color = getRandomColor();
3943
}
@@ -108,6 +112,10 @@ export class DataGroup {
108112

109113
constructor(public readonly title: string, public readonly datasets: (DataSet | DataGroup)[]) {}
110114

115+
displayTitle(): string {
116+
return this.title;
117+
}
118+
111119
flat(arr: DataSet[]): void {
112120
for (const child of this.datasets) {
113121
if (child instanceof DataSet) {

src/deriveLinkDefaults.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ export function initialLoader(datasets: ILinkConfig['datasets']) {
182182
return Promise.all(resolvedDataSets).then((data) => {
183183
const cleaned = data.filter((d): d is DataSet => d != null);
184184
cleaned.forEach((d) => {
185-
if (d.customTitle) {
186-
d.title = d.customTitle;
187-
}
185+
// TODO: is this necessary??
188186
add(d);
189187
});
190188
return cleaned;
@@ -228,11 +226,15 @@ export function getDirectLinkImpl(state: SharedState): { url: URL; anySkipped: b
228226
let anySkipped = false;
229227
state.active.forEach((data) => {
230228
if (data.params) {
231-
config.datasets.push({
229+
let ds = {
232230
color: data.color,
233231
title: data.title,
234232
params: data.params as unknown as Record<string, unknown>,
235-
});
233+
};
234+
if (data.customTitle) {
235+
ds.params.custom_title = data.customTitle;
236+
}
237+
config.datasets.push(ds);
236238
} else {
237239
console.log('unable to get direct link to dataset:', data.title);
238240
anySkipped = true;

0 commit comments

Comments
 (0)