Re-implement building page tree hierarchy - #22345
Conversation
This is necessary to get up to date with a CI configuration change that requires running on Xcode 15.1. See #22270
Generated by 🚫 dangerJS |
@mokagio , this PR targets 24.0 and I think it may be worthy while to update the release notes to include this bug fix? |
|
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr22345-55fbfdb | |
| Version | 23.9 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 55fbfdb | |
| App Center Build | WPiOS - One-Offs #8372 |
|
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr22345-55fbfdb | |
| Version | 23.9 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 55fbfdb | |
| App Center Build | jetpack-installable-builds #7394 |
Sure. We're in luck in that the release notes haven't been sent to editorialization yet, so anything goes 😄 |



Fixes #22283. This PR is a follow-up of #22338.
While working on the issue yesterday, probably due to having a holiday break which made me look back at the implementation, I realised that I had over-engineered the implementation and made it unnecessarily complicated.
There is a big undocumented intention of using and maintaining a
PageTreestruct. I thought it'd be nice to use aPageTreestruct instance throughout the lifecyle of the Pages List, where we can add/remove pages to the instance as new pages are loaded from the server or when user deletes a page. That's why I didn't go with a pure function that turns a list of pages into another lists of pages.But since we are really hold onto
PageTreestruct instances in the view controller, and I don't foresee we are going to do that in any time soon, I decided to scratch the implementation and re-implementing using a pure function, which only has 30 lines of code and is pretty easy to read.Also, the new algorithm is much faster (about x3 times faster) and has 0(n) time complexity, because it builds an index of parent-child page before assembling them into a tree.
Regression Notes
Potential unintended areas of impact
None.
What I did to test those areas of impact (or what existing automated tests I relied on)
Verified Pages are not displayed in a hierarchy #22283
What automated tests I added (or what prevented me from doing so)
A few unit tests.
PR submission checklist:
RELEASE-NOTES.txtif necessary.UI Changes testing checklist: N/A