fix new window loading bug
This commit is contained in:
@@ -438,6 +438,7 @@ const initializeCore = async (runtime, { plugins }) => {
|
|||||||
let notesAPI = null;
|
let notesAPI = null;
|
||||||
let initPromise = null;
|
let initPromise = null;
|
||||||
const getNotesAPI = async () => {
|
const getNotesAPI = async () => {
|
||||||
|
console.log("getNotesAPI before: ", notesAPI);
|
||||||
if (notesAPI) return notesAPI;
|
if (notesAPI) return notesAPI;
|
||||||
if (!initPromise) {
|
if (!initPromise) {
|
||||||
initPromise = (async () => {
|
initPromise = (async () => {
|
||||||
@@ -458,6 +459,7 @@ const initializeCore = async (runtime, { plugins }) => {
|
|||||||
);
|
);
|
||||||
notesAPI = new NotesAPI(adapter, encryptionKey);
|
notesAPI = new NotesAPI(adapter, encryptionKey);
|
||||||
await notesAPI.init();
|
await notesAPI.init();
|
||||||
|
console.log("getNotesAPI after: ", notesAPI);
|
||||||
return notesAPI;
|
return notesAPI;
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,6 @@ export default class NotesAPI {
|
|||||||
|
|
||||||
getNote(id) {
|
getNote(id) {
|
||||||
const note = this.notesCache.get(id)
|
const note = this.notesCache.get(id)
|
||||||
console.log(this.notesCache, id)
|
|
||||||
|
|
||||||
return note ? { ...note } : null
|
return note ? { ...note } : null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,35 @@ const initConfigManager = async (runtime, pluginManager) => {
|
|||||||
return createConfigManager(storage, pluginManager)
|
return createConfigManager(storage, pluginManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
let encryptionKey = latestConfig?.encryptionKey
|
||||||
|
|
||||||
|
if (!encryptionKey) {
|
||||||
|
encryptionKey = generateEncryptionKey()
|
||||||
|
await configManager.setConfig({
|
||||||
|
...latestConfig,
|
||||||
|
encryptionKey,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const pluginId = latestConfig?.activeAdapter || 'filesystem'
|
||||||
|
const adapterConfig = latestConfig?.adapters?.[pluginId] || {}
|
||||||
|
|
||||||
|
const adapter = pluginManager.getAdapter(pluginId, adapterConfig)
|
||||||
|
|
||||||
|
const api = new NotesAPI(adapter, encryptionKey)
|
||||||
|
await api.init()
|
||||||
|
|
||||||
|
notesAPI = api
|
||||||
|
|
||||||
|
return api
|
||||||
|
}
|
||||||
|
|
||||||
export const initializeCore = async (runtime, { plugins }) => {
|
export const initializeCore = async (runtime, { plugins }) => {
|
||||||
const pluginManager = initPluginManager(runtime, plugins)
|
const pluginManager = initPluginManager(runtime, plugins)
|
||||||
const configManager = await initConfigManager(runtime, pluginManager)
|
const configManager = await initConfigManager(runtime, pluginManager)
|
||||||
@@ -60,39 +89,11 @@ export const initializeCore = async (runtime, { plugins }) => {
|
|||||||
pluginManager.setActivePlugin(config.activeAdapter, activeConfig)
|
pluginManager.setActivePlugin(config.activeAdapter, activeConfig)
|
||||||
|
|
||||||
// Create API instance
|
// Create API instance
|
||||||
let notesAPI = null
|
|
||||||
let initPromise = null
|
|
||||||
const getNotesAPI = async () => {
|
const getNotesAPI = async () => {
|
||||||
if (notesAPI) return notesAPI
|
if (notesAPI) return notesAPI
|
||||||
|
|
||||||
if (!initPromise) {
|
if (!initPromise) {
|
||||||
initPromise = (async () => {
|
initPromise = initNotesAPI(configManager, pluginManager)
|
||||||
// Get fresh config to ensure adapters are populated from main process
|
|
||||||
const latestConfig = await configManager.loadConfig()
|
|
||||||
|
|
||||||
let encryptionKey = latestConfig?.encryptionKey
|
|
||||||
|
|
||||||
if (!encryptionKey) {
|
|
||||||
encryptionKey = generateEncryptionKey()
|
|
||||||
await configManager.setConfig({
|
|
||||||
...latestConfig,
|
|
||||||
encryptionKey,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const pluginId = latestConfig?.activeAdapter || 'filesystem'
|
|
||||||
const adapterConfig = latestConfig?.adapters?.[pluginId] || {}
|
|
||||||
|
|
||||||
const adapter = pluginManager.getAdapter(
|
|
||||||
pluginId,
|
|
||||||
adapterConfig,
|
|
||||||
)
|
|
||||||
|
|
||||||
notesAPI = new NotesAPI(adapter, encryptionKey)
|
|
||||||
await notesAPI.init()
|
|
||||||
|
|
||||||
return notesAPI
|
|
||||||
})()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return initPromise
|
return initPromise
|
||||||
|
|||||||
@@ -15,11 +15,17 @@
|
|||||||
<span v-else class="date">{{ formatDate(note.updatedAt) }}</span>
|
<span v-else class="date">{{ formatDate(note.updatedAt) }}</span>
|
||||||
|
|
||||||
<div class="title-actions">
|
<div class="title-actions">
|
||||||
<button class="title bold" @click="openNote(note.id)">
|
<button
|
||||||
|
class="title bold"
|
||||||
|
@click="!deleteActive && openNote(note.id)"
|
||||||
|
>
|
||||||
{{ note.title }}
|
{{ note.title }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="action bold" @click="openNote(note.id)">
|
<button
|
||||||
|
class="action bold"
|
||||||
|
@click="!deleteActive && openNote(note.id)"
|
||||||
|
>
|
||||||
(open)
|
(open)
|
||||||
</button>
|
</button>
|
||||||
<button class="action bold move" @click="onMoveOpened">
|
<button class="action bold move" @click="onMoveOpened">
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export default () => {
|
|||||||
}
|
}
|
||||||
const loadNote = async (id) => {
|
const loadNote = async (id) => {
|
||||||
const api = await getNotesAPI()
|
const api = await getNotesAPI()
|
||||||
|
console.log(api)
|
||||||
return await api.getNote(id)
|
return await api.getNote(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user