Skip to content

Decouple some model implementations from the app targets - Round 2 - #24349

Merged
mokagio merged 12 commits into
trunkfrom
mokagio/decouple-round-2
Mar 28, 2025
Merged

Decouple some model implementations from the app targets - Round 2#24349
mokagio merged 12 commits into
trunkfrom
mokagio/decouple-round-2

Conversation

@mokagio

@mokagio mokagio commented Mar 28, 2025

Copy link
Copy Markdown
Contributor

Same rationale as #24331. Part of #24165. The end goal is to have the diff in #24242 to be as little as possible, so that we can easily identify issues.

I added rationales in the commit messages, and commit by commit is likely the best way to review the changes.

mokagio added 12 commits March 28, 2025 11:08
I don't remember why in the context of the #24165 work this gave
problem, other than it wouldn't compile.

Given the types being compared as `String`, using Swift's `==` seems
like a better solution anyway.
This unblocks finding the `xcdatamodeld` once both `ContextManager` and
the Core Data schema are part of the same framework.
This way, once it's in the WordPressData framework, it'll be accessible
by consumers.
The `Notification` model is littered with functionality that has to do
with the view layer. To move `Notification` to WordPressData in a timely
fashion, we need to separate the model description from all that other
logic.
That's where they're used, and they're not needed in WordPressData.
Again, this simplifies moving to WordPressData without having to carry
along additional dependencies
@mokagio
mokagio requested review from crazytonyli and kean and removed request for crazytonyli March 28, 2025 00:36
@mokagio mokagio self-assigned this Mar 28, 2025
@mokagio mokagio added the Core Data Issues related to Core Data label Mar 28, 2025
@mokagio mokagio added this to the 25.9 milestone Mar 28, 2025
@dangermattic

Copy link
Copy Markdown
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 25.9. 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

@wpmobilebot

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

@wpmobilebot

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

@mokagio
mokagio enabled auto-merge March 28, 2025 02:40

@kean kean 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.

Approved, left a couple of nits.

/// Header Blocks Transient Storage.
///
fileprivate var cachedHeaderContentGroup: FormattableContentGroup?
public var cachedHeaderContentGroup: FormattableContentGroup?

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.

(nit) Let's extract NotificationsFormattableContentCache (or similar name) and document that it's for internal purposes. I'd suggest doing in a separate PR (or never).

private extension ContextManager {
static func createPersistentContainer(storeURL: URL, modelName: String) -> NSPersistentContainer {
guard var modelFileURL = Bundle.main.url(forResource: "WordPress", withExtension: "momd") else {
guard var modelFileURL = Bundle(for: ContextManager.self).url(forResource: "WordPress", withExtension: "momd") else {

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.

Just noting this change. I tested it and it works as Bundle(for: ContextManager.self) returns Bundle.main. I'm not sure if this change belongs in this PR, but I don't have strong feelings about. If it gets merged as part of it, it's totally fine.

@mokagio
mokagio added this pull request to the merge queue Mar 28, 2025
Merged via the queue into trunk with commit 58f73c0 Mar 28, 2025
@mokagio
mokagio deleted the mokagio/decouple-round-2 branch March 28, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core Data Issues related to Core Data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants