mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 13:35:17 +00:00
Create substore as function
This commit is contained in:
parent
fe8ea0afdf
commit
60fe49cbaf
|
@ -4,7 +4,7 @@ import Vuex from 'vuex';
|
||||||
import userService from '@/shared/userService';
|
import userService from '@/shared/userService';
|
||||||
import { getCurrentTheme, getTheme, storeCurrentTheme } from '@/shared/themes';
|
import { getCurrentTheme, getTheme, storeCurrentTheme } from '@/shared/themes';
|
||||||
import axios, { AxiosInstance } from 'axios';
|
import axios, { AxiosInstance } from 'axios';
|
||||||
import ftbotModule, { BotStoreGetters } from './modules/ftbot';
|
import { createBotSubStore, BotStoreGetters } from './modules/ftbot';
|
||||||
import alertsModule from './modules/alerts';
|
import alertsModule from './modules/alerts';
|
||||||
import layoutModule from './modules/layout';
|
import layoutModule from './modules/layout';
|
||||||
import settingsModule from './modules/settings';
|
import settingsModule from './modules/settings';
|
||||||
|
@ -40,7 +40,7 @@ export default new Vuex.Store({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modules: {
|
modules: {
|
||||||
ftbot: ftbotModule,
|
ftbot: createBotSubStore(),
|
||||||
alerts: alertsModule,
|
alerts: alertsModule,
|
||||||
layout: layoutModule,
|
layout: layoutModule,
|
||||||
uiSettings: settingsModule,
|
uiSettings: settingsModule,
|
||||||
|
|
|
@ -84,7 +84,8 @@ export enum BotStoreGetters {
|
||||||
selectedBacktestResultKey = 'selectedBacktestResultKey',
|
selectedBacktestResultKey = 'selectedBacktestResultKey',
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export function createBotSubStore() {
|
||||||
|
return {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state,
|
state,
|
||||||
getters: {
|
getters: {
|
||||||
|
@ -393,7 +394,10 @@ export default {
|
||||||
async deleteLock({ dispatch, commit }, lockid: string) {
|
async deleteLock({ dispatch, commit }, lockid: string) {
|
||||||
try {
|
try {
|
||||||
const res = await api.delete(`/locks/${lockid}`);
|
const res = await api.delete(`/locks/${lockid}`);
|
||||||
showAlert(dispatch, res.data.result_msg ? res.data.result_msg : `Deleted Lock ${lockid}.`);
|
showAlert(
|
||||||
|
dispatch,
|
||||||
|
res.data.result_msg ? res.data.result_msg : `Deleted Lock ${lockid}.`,
|
||||||
|
);
|
||||||
commit('updateLocks', res.data);
|
commit('updateLocks', res.data);
|
||||||
return Promise.resolve(res);
|
return Promise.resolve(res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -413,7 +417,9 @@ export default {
|
||||||
Array.isArray(state.openTrades) &&
|
Array.isArray(state.openTrades) &&
|
||||||
Array.isArray(result.data) &&
|
Array.isArray(result.data) &&
|
||||||
(state.openTrades.length !== result.data.length ||
|
(state.openTrades.length !== result.data.length ||
|
||||||
!state.openTrades.every((val, index) => val.trade_id === result.data[index].trade_id))
|
!state.openTrades.every(
|
||||||
|
(val, index) => val.trade_id === result.data[index].trade_id,
|
||||||
|
))
|
||||||
) {
|
) {
|
||||||
// Open trades changed, so we should refresh now.
|
// Open trades changed, so we should refresh now.
|
||||||
commit('updateRefreshRequired', true);
|
commit('updateRefreshRequired', true);
|
||||||
|
@ -643,7 +649,10 @@ export default {
|
||||||
async deleteTrade({ dispatch }, tradeid: string) {
|
async deleteTrade({ dispatch }, tradeid: string) {
|
||||||
try {
|
try {
|
||||||
const res = await api.delete(`/trades/${tradeid}`);
|
const res = await api.delete(`/trades/${tradeid}`);
|
||||||
showAlert(dispatch, res.data.result_msg ? res.data.result_msg : `Deleted Trade ${tradeid}`);
|
showAlert(
|
||||||
|
dispatch,
|
||||||
|
res.data.result_msg ? res.data.result_msg : `Deleted Trade ${tradeid}`,
|
||||||
|
);
|
||||||
return Promise.resolve(res);
|
return Promise.resolve(res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
|
@ -691,7 +700,11 @@ export default {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (axios.isAxiosError(error)) {
|
if (axios.isAxiosError(error)) {
|
||||||
console.error(error.response);
|
console.error(error.response);
|
||||||
showAlert(dispatch, `Error occured buying: '${error.response?.data?.error}'`, 'danger');
|
showAlert(
|
||||||
|
dispatch,
|
||||||
|
`Error occured buying: '${error.response?.data?.error}'`,
|
||||||
|
'danger',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
@ -772,4 +785,5 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user