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.' });
|
||||
}
|
||||
|
||||
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() {
|
||||
await ensurePocketBaseClient();
|
||||
ensureLoggedIn();
|
||||
@@ -614,9 +637,7 @@
|
||||
searchInput.addEventListener('input', () => renderList());
|
||||
hiddenMode.addEventListener('change', () => renderList());
|
||||
|
||||
ensurePocketBaseClient()
|
||||
.then(() => updatePbStatus())
|
||||
.catch((error) => writeOutput({ error: error?.message || String(error) }));
|
||||
bootstrapWorkspace();
|
||||
clearForm();
|
||||
renderList();
|
||||
loadHealth();
|
||||
|
||||
Reference in New Issue
Block a user