Skip to content

Commit

Permalink
Merge pull request #5 from hegerdes/fix/notebook-pagination
Browse files Browse the repository at this point in the history
fix: show all notebook in selector - closes #4
  • Loading branch information
hegerdes committed Jan 13, 2024
2 parents 64546f7 + 9c93cda commit 09e8c57
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,23 @@ export const setDialogHTML = async (dialog: string) => {

// Get all Notebooks with id and name
export const createNotebookList = async () => {
const folders = await joplin.data.get(["folders"]);
return folders.items.reduce(
(obj, item) => Object.assign(obj, { [item.id]: item.title }),
{}
);
const out = new Map<string, string>();
let pageNum = 1;
let data = await joplin.data.get(["folders"], {
limit: notes_query_limit,
page: pageNum,
});

data.items.forEach((entry) => out.set(entry.id, entry.title));
while (data.has_more) {
pageNum++;
data = await joplin.data.get(["folders"], {
limit: notes_query_limit,
page: pageNum,
});
data.items.forEach((entry: JoplinNote) => out.set(entry.id, entry.title));
}
return Object.fromEntries(out);
};

// Create HTML options of notebooks
Expand Down

0 comments on commit 09e8c57

Please sign in to comment.