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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user