Auto-load notes on notes workspace startup for existing sessions
This commit is contained in:
+24
-3
@@ -504,6 +504,29 @@
|
|||||||
writeOutput({ message: 'PocketBase session cleared.' });
|
writeOutput({ message: 'PocketBase session cleared.' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function bootstrapWorkspace() {
|
||||||
|
try {
|
||||||
|
const client = await ensurePocketBaseClient();
|
||||||
|
const config = await getPocketBaseConfig();
|
||||||
|
|
||||||
|
if (client.authStore?.token) {
|
||||||
|
try {
|
||||||
|
await client.collection(config.collection).authRefresh();
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await updatePbStatus();
|
||||||
|
if (client.authStore?.isValid) {
|
||||||
|
await loadNotes();
|
||||||
|
} else {
|
||||||
|
writeOutput('Login to load notes.');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
writeOutput({ error: error?.message || String(error) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function loadNotes() {
|
async function loadNotes() {
|
||||||
await ensurePocketBaseClient();
|
await ensurePocketBaseClient();
|
||||||
ensureLoggedIn();
|
ensureLoggedIn();
|
||||||
@@ -614,9 +637,7 @@
|
|||||||
searchInput.addEventListener('input', () => renderList());
|
searchInput.addEventListener('input', () => renderList());
|
||||||
hiddenMode.addEventListener('change', () => renderList());
|
hiddenMode.addEventListener('change', () => renderList());
|
||||||
|
|
||||||
ensurePocketBaseClient()
|
bootstrapWorkspace();
|
||||||
.then(() => updatePbStatus())
|
|
||||||
.catch((error) => writeOutput({ error: error?.message || String(error) }));
|
|
||||||
clearForm();
|
clearForm();
|
||||||
renderList();
|
renderList();
|
||||||
loadHealth();
|
loadHealth();
|
||||||
|
|||||||
Reference in New Issue
Block a user