Skip to content

Access local window instead of via UIApplication or UIApplicationDelegate#25672

Open
crazytonyli wants to merge 9 commits into
trunkfrom
task/scene-api-adoption
Open

Access local window instead of via UIApplication or UIApplicationDelegate#25672
crazytonyli wants to merge 9 commits into
trunkfrom
task/scene-api-adoption

Conversation

@crazytonyli

Copy link
Copy Markdown
Contributor

There are many places in the app that access UIWindow instance via the app-wide API UIApplication or UIApplicationDelegate. This PR refactors some of those usages to rely on local context via view or view controller.

@crazytonyli crazytonyli added this to the 27.1 milestone Jun 18, 2026
@crazytonyli crazytonyli requested a review from jkmassel June 18, 2026 22:05
@crazytonyli crazytonyli enabled auto-merge June 18, 2026 22:05
@dangermattic

dangermattic commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number32848
VersionPR #25672
Bundle IDorg.wordpress.alpha
Commit78c2d08
Installation URL6ii6ifvmr4u10
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number32848
VersionPR #25672
Bundle IDcom.jetpack.alpha
Commit78c2d08
Installation URL4772nrds2omsg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jkmassel jkmassel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change, but then this is good.

One other thing – it seems ReaderDetailFeaturedImageView might not be used anywhere?

func startLoading() {
activityIndicatorView.startAnimating()
UIApplication.shared.mainWindow?.isUserInteractionEnabled = false
view.window?.isUserInteractionEnabled = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be super rare, but it's possible for this view to change and break the entire window.

I wonder if we should either:

  1. Not disable the entire window
  2. Capture the window reference until stopLoading?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's possible for this view to change and break the entire window.

Do you mean like calling startLoading without calling stopLoading afterward?

Capture the window reference until stopLoading?

Is the concern that view.window in stopLoading becomes nil, like it's called after the view controller is dismissed?

The concerns seem to be around making these two functions more error-proof for the future. I think one solution could be getting rid of the startLoading and stopLoading functions and moving them inline to the caller. They are private and used in one place after all. 😆

Not disable the entire window

I'm not very keen on this change, because I just checked tracks that the involved interaction (disconnecting Jetpack) only happens once per day, so it's probably not worth changing the UX.

@crazytonyli

Copy link
Copy Markdown
Contributor Author

it seems ReaderDetailFeaturedImageView might not be used anywhere?

Good catch. I'll remove it.

@crazytonyli crazytonyli requested a review from jkmassel June 25, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants