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:
1 parent
dcfe2a667c
commit
41fbf0b7d9
5 files changed
+103
-19
No files matched your search
+6
-1
@@ -20,7 +20,12 @@ namespace jet {
|
||||
if (limit <= 0)
|
||||
limit = 50;
|
||||
|
||||
out = global.getImapSession(sessionId)->listMessages(folder, limit);
|
||||
std::string offsetStr = resolveKeyword("offset").str();
|
||||
int offset = offsetStr.empty() ? 0 : atoi(offsetStr.c_str());
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
|
||||
out = global.getImapSession(sessionId)->listMessages(folder, limit, offset);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user