mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-31 16:13:15 +00:00
Calendar/contact aggregation left the ACTIVE account's ids raw while namespacing background accounts (<localAccountId>::id). So an entity's id depended on which account was active; switching flipped the id form and invalidated persisted references (selectedCalendarIds), broke isSubscription matching, and destabilised selection - the account-switch bug users saw in Calendar and Address Book (mail was fine: it keys per account + stable virtual ids). Invariant now: an entity is namespaced iff it carries a localAccountId; originalId always holds the raw JMAP id. Consumers/mutations already resolve the raw id via `originalId || stripLocalAccountPrefix`, so they are unchanged. - prefix* functions (calendar + contacts) always namespace + set originalId; drop the isActiveAccount branch and the now-dead activeLocalAccountId params (callers in the hooks + calendar-app/contacts-app updated). - mapServerEventToStoreEvent namespaces the event id with the matched calendar's localAccountId, so createEvent/updateEvent results are consistent. - reconcileSelectedIds(): remap selectedCalendarIds by raw identity on every fetch, so a raw->namespaced transition (switch, just-created calendar, or the one-time migration from old persisted raw ids) keeps the selection instead of resetting to "all". - isSubscriptionCalendar(): namespace-robust and collision-safe - resolve the calendar and match by raw id scoped to the owning JMAP accountId (Stalwart's raw ids like "b"/"c" collide across accounts). +9 unit tests (selection stability across switch/create, subscription robustness, no cross-account false positives). tsc + eslint clean; 368 store tests green.