fix: make bulwark respect server limits

If you have a large number of tags, getTagCounts would not be able to get the
unread counts because it did not respect maxCallsInRequest, even though the
value was actually read out, it was just ignored. There are also other places
where the limits were not respected.

Batching is now generalized in a helper that also takes maxObjectsInSet, which
also was ignored, into account and is applied to all functions.

In addition, the dev mock now also advertises and enforces the limits, so these
issues can get picked up during development.

Possible closes #699
Possibly closes #399
This commit is contained in:
Mathy Vanvoorden
2026-07-30 22:11:40 +02:00
parent e659fe3d38
commit 1652a0ec62
8 changed files with 685 additions and 261 deletions
+8 -5
View File
@@ -949,15 +949,18 @@ export function Sidebar({
? buildKeywordTree(emailKeywords)
: emailKeywords.map((kw) => ({ ...kw, children: [], depth: 0 }));
// Counts arrive from a separate JMAP round trip; until they land, treat every
// "show if unread" tag as visible rather than blanking the section and
// filling it back in.
const tagCountsLoaded = Object.keys(tagCounts).length > 0;
// Counts arrive from a separate JMAP round trip, one batch per group of tags;
// a tag with no count yet is treated as visible rather than blanking it and
// filling it back in. A tag the server answered for with zero unread hides,
// which is the point of the setting.
const isTagVisible = (node: KeywordNode) => {
if (showAllTags || node.id === selectedKeyword) return true;
const visibility = getKeywordVisibility(node);
if (visibility === 'hide') return false;
if (visibility === 'unread') return !tagCountsLoaded || (tagCounts[node.id]?.unread ?? 0) > 0;
if (visibility === 'unread') {
const count = tagCounts[node.id];
return !count || count.unread > 0;
}
return true;
};
const visibleTagTree = filterKeywordTree(tagTree, isTagVisible);