Skip to content

Conversation

jkmassel
Copy link
Contributor

What?

Android uses a configuration builder which is much cleaner around mutability. This PR adds a configuration builder to iOS as well.

Why?

The configuration has concerning mutability – it should never change after it's created because it's injected at the start. Once it starts being consumed, changes to it don't apply elsewhere, so by making it immutable it's harder to use it wrong.

How?

Builder pattern

Testing Instructions

Covered by new unit tests.

@jkmassel jkmassel requested review from dcalhoun and crazytonyli May 30, 2025 17:54
@jkmassel jkmassel added the [Type] Enhancement A suggestion for improvement. label May 30, 2025
@jkmassel jkmassel force-pushed the align/configuration-builder branch 3 times, most recently from 786184c to 77be22f Compare May 30, 2025 18:11
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

At a high level, this makes sense to me. Solid improvements—thank you! Testing the Demo app worked as expected.

This is likely already understood, but building WP-iOS with these changes fails currently. Before merging this, we should open a sibling PR updating the WP-iOS implementation.

That said, I wanted to address the following:

The configuration has concerning mutability – it should never change after it's created because it's injected at the start. Once it starts being consumed, changes to it don't apply elsewhere, so by making it immutable it's harder to use it wrong.

It's not entirely true that mutations do not have an impact at the moment, because we explicitly rely upon mutating the configuration to set the editor settings and start the editor after the host app fetches the settings.

I am quite confident that code could/should be refactored to be less complex. There are a couple of nuances to consider:

  1. We "warm up" the editor on the My Site tab with an empty configuration;
  2. Within init, we initialize the editor configuration and view controller;
  3. And within viewDidLoad, we display an activity indicator and fetch the editor settings.

These nuances could likely be refactored to embrace immutable configuration while retaining the necessary loading sequence.

@jkmassel
Copy link
Contributor Author

jkmassel commented Jun 9, 2025

@dcalhoun – I broadly agree with your comment. IMHO having two methods on the editor like init and updateConfiguration both of which take an immutable configuration would make a ton of sense, and would make it clear that simply updating the configuration object doesn't cause the underlying editor to change in any way.

I'm happy to leave this PR with you, feel free to do with it what you think is best!

@dcalhoun
Copy link
Member

dcalhoun commented Jul 9, 2025

@crazytonyli in addition to help with wordpress-mobile/WordPress-iOS#24662 (comment), I welcome your review of these changes now that I've rebased it atop the latest trunk branch. Thank you!

@dcalhoun dcalhoun force-pushed the align/configuration-builder branch from 26c3afa to d81b8ca Compare August 5, 2025 13:09
jkmassel and others added 8 commits September 10, 2025 17:32
Apply iOS conditionals used in other, existing code.
This was changed while making the tests pass when running on macOS, but
it is unclear why the original CI script was changed. Presumably we
should run the tests with a fixed device on the CI.

debc1c7#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52L62
This functionality was removed in the trunk branch.
@jkmassel jkmassel force-pushed the align/configuration-builder branch from d81b8ca to cb325d6 Compare September 10, 2025 23:34
@jkmassel jkmassel enabled auto-merge (squash) September 10, 2025 23:34
@jkmassel jkmassel merged commit 601a9a8 into trunk Sep 10, 2025
11 checks passed
@jkmassel jkmassel deleted the align/configuration-builder branch September 10, 2025 23:53
@dcalhoun
Copy link
Member

@jkmassel unfortunately, this is a breaking change. Would you be willing to resolve the incompatible types and finish the WP-iOS integration? Alternatively, we could revert this change for the time being.

@dcalhoun
Copy link
Member

@jkmassel I'll also note that GBK cookie configuration was removed from iOS in #157. I see that fc28a0a re-added iOS cookie configuration.

We should either remove cookie configuration again or finish reinstating it—ensuring we set them for the WebView and updating the WP-iOS integration.

Currently, WP-iOS relies upon the shared global cookie jar used by the WebView. GBK's cookie logic clears that out when launching its own WebView. We'd need to update WP-iOS to address this.

@dcalhoun dcalhoun mentioned this pull request Sep 11, 2025
@dcalhoun
Copy link
Member

@jkmassel it looks like this also reinstated the WebView globals removed in #172. I suggest we remove that too. It is now unused.

jkmassel added a commit that referenced this pull request Sep 11, 2025
@dcalhoun dcalhoun mentioned this pull request Sep 12, 2025
dcalhoun added a commit that referenced this pull request Sep 17, 2025
dcalhoun added a commit that referenced this pull request Sep 19, 2025
* Remove WebViewGlobals

#146 (comment)

* Change `editorSettings` to a `String`

The host app doesn’t need to parse it, so we can pass the raw settings

* Fix tests

* Add EditorConfigurationBuilder helper

* Remove cookie configuration

* Add tests

* docs: Fix comment typo

---------

Co-authored-by: David Calhoun <github@davidcalhoun.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants