Don't break if plotconfig loading fails

closes #498
This commit is contained in:
Matthias 2021-09-18 11:05:02 +02:00
parent 25e0bace6d
commit 4e171457fe
2 changed files with 23 additions and 6 deletions

View File

@ -124,9 +124,12 @@ import { PlotConfig, EMPTY_PLOTCONFIG, IndicatorConfig } from '@/types';
import { getCustomPlotConfig } from '@/shared/storage'; import { getCustomPlotConfig } from '@/shared/storage';
import PlotIndicator from '@/components/charts/PlotIndicator.vue'; import PlotIndicator from '@/components/charts/PlotIndicator.vue';
import { BotStoreGetters } from '@/store/modules/ftbot'; import { BotStoreGetters } from '@/store/modules/ftbot';
import { AlertActions } from '@/store/modules/alerts';
const ftbot = namespace('ftbot'); const ftbot = namespace('ftbot');
const alerts = namespace('alerts');
@Component({ @Component({
components: { PlotIndicator }, components: { PlotIndicator },
}) })
@ -202,6 +205,8 @@ export default class PlotConfigurator extends Vue {
@ftbot.Getter [BotStoreGetters.plotConfigName]!: string; @ftbot.Getter [BotStoreGetters.plotConfigName]!: string;
@alerts.Action [AlertActions.addAlert];
get plotConfigJson() { get plotConfigJson() {
return JSON.stringify(this.plotConfig, null, 2); return JSON.stringify(this.plotConfig, null, 2);
} }
@ -334,9 +339,14 @@ export default class PlotConfigurator extends Vue {
} }
async loadPlotConfigFromStrategy() { async loadPlotConfigFromStrategy() {
try {
await this.getStrategyPlotConfig(); await this.getStrategyPlotConfig();
this.plotConfig = this.strategyPlotConfig; this.plotConfig = this.strategyPlotConfig;
this.emitPlotConfig(); this.emitPlotConfig();
} catch (data) {
//
this.addAlert({ message: 'Failed to load Plot configuration from Strategy.' });
}
} }
} }
</script> </script>

View File

@ -159,7 +159,12 @@ export function createBotSubStore(botId: string) {
[BotStoreGetters.refreshNow](state, getters, rootState, rootGetters): boolean { [BotStoreGetters.refreshNow](state, getters, rootState, rootGetters): boolean {
const bgRefresh = rootGetters['uiSettings/backgroundSync']; const bgRefresh = rootGetters['uiSettings/backgroundSync'];
const selectedBot = rootGetters['ftbot/selectedBot']; const selectedBot = rootGetters['ftbot/selectedBot'];
if ((selectedBot === botId || bgRefresh) && getters.autoRefresh && getters.isBotOnline) { if (
(selectedBot === botId || bgRefresh) &&
getters.autoRefresh &&
getters.isBotOnline &&
!getters.isWebserverMode
) {
return true; return true;
} }
return false; return false;
@ -633,9 +638,11 @@ export function createBotSubStore(botId: string) {
// TODO: Remove this fix when fix in freqtrade is populated further. // TODO: Remove this fix when fix in freqtrade is populated further.
plotConfig.subplots = {}; plotConfig.subplots = {};
} }
return commit('updatePlotConfig', result.data); commit('updatePlotConfig', result.data);
return Promise.resolve();
} catch (data) { } catch (data) {
return console.error(data); console.error(data);
return Promise.reject(data);
} }
}, },
[BotStoreActions.setPlotConfigName]({ commit }, plotConfigName: string) { [BotStoreActions.setPlotConfigName]({ commit }, plotConfigName: string) {