Skip to content

refactor(events): change connectionUpdated payload from Void to UUID? for per-connection filtering#1159

Merged
datlechin merged 1 commit into
mainfrom
refactor/connection-updated-uuid-payload
May 9, 2026
Merged

refactor(events): change connectionUpdated payload from Void to UUID? for per-connection filtering#1159
datlechin merged 1 commit into
mainfrom
refactor/connection-updated-uuid-payload

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

AppEvents.connectionUpdated payload changes from PassthroughSubject<Void, Never> to PassthroughSubject<UUID?, Never>. The payload is the affected connection's id, or nil for bulk updates where the sender doesn't track individual ids.

Senders updated (9 sites):

  • Single-connection: ConnectionFormCoordinator.deleteCurrent, ConnectionFormCoordinator.save (insert + update branches), sample-DB launcher (open + reset), per-connection iCloud-sync toggle in WelcomeContextMenus -> pass connection.id.
  • Bulk: SyncCoordinator.applyRemoteChanges, ConnectionExportService.importConnections, multi-select iCloud-sync toggle in WelcomeContextMenus -> pass nil.

Subscribers: WelcomeViewModel is the only current subscriber and it discards the payload ({ _ in self?.loadConnections() }); the welcome list shows every connection so a payload-agnostic refresh is correct. The new payload type is binary-source-compatible with that closure shape.

Why this matters

Audit finding X2. The audit recommends matching the same shape as ConnectionStatusChange and DatabaseDidConnect, which already carry the affected connectionId so per-connection subscribers can filter. Today there are no per-connection subscribers, but the same anti-pattern that PR #1139 had to fix (mainCoordinatorTeardown that lacked a payload) and PR #1148 had to fix (databaseDidConnect subscribers that ignored the payload) starts here: every event the welcome list has to consume is also visible to any future per-coordinator subscriber, and without a payload that subscriber would have to refresh on every unrelated edit.

Test plan

  • Edit a connection name on the welcome window; confirm the welcome list refreshes.
  • Run a full sync pull that updates many connections; confirm welcome list refreshes once via nil event.
  • Open the sample database; confirm welcome refreshes.
  • Bulk toggle iCloud-sync on multiple selected connections via context menu; confirm welcome refreshes.
  • swiftlint --strict clean.

@datlechin datlechin merged commit 83e51c9 into main May 9, 2026
2 checks passed
@datlechin datlechin deleted the refactor/connection-updated-uuid-payload branch May 9, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant