Skip to content

fix: guard flexible update notice against double-posting#25681

Open
mvanhorn wants to merge 1 commit into
wordpress-mobile:trunkfrom
mvanhorn:fix/25666-showNotice-double-post-guard
Open

fix: guard flexible update notice against double-posting#25681
mvanhorn wants to merge 1 commit into
wordpress-mobile:trunkfrom
mvanhorn:fix/25666-showNotice-double-post-guard

Conversation

@mvanhorn

Copy link
Copy Markdown

Description

AppUpdatePresenter.showNotice(using:) now guards against posting a second flexible in-app-update notice while one is already showing, mirroring the existing already-on-top guard in showBlockingUpdate(using:).

Why this matters: showBlockingUpdate bails when a BlockingUpdateViewController is already on top (AppUpdatePresenter.swift:54-59), but showNotice posted the flexible notice with no equivalent guard. Because AppUpdateCoordinator creates a fresh presenter per call and the persisted day-granularity throttles (shouldFetchAppStoreInfo, shouldShowFlexibleUpdate) are frequency caps rather than in-flight dedup, two checkForAppUpdates() runs racing on cold launch could each reach showNotice and queue two identical "update available" notices shown back-to-back (#25666).

The fix tags the notice with a stable identifier and bails before posting if a notice with that tag is already the current notice in NoticeStore. This defends the presentation invariant independent of the fetch-side trigger, so it holds for any future caller that reaches showNotice twice. The day-granularity throttles are left untouched.

Fixes #25666

Testing instructions

Added presenter-level tests in AppUpdateCoordinatorTests:

  • A single showNotice posts exactly one flexible notice (tagged).
  • A second showNotice while one is already showing is suppressed, and dismissing the current notice leaves no queued duplicate.
  • After the current notice is cleared, a later showNotice can post again (the guard does not permanently latch).

swiftlint passes on the changed files. The full unit suite runs in CI.

AppUpdatePresenter.showNotice posted the flexible in-app-update notice
with no already-shown guard, so two checkForAppUpdates() runs racing on
cold launch could queue two identical notices back-to-back. Tag the
notice and bail if a notice with that tag is already the current notice
in NoticeStore, mirroring the existing showBlockingUpdate guard.

Fixes wordpress-mobile#25666
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.

AppUpdatePresenter.showNotice can double-post the flexible update notice (no already-shown guard)

1 participant