Folder model: derive roleOf and isServerSpecial from one attribute-to-role table #65

Closed
opened 2026-07-01 21:18:14 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-01 21:18:14 +00:00 (Migrated from github.com)

Origin: code review of PR #54. Reuse/maintainability — the divergence is already observable.

Problem

SPECIAL_USE_ATTRIBUTES (Folder.kt:60) is a second hand-maintained RFC 6154 attribute table sitting six lines below roleOf()'s attribute when-ladder (Folder.kt:45-49) in the same companion object. They already disagree: \all and \flagged are in the set but have no roleOf branch. Every future attribute change must now be made twice, or role classification and label de-duplication diverge.

The disagreement is live on one folder today: Mappers.kt:160-163 feeds the same attributes list to both functions, so a non-English Gmail account's All Mail (e.g. German "Alle Nachrichten", advertising \All) gets specialUse = true from isServerSpecial() yet role = NORMAL from roleOf() (no \all branch, and the English-only "all mail" display-name fallback misses) — treated as provider-special for label de-dup while sorting among user folders with no role icon. The roleOf gap itself predates PR #54; what #54 added is the second table that locks the drift in.

Suggested fix

One ordered Map<String, FolderRole?> in the companion (role-less entries like \flagged map to null):

  • roleOf = first non-null role among the folder's attributes (preserves the ladder's precedence),
  • isServerSpecial = any attribute is a key.

This also absorbs #62 (\Important becomes one more entry) and fixes the KDoc nit that \All is a standard RFC 6154 attribute, not a Gmail extension. Consider a \all → ARCHIVE mapping while here, which fixes the localized All-Mail role for free.

Origin: code review of PR #54. Reuse/maintainability — the divergence is already observable. ## Problem `SPECIAL_USE_ATTRIBUTES` (`Folder.kt:60`) is a second hand-maintained RFC 6154 attribute table sitting six lines below `roleOf()`'s attribute when-ladder (`Folder.kt:45-49`) in the same companion object. They already disagree: `\all` and `\flagged` are in the set but have no `roleOf` branch. Every future attribute change must now be made twice, or role classification and label de-duplication diverge. The disagreement is live on one folder today: `Mappers.kt:160-163` feeds the same attributes list to both functions, so a non-English Gmail account's All Mail (e.g. German "Alle Nachrichten", advertising `\All`) gets `specialUse = true` from `isServerSpecial()` yet `role = NORMAL` from `roleOf()` (no `\all` branch, and the English-only "all mail" display-name fallback misses) — treated as provider-special for label de-dup while sorting among user folders with no role icon. The `roleOf` gap itself predates PR #54; what #54 added is the second table that locks the drift in. ## Suggested fix One ordered `Map<String, FolderRole?>` in the companion (role-less entries like `\flagged` map to null): - `roleOf` = first non-null role among the folder's attributes (preserves the ladder's precedence), - `isServerSpecial` = any attribute is a key. This also absorbs #62 (`\Important` becomes one more entry) and fixes the KDoc nit that `\All` is a standard RFC 6154 attribute, not a Gmail extension. Consider a `\all → ARCHIVE` mapping while here, which fixes the localized All-Mail role for free.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#65