wordpress-mobile / wordpress-mobile/WordPress-iOS
ReaderPost performs double-save on the ContextManager when saved
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 3.9k
- Forks
- 1.2k
- Avg merge
- 23h 51m
- Merged PRs (30d)
- 58
Description
Refs https://github.com/wordpress-mobile/WordPress-iOS/pull/19765#issuecomment-1345181064
Currently, when saving a post in the Reader, a didSave hook is implemented on ReaderPost to update the parent object, ReaderCard:
As quoted above, the didSave method made another save call to ContextManager, effectively double-saving every time a post is saved. This can make Core Data operations slightly less visible, and might introduce side effects (i.e., the issue described in #19765). As an idea, we can look into moving this part of the logic to the post-saving logic described in https://github.com/wordpress-mobile/WordPress-iOS/pull/19765#pullrequestreview-1212232664.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in WordPress/Classes/Models/ReaderPost.m around lines 513-522 and inspect the didSave hook, then read the post-saving logic discussed in PR #19765. Trace how ReaderPost updates its parent ReaderCard and calls ContextManager. Done means saving a ReaderPost no longer causes a second ContextManager save while the parent update still occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, objective-c
- Domain
- database, mobile
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100