Skip to content

Improve TimeZonePickerViewController#24612

Merged
kean merged 9 commits intotrunkfrom
task/rework-timezone-picker
Jun 26, 2025
Merged

Improve TimeZonePickerViewController#24612
kean merged 9 commits intotrunkfrom
task/rework-timezone-picker

Conversation

@kean
Copy link
Contributor

@kean kean commented Jun 20, 2025

  • Implement TimeZonePickerViewController using SwiftUI and without TimeZoneStore (WordPressFlux)
  • Improve search by using RankedStringSearch and passing additional fields in search
  • Highlight the currently selected values in the picker (bolder font)

Screenshots

Left – before. Right – after.

Here's an example where search would previously return poor result as it was looking was the wrong values:

Screenshot 2025-06-20 at 3 44 37 PM

Note: the screenshots are a bit old. I increased the cell height to closer match the original.

Screenshot 2025-06-20 at 3 37 30 PM Screenshot 2025-06-20 at 3 35 04 PM

@kean kean added this to the 26.0 milestone Jun 20, 2025
@kean kean requested a review from crazytonyli June 20, 2025 20:09
@dangermattic
Copy link
Collaborator

2 Warnings
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 26.0. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger


@objc public func showTimezoneSelector() {
let controller = TimeZoneSelectorViewController(selectedValue: timezoneValue) { [weak self] (newValue) in
self?.navigationController?.popViewController(animated: true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The screen now dismisses itself.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 20, 2025

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 Number28011
VersionPR #24612
Bundle IDorg.wordpress.alpha
Commit4f77d3a
Installation URL537f156b7e098
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 20, 2025

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 Number28011
VersionPR #24612
Bundle IDcom.jetpack.alpha
Commit4f77d3a
Installation URL6ucd5l2dml2k0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@kean
Copy link
Contributor Author

kean commented Jun 20, 2025

Update: I also changed how suggestions are displayed to make it clearer what timezones is suggested and also reuse the code:

Screenshot 2025-06-20 at 5 29 18 PM


init(selectedValue: String?, onSelection: @escaping (WPTimeZone) -> Void) {
self.onSelection = onSelection
self._viewModel = StateObject(wrappedValue: TimeZoneSelectorViewModel(selectedValue: selectedValue))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the issue mentioned in #24072 (comment) apply here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not in practice, but let's just get rid of it. We only need previously selectedValue and it can be a plain property - updated.

func loadTimezones() async {
guard !isLoading else { return }

isLoading = true
Copy link
Contributor

Choose a reason for hiding this comment

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

I personally like to add a defer { isLoading = false } right below this line. The relevant code is kept together, and most importantly, prevents the issue where the function body returns in the middle of execution before isLoading = false is executed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't write this – this entire file is generated 😄

I verified it all, and as long as it worked and was good enough for readability, I kept it as it to minimize the amount of busy work moving things around. I'd suggest to focus more on the substance as there is going to be some maybe sub-optimal constructs, but as long as they are correct and readable, I'd keep it as is. Do you agree?

Copy link
Contributor

Choose a reason for hiding this comment

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

I forgot to mention this particular comment was a nitpick.

To your question about code quality, I don't think we should use a lower standard just because the code is generated by AI. It's in the codebase, it'll run in production, the same way our own code does.

Again, feel free to leave the isLoading code as it is. My suggestion was just a personal preference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I wouldn't lower the standards, and I change a lot of the code manually, including some style changes – so it's not just straight up one-prompt. In the future, I think it's a matter of adjusting the prompts to get it to follow more of the coding standards. It's a bit tricky because there aren't really well established and are not in writing.

In the example, there is an argument to be made that not using defer is simpler as it's one less relatively non-trivial language feature to use. The generate code tends to be simpler and use simpler primitives, which I personally prefer as it makes it easy to review. If it's simple and readable, I keep it as is optimizing for development speed.

@kean kean requested a review from crazytonyli June 25, 2025 21:31
@kean kean force-pushed the task/rework-timezone-picker branch from 5f468de to 10fe744 Compare June 26, 2025 12:21
@kean kean enabled auto-merge June 26, 2025 12:23
@sonarqubecloud
Copy link

@kean kean added this pull request to the merge queue Jun 26, 2025
Merged via the queue into trunk with commit d19dacf Jun 26, 2025
32 of 34 checks passed
@kean kean deleted the task/rework-timezone-picker branch June 26, 2025 13:27
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