-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract ContextManager
usages behind CoreDataStack
#24191
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,11 @@ import WordPressKit | |
|
||
/// Init method for Objective-C. | ||
/// | ||
@objc init(contextManager: ContextManager) { | ||
self.coreDataStack = contextManager | ||
@objc init(contextManager: CoreDataStack) { | ||
guard let typeCastStack = contextManager as? CoreDataStackSwift else { | ||
fatalError("Expected a CoreDataStackSwift-conforming type even though this initializer is marked @objc.") | ||
} | ||
self.coreDataStack = typeCastStack | ||
Comment on lines
-22
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not proud of this one. I don't know if there's a neater way to go about it because if Luckily, this hack has to be used only twice, so I think we can live with it...? Of course, one possible solution would be to convert the Objective-C consumers to Swift... But I think we ought to focus on moving forward with the Core Data migration at the moment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, it'd be okay to remove the argument and use the shared instance internally. |
||
} | ||
|
||
init(coreDataStack: CoreDataStackSwift = ContextManager.shared) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,9 @@ struct UITestConfigurator { | |
|
||
private static func resetEverything() { | ||
// Remove CoreData DB | ||
ContextManager.shared.resetEverything() | ||
// | ||
// We can afford to force cast here because we are in a test-specific code | ||
(ContextManager.shared as! ContextManager).resetEverything() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In particular, this code will run only in the UI tests and only if a certain launch argument is given |
||
|
||
// Clear user defaults. | ||
for key in UserDefaults.standard.dictionaryRepresentation().keys { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR, I decided not to rename the
contextManager
variable that now haveCoreDataStackSwift
to keep the diff smaller.We might want to do it later on, but it does not seem urgent.