diff --git a/src/shared/userService.ts b/src/shared/userService.ts index d0a53102..d53835ce 100644 --- a/src/shared/userService.ts +++ b/src/shared/userService.ts @@ -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): void { const newInfo = this.getLoginInfo(); - newInfo.botName = newName; + + Object.assign(newInfo, newName); + this.storeLoginInfo(newInfo); } diff --git a/src/stores/ftbot.ts b/src/stores/ftbot.ts index 15557d61..ed12ef2b 100644 --- a/src/stores/ftbot.ts +++ b/src/stores/ftbot.ts @@ -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) { + userService.updateBot(updatedBotInfo); }, setAutoRefresh(newRefreshValue) { this.autoRefresh = newRefreshValue; diff --git a/src/stores/ftbotwrapper.ts b/src/stores/ftbotwrapper.ts index 5874f589..edd937ba 100644 --- a/src/stores/ftbotwrapper.ts +++ b/src/stores/ftbotwrapper.ts @@ -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) {