Skip to content

ReaderPost performs double-save on the ContextManager when saved #19771

@dvdchr

Description

@dvdchr

Refs #19765 (comment)

Currently, when saving a post in the Reader, a didSave hook is implemented on ReaderPost to update the parent object, ReaderCard:

- (void) didSave {
[super didSave];
// A ReaderCard can have either a post, or a list of topics, but not both.
// Since this card has a post, we can confidently set `topics` to NULL.
if ([self respondsToSelector:@selector(card)] && self.card.count > 0) {
self.card.allObjects[0].topics = NULL;
[[ContextManager sharedInstance] saveContext:self.managedObjectContext];
}
}

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 #19765 (review).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions