Skip to content

Move some content group and styles to FormattableContentKit - #24265

Merged
mokagio merged 4 commits into
trunkfrom
mokagio/more-format-kit
Mar 24, 2025
Merged

Move some content group and styles to FormattableContentKit#24265
mokagio merged 4 commits into
trunkfrom
mokagio/more-format-kit

Conversation

@mokagio

@mokagio mokagio commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

These are needed by the WordPressData files, see #24242.

@dangermattic

dangermattic commented Mar 20, 2025

Copy link
Copy Markdown
Collaborator
2 Warnings
⚠️ Modules/Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages as appropriate to your project setup (e.g. in Xcode or by running swift package resolve).
⚠️ 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

Comment thread Modules/Package.swift
Comment on lines +79 to +87
"WordPressUI",
.product(name: "Gridicons", package: "Gridicons-iOS"),
// TODO: Remove — It's here just for a NSMutableParagraphStyle init helper
.product(name: "WordPressKit", package: "WordPressKit-iOS"),

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.

@mokagio
mokagio requested review from crazytonyli and kean March 20, 2025 09:43
@mokagio mokagio added this to the 25.9 milestone Mar 20, 2025
@wpmobilebot

wpmobilebot commented Mar 20, 2025

Copy link
Copy Markdown
Contributor
Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr24265-241b304
Version25.8
Bundle IDcom.jetpack.alpha
Commit241b304
App Center Buildjetpack-installable-builds #10837
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot

wpmobilebot commented Mar 20, 2025

Copy link
Copy Markdown
Contributor
WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr24265-241b304
Version25.8
Bundle IDorg.wordpress.alpha
Commit241b304
App Center BuildWPiOS - One-Offs #11813
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@kean

kean commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

There are a few types like Notification that are dependent on on FormattableContentKit but mainly as a convenient way to cache some data:

/// Subject Blocks Transient Storage.
///
fileprivate var cachedSubjectContentGroup: FormattableContentGroup?

Would it be possible to extract these extensions and move them to the app target? They could use objc_assocciatedObject for caching.

Files like these do not belong to FormattableContentKit:

Modules/Sources/FormattableContentKit/Styles/WPStyleGuide+Notifications.swift

@mokagio

mokagio commented Mar 21, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @kean.

In my haste of getting WordPressData to build and run, I might be spending too little time evaluating what should be moved and what could be reworked.

I'll have a look here after closing #24267

@mokagio

mokagio commented Mar 21, 2025

Copy link
Copy Markdown
Contributor Author

So I've been looking into this a bit and it's not straightforward. The main blocker is that Notification (an NSManagedObject which we need to move to WordPressData) uses the logic directly related to FormattableContentKit in its deinit.

I'm going to play around with this more on my Monday.

@kean

kean commented Mar 21, 2025

Copy link
Copy Markdown
Contributor

the logic directly related to FormattableContentKit in its deinit.

I see. So it observes some of its own properties to reload the cached attributes. These properties can be observed from the outside – similarly to how we use ImageLoadingController with its lifetime tied to the associated image view.

// Name arbitrary 
final class NotificationFormattableContentController {
    weak var notification: Notification?

    private var cachedSubjectContentGroup: FormattableContentGroup?
    // ... 
 
    deinit {
        // Remove KVO observation
    }

    init(notification: Notification) {
        // 1. Set up obsever
        // 2. Set as associated object 
    }
}

ideally, I would just add NotificationViewModel, put the "formattable" code there, and use it in the UI. I'm not sure if it's going to be easy though. I'd just go with what's faster for now.

@mokagio
mokagio force-pushed the mokagio/more-format-kit branch from 8c75698 to 241b304 Compare March 24, 2025 10:01
@mokagio

mokagio commented Mar 24, 2025

Copy link
Copy Markdown
Contributor Author

I'd just go with what's faster for now.

Thanks @kean! I'll cash this is and log a tech debt issue, #24298, to address this later.

@mokagio
mokagio added this pull request to the merge queue Mar 24, 2025
Merged via the queue into trunk with commit 734161a Mar 24, 2025
@mokagio
mokagio deleted the mokagio/more-format-kit branch March 24, 2025 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants