fix new window loading bug

This commit is contained in:
nicwands
2026-05-08 13:18:16 -04:00
parent 75d3488de0
commit a43c3221da
5 changed files with 41 additions and 32 deletions

View File

@@ -438,6 +438,7 @@ const initializeCore = async (runtime, { plugins }) => {
let notesAPI = null;
let initPromise = null;
const getNotesAPI = async () => {
console.log("getNotesAPI before: ", notesAPI);
if (notesAPI) return notesAPI;
if (!initPromise) {
initPromise = (async () => {
@@ -458,6 +459,7 @@ const initializeCore = async (runtime, { plugins }) => {
);
notesAPI = new NotesAPI(adapter, encryptionKey);
await notesAPI.init();
console.log("getNotesAPI after: ", notesAPI);
return notesAPI;
})();
}

View File

@@ -188,7 +188,6 @@ export default class NotesAPI {
getNote(id) {
const note = this.notesCache.get(id)
console.log(this.notesCache, id)
return note ? { ...note } : null
}

View File

@@ -50,23 +50,9 @@ const initConfigManager = async (runtime, pluginManager) => {
return createConfigManager(storage, pluginManager)
}
export const initializeCore = async (runtime, { plugins }) => {
const pluginManager = initPluginManager(runtime, plugins)
const configManager = await initConfigManager(runtime, pluginManager)
const config = await configManager.loadConfig()
// Set active plugin
const activeConfig = config.adapters?.[config.activeAdapter] || {}
pluginManager.setActivePlugin(config.activeAdapter, activeConfig)
// Create API instance
let notesAPI = null
let initPromise = null
const getNotesAPI = async () => {
if (notesAPI) return notesAPI
if (!initPromise) {
initPromise = (async () => {
let notesAPI = null
let initPromise = null
const initNotesAPI = async (configManager, pluginManager) => {
// Get fresh config to ensure adapters are populated from main process
const latestConfig = await configManager.loadConfig()
@@ -83,16 +69,31 @@ export const initializeCore = async (runtime, { plugins }) => {
const pluginId = latestConfig?.activeAdapter || 'filesystem'
const adapterConfig = latestConfig?.adapters?.[pluginId] || {}
const adapter = pluginManager.getAdapter(
pluginId,
adapterConfig,
)
const adapter = pluginManager.getAdapter(pluginId, adapterConfig)
notesAPI = new NotesAPI(adapter, encryptionKey)
await notesAPI.init()
const api = new NotesAPI(adapter, encryptionKey)
await api.init()
return notesAPI
})()
notesAPI = api
return api
}
export const initializeCore = async (runtime, { plugins }) => {
const pluginManager = initPluginManager(runtime, plugins)
const configManager = await initConfigManager(runtime, pluginManager)
const config = await configManager.loadConfig()
// Set active plugin
const activeConfig = config.adapters?.[config.activeAdapter] || {}
pluginManager.setActivePlugin(config.activeAdapter, activeConfig)
// Create API instance
const getNotesAPI = async () => {
if (notesAPI) return notesAPI
if (!initPromise) {
initPromise = initNotesAPI(configManager, pluginManager)
}
return initPromise

View File

@@ -15,11 +15,17 @@
<span v-else class="date">{{ formatDate(note.updatedAt) }}</span>
<div class="title-actions">
<button class="title bold" @click="openNote(note.id)">
<button
class="title bold"
@click="!deleteActive && openNote(note.id)"
>
{{ note.title }}
</button>
<button class="action bold" @click="openNote(note.id)">
<button
class="action bold"
@click="!deleteActive && openNote(note.id)"
>
(open)
</button>
<button class="action bold move" @click="onMoveOpened">

View File

@@ -31,6 +31,7 @@ export default () => {
}
const loadNote = async (id) => {
const api = await getNotesAPI()
console.log(api)
return await api.getNote(id)
}