@veramo-community/veramo-react
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -8,3 +8,3 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
}; | ||
import React, { useContext, useState, useEffect } from 'react'; | ||
import React, { useContext, useState } from 'react'; | ||
import { createAgentFromConfig, getStoredAgentConfigs, storeAgentConfigs, storeActiveAgentId, getStoredActiveAgentId, } from './utils'; | ||
@@ -27,11 +27,2 @@ import { v4 as uuidv4 } from 'uuid'; | ||
}; | ||
useEffect(function () { | ||
var _a; | ||
if (!activeAgentId && agents.length > 0) { | ||
setActiveAgentId((_a = agents[0].context) === null || _a === void 0 ? void 0 : _a.id); | ||
} | ||
else if (agents.length === 0 && activeAgentId !== undefined) { | ||
setActiveAgentId(undefined); | ||
} | ||
}, [agents, activeAgentId]); | ||
var validateContext = function (context) { | ||
@@ -44,2 +35,5 @@ if (!(context === null || context === void 0 ? void 0 : context.id)) | ||
setAgents(__spreadArrays(agents, [agent])); | ||
if (!activeAgentId) { | ||
setActiveAgentId(agent.context.id); | ||
} | ||
}; | ||
@@ -55,7 +49,9 @@ function addAgentConfig(config) { | ||
var removeAgent = function (id) { | ||
var _a, _b; | ||
storeAgentConfigs(getStoredAgentConfigs().filter(function (c) { return c.context.id !== id; })); | ||
var filtered = agents.filter(function (a) { var _a; return ((_a = a.context) === null || _a === void 0 ? void 0 : _a.id) !== id; }); | ||
setAgents(filtered); | ||
if (activeAgentId === id) { | ||
setActiveAgentId(undefined); | ||
setActiveAgentId((_b = (_a = filtered[0]) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.id); | ||
} | ||
storeAgentConfigs(getStoredAgentConfigs().filter(function (c) { return c.context.id !== id; })); | ||
setAgents(agents.filter(function (a) { var _a; return ((_a = a.context) === null || _a === void 0 ? void 0 : _a.id) !== id; })); | ||
}; | ||
@@ -62,0 +58,0 @@ var getAgentConfig = function (id) { |
{ | ||
"name": "@veramo-community/veramo-react", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
34901
480