mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 13:35:17 +00:00
Add logic to add/remove a substore
This commit is contained in:
parent
a253377124
commit
cb8d0af126
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Watch } from 'vue-property-decorator';
|
import { Component, Vue, Watch } from 'vue-property-decorator';
|
||||||
import { Action, State } from 'vuex-class';
|
import { Action, Getter, State } from 'vuex-class';
|
||||||
import RefreshIcon from 'vue-material-design-icons/Refresh.vue';
|
import RefreshIcon from 'vue-material-design-icons/Refresh.vue';
|
||||||
|
|
||||||
@Component({ components: { RefreshIcon } })
|
@Component({ components: { RefreshIcon } })
|
||||||
|
@ -40,7 +40,7 @@ export default class ReloadControl extends Vue {
|
||||||
this.stopRefresh();
|
this.stopRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@State loggedIn;
|
@Getter loggedIn;
|
||||||
|
|
||||||
@State autoRefresh!: boolean;
|
@State autoRefresh!: boolean;
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,15 @@ export default function createBotStore(store) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
addBot(state: FTMultiBotState, botName: string) {
|
addBot(state: FTMultiBotState, botId: string) {
|
||||||
state.availableBots = [...state.availableBots, botName];
|
state.availableBots = [...state.availableBots, botId];
|
||||||
|
},
|
||||||
|
removeBot(state: FTMultiBotState, botId: string) {
|
||||||
|
const index = state.availableBots.indexOf(botId);
|
||||||
|
if (index > -1) {
|
||||||
|
state.availableBots.splice(index, 1);
|
||||||
|
state.availableBots = [...state.availableBots];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,9 +51,17 @@ export default function createBotStore(store) {
|
||||||
// TODO: handle error!
|
// TODO: handle error!
|
||||||
}
|
}
|
||||||
console.log('add bot', botId);
|
console.log('add bot', botId);
|
||||||
store.registerModule(`ftbot/${botId}`, createBotSubStore(botId));
|
store.registerModule(['ftbot', botId], createBotSubStore(botId));
|
||||||
commit('addBot', botId);
|
commit('addBot', botId);
|
||||||
},
|
},
|
||||||
|
removeBot({ commit, getters }, botId: string) {
|
||||||
|
if (getters.allAvailableBots.includes(botId)) {
|
||||||
|
store.unregisterModule(`ftbot/${botId}`);
|
||||||
|
commit('removeBot', botId);
|
||||||
|
} else {
|
||||||
|
console.warn(`bot ${botId} not found! could not remove`);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
// Autocreate Actions
|
// Autocreate Actions
|
||||||
Object.keys(BotStoreActions).forEach((e) => {
|
Object.keys(BotStoreActions).forEach((e) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user