Add pagination to the email list (was hardcoded to newest 50, no way to see older mail)

listMessages() only ever fetched everything then kept the newest
limit (default 50) messages, with no offset parameter and no way for
the client to know how many messages existed beyond what it was
shown - older mail was completely unreachable through the webmail UI.

__imap::listMessages() now takes an offset (counted back from the
newest message) and returns {"total":N,"messages":[...]} instead of
a bare array, so the client can page backward/forward and know when
it has reached either end. __imaplist tag and /email/list both pass
offset through; /email/search is unchanged (search results are not
paginated). email.js tracks currentOffset (reset alongside
currentFolder/currentUid at every existing reset site), and renders
Prev/Next controls next to the unread count showing the current
1-based range and total.
This commit is contained in:
Brad Arant committed 2026-09-07 04:20:42 +00:00
1 parent dcfe2a667c
commit 41fbf0b7d9
5 files changed
+103 -19

No files matched your search

+3 -1
View File
@@ -55,7 +55,9 @@ namespace jet {
// just write whatever this returns straight into their own `out`,
// the same one-call-does-everything shape __sql's query() call
// has relative to <sql>.
coreutils::MString listMessages(const std::string &folder, int limit);
/// offset counts back from the newest message (0 = the newest
/// page); the returned JSON is {"total":N,"messages":[...]}.
coreutils::MString listMessages(const std::string &folder, int limit, int offset);
coreutils::MString searchMessages(const std::string &folder, const std::string &query);
coreutils::MString fetchMessage(const std::string &folder, uint32_t uid);
coreutils::MString setFlag(const std::string &folder, uint32_t uid, const std::string &flag, bool add);