Align notes workspace filter/load behavior with legacy records
This commit is contained in:
+23
-10
@@ -143,7 +143,8 @@
|
||||
<div class="mt-4 grid gap-3 md:grid-cols-2">
|
||||
<input id="searchInput" class="field" placeholder="Search notes..." />
|
||||
<select id="hiddenMode" class="field">
|
||||
<option value="visible" selected>Show Visible</option>
|
||||
<option value="all" selected>Show All</option>
|
||||
<option value="visible">Show Visible</option>
|
||||
<option value="hidden">Show Hidden</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -352,13 +353,12 @@
|
||||
}
|
||||
|
||||
function passFilter(note) {
|
||||
if (toBoolFlag(note?.delete)) return false;
|
||||
|
||||
const wantHidden = hiddenMode.value === 'hidden';
|
||||
const isHidden = toBoolFlag(note?.hidden);
|
||||
if (wantHidden !== isHidden) return false;
|
||||
const hiddenView = hiddenMode.value;
|
||||
if (hiddenView === 'visible' && isHidden) return false;
|
||||
if (hiddenView === 'hidden' && !isHidden) return false;
|
||||
|
||||
if (currentFilter === 'myshared' && !(isMine(note) && toBoolFlag(note?.shared))) return false;
|
||||
if (currentFilter === 'myshared' && !toBoolFlag(note?.shared)) return false;
|
||||
if (currentFilter === 'sharedwithme' && !isSharedWithCurrentUser(note)) return false;
|
||||
if (currentFilter === 'job' && !(toBoolFlag(note?.job_note) || noteType(note) === 'job')) return false;
|
||||
if (currentFilter === 'manager' && noteType(note) !== 'manager') return false;
|
||||
@@ -507,10 +507,23 @@
|
||||
async function loadNotes() {
|
||||
await ensurePocketBaseClient();
|
||||
ensureLoggedIn();
|
||||
const records = await pb.collection(NOTES_COLLECTION).getFullList({
|
||||
sort: '-updated,-created',
|
||||
});
|
||||
allNotes = Array.isArray(records) ? records : [];
|
||||
let records = [];
|
||||
try {
|
||||
const page = await pb.collection(NOTES_COLLECTION).getList(1, 200, {
|
||||
sort: '-updated,-created',
|
||||
});
|
||||
records = Array.isArray(page?.items) ? page.items : [];
|
||||
} catch {
|
||||
const full = await pb.collection(NOTES_COLLECTION).getFullList({
|
||||
sort: '-updated,-created',
|
||||
});
|
||||
records = Array.isArray(full) ? full : [];
|
||||
}
|
||||
|
||||
allNotes = records.map((note) => ({
|
||||
...note,
|
||||
_sharedWithMe: isSharedWithCurrentUser(note),
|
||||
}));
|
||||
if (selectedNote) {
|
||||
const refreshed = allNotes.find((n) => n.id === selectedNote.id);
|
||||
selectedNote = refreshed || null;
|
||||
|
||||
Reference in New Issue
Block a user