in packages/app/client/src/ui/helpers/activeBotHelper.ts [189:227]
static async confirmAndOpenBotFromFile(filename?: string): Promise<any> {
try {
if (!filename) {
filename = await this.browseForBotFile();
}
if (filename) {
const activeBot = getActiveBot();
if (activeBot && activeBot.path === filename) {
await this.commandService.call(SharedConstants.Commands.Bot.Switch, activeBot);
return;
}
const result = this.confirmSwitchBot();
if (result) {
store.dispatch(closeNonGlobalTabs());
const bot = await this.commandService.remoteCall<BotConfigWithPath>(
SharedConstants.Commands.Bot.Open,
filename
);
if (!bot) {
return;
}
await this.commandService.remoteCall(SharedConstants.Commands.Bot.SetActive, bot);
await this.commandService.call(SharedConstants.Commands.Bot.Load, bot);
const numOfServices = bot.services && bot.services.length;
this.commandService
.remoteCall(Telemetry.TrackEvent, `bot_open`, {
method: 'file_browse',
numOfServices,
source: 'path',
})
.catch(_e => void 0);
}
}
} catch (err) {
throw new Error(`[confirmAndOpenBotFromFile] Error while calling browseForBotFile: ${err}`);
}
}