fix: Improved logic to trigger plot reload on config changes

This commit is contained in:
Matthias 2024-07-23 06:41:35 +02:00
parent 2739e72bff
commit d336ac903b

View File

@ -45,9 +45,9 @@
</div> </div>
</div> </div>
<div class="ms-auto d-flex align-items-center w-auto"> <div class="ms-auto d-flex align-items-center w-auto">
<BFormCheckbox v-model="settingsStore.useHeikinAshiCandles" <BFormCheckbox v-model="settingsStore.useHeikinAshiCandles">
><small class="text-nowrap">Heikin Ashi</small></BFormCheckbox <small class="text-nowrap">Heikin Ashi</small>
> </BFormCheckbox>
<div class="ms-2"> <div class="ms-2">
<PlotConfigSelect></PlotConfigSelect> <PlotConfigSelect></PlotConfigSelect>
@ -149,6 +149,10 @@ const strategyName = computed(() => props.strategy || dataset.value?.strategy ||
const datasetColumns = computed(() => const datasetColumns = computed(() =>
dataset.value ? (dataset.value.all_columns ?? dataset.value.columns) : [], dataset.value ? (dataset.value.all_columns ?? dataset.value.columns) : [],
); );
const datasetLoadedColumns = computed(() =>
dataset.value ? (dataset.value.columns ?? dataset.value.all_columns) : [],
);
const hasDataset = computed(() => dataset.value && dataset.value.data.length > 0); const hasDataset = computed(() => dataset.value && dataset.value.data.length > 0);
const isLoadingDataset = computed((): boolean => { const isLoadingDataset = computed((): boolean => {
if (props.historicView) { if (props.historicView) {
@ -236,9 +240,12 @@ watch(
watch( watch(
() => plotStore.plotConfig, () => plotStore.plotConfig,
() => { () => {
// all plotstore.usedColumns are in the dataset // Trigger reload if the used columns are not loaded yet but would be available.
const hasAllColumns = plotStore.usedColumns.every((c) => datasetColumns.value.includes(c)); const hasAllColumns = plotStore.usedColumns.some(
if (settingsStore.useReducedPairCalls && !hasAllColumns) { (c) => datasetColumns.value.includes(c) && !datasetLoadedColumns.value.includes(c),
);
if (settingsStore.useReducedPairCalls && hasAllColumns) {
console.log('triggering refresh'); console.log('triggering refresh');
refresh(); refresh();
} }