fix(desktop): ajustar store do agente para build
This commit is contained in:
parent
152550a9a0
commit
30928fd938
1 changed files with 9 additions and 9 deletions
|
|
@ -105,23 +105,23 @@ function setStatus(message: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = new Store(STORE_FILENAME)
|
let storeInstance: Store | null = null
|
||||||
let storeLoaded = false
|
|
||||||
|
|
||||||
async function ensureStoreLoaded() {
|
async function ensureStoreLoaded(): Promise<Store> {
|
||||||
if (!storeLoaded) {
|
if (!storeInstance) {
|
||||||
try {
|
try {
|
||||||
await store.load()
|
storeInstance = await Store.load(STORE_FILENAME)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[agent] Falha ao carregar store", error)
|
console.error("[agent] Falha ao carregar store", error)
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
storeLoaded = true
|
|
||||||
}
|
}
|
||||||
|
return storeInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadConfig(): Promise<AgentConfig | null> {
|
async function loadConfig(): Promise<AgentConfig | null> {
|
||||||
try {
|
try {
|
||||||
await ensureStoreLoaded()
|
const store = await ensureStoreLoaded()
|
||||||
const record = await store.get<AgentConfig>("config")
|
const record = await store.get<AgentConfig>("config")
|
||||||
if (!record) return null
|
if (!record) return null
|
||||||
return record
|
return record
|
||||||
|
|
@ -132,13 +132,13 @@ async function loadConfig(): Promise<AgentConfig | null> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveConfig(config: AgentConfig) {
|
async function saveConfig(config: AgentConfig) {
|
||||||
await ensureStoreLoaded()
|
const store = await ensureStoreLoaded()
|
||||||
await store.set("config", config)
|
await store.set("config", config)
|
||||||
await store.save()
|
await store.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearConfig() {
|
async function clearConfig() {
|
||||||
await ensureStoreLoaded()
|
const store = await ensureStoreLoaded()
|
||||||
await store.delete("config")
|
await store.delete("config")
|
||||||
await store.save()
|
await store.save()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue