Make updateBot method more dynamic, allowing for random updates

This commit is contained in:
Matthias 2023-04-18 19:26:31 +02:00
parent 8570aed525
commit 6aeb3755b2
3 changed files with 16 additions and 6 deletions

View File

@ -1,6 +1,13 @@
import axios, { AxiosResponse } from 'axios';
import { AuthPayload, AuthResponse, BotDescriptors, AuthStorage, AuthStorageMulti } from '@/types';
import {
AuthPayload,
AuthResponse,
BotDescriptors,
AuthStorage,
AuthStorageMulti,
BotDescriptor,
} from '@/types';
const AUTH_LOGIN_INFO = 'ftAuthLoginInfo';
const APIBASE = '/api/v1';
@ -13,9 +20,11 @@ export class UserService {
this.botId = botId;
}
public renameBot(newName: string): void {
public updateBot(newName: Partial<BotDescriptor>): void {
const newInfo = this.getLoginInfo();
newInfo.botName = newName;
Object.assign(newInfo, newName);
this.storeLoginInfo(newInfo);
}

View File

@ -34,6 +34,7 @@ import {
ForceEnterPayload,
TradeResponse,
ClosedTrade,
BotDescriptor,
} from '@/types';
import axios, { AxiosResponse } from 'axios';
import { defineStore } from 'pinia';
@ -175,8 +176,8 @@ export function createBotSubStore(botId: string, botName: string) {
getLoginInfo() {
return userService.getLoginInfo();
},
rename(name: string) {
userService.renameBot(name);
updateBot(updatedBotInfo: Partial<BotDescriptor>) {
userService.updateBot(updatedBotInfo);
},
setAutoRefresh(newRefreshValue) {
this.autoRefresh = newRefreshValue;

View File

@ -175,7 +175,7 @@ export const useBotStore = defineStore('ftbot-wrapper', {
console.error('Bot not found');
return;
}
this.botStores[bot.botId].rename(bot.botName);
this.botStores[bot.botId].updateBot({ botName: bot.botName });
this.availableBots[bot.botId].botName = bot.botName;
},
removeBot(botId: string) {