Move ReachabilityUtils to WordPressShared - #24267
Conversation
Generated by 🚫 Danger |
3fef4e5 to
3d7c75b
Compare
|
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr24267-7faaf9b | |
| Version | 25.8 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 7faaf9b | |
| App Center Build | jetpack-installable-builds #10863 |
|
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr24267-7faaf9b | |
| Version | 25.8 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 7faaf9b | |
| App Center Build | WPiOS - One-Offs #11840 |
ReachabilityUtils to WordPressShared
b8335c4 to
91c8d33
Compare
Thanks @crazytonyli I'll have a look 👀 |
b72ff41 to
4fe98c1
Compare
| [self preloadComments]; | ||
| [self preloadMetadata]; | ||
| [self preloadDomains]; | ||
| if ([ReachabilityUtils.internetReachability isReachableViaWiFi] == false) { |
There was a problem hiding this comment.
Notice this accesses Reachability. I think we could work on this further and hide the library altogether under ReachabilityUtils. That is, this could call a method on ReachabilityUtils instead—law of Demeter
There was a problem hiding this comment.
If this makes sense to you, I'll create an issue to address this once #24165 is "done"
There was a problem hiding this comment.
The Reachability library probably can be replaced with NWPath, but that's perhaps a story for another day.
|
|
||
| WordPressAppDelegate *appDelegate = [WordPressAppDelegate shared]; | ||
| [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:appDelegate.internetReachability]; | ||
| [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:ReachabilityUtils.internetReachability]; |
There was a problem hiding this comment.
I converted the code here to pass the same Reachability instance, but I think we could omit it.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification];From the docs:
The object that sends notifications to the observer. Specify a notification sender to deliver only notifications from this sender.
When nil, the notification center doesn’t use sender names as criteria for delivery.
The handler method does
- (void)reachabilityChanged:(NSNotification *)notification
{
Reachability *reachability = notification.object;
if (reachability.isReachable) {
[self initStats];
}
}We could replace add the info about connectivity as userInfo in the Notification and then we'd be good.
| 24CE68B42CD3375300C7B37D /* Exceptions for "Classes" folder in "WordPressUITests" target */ = { | ||
| 24CE68AF2CD3375300C7B37D /* Exceptions for "Classes" folder in "WordPressShareExtension" target */ = { | ||
| isa = PBXFileSystemSynchronizedBuildFileExceptionSet; | ||
| membershipExceptions = ( | ||
| "Extensions/UIApplication+MainWindow.swift", | ||
| "Utility/App Configuration/AppConfiguration.swift", |
There was a problem hiding this comment.
Mmm... this and the rest of the diff look like a bad rebase
d94ca6d to
ba440e7
Compare
…yUtils` Co-authored-by: Tony Li <tony.li@automattic.com>
This is not a design choice but a necessity as we now use `ReachabilityUtils` without passing through the application delegate to check connectivity.
ba440e7 to
7faaf9b
Compare


Problem
As part of #24165, there are certain pieces that need to be moved which depend on
ReachabilityUtilsan helper object that is also shared with the apps targets.Solution
ReachabilityUtilsand the underlyingReachabilityAlertin SwiftI considered moving it to a dedicated package because I thought it used the actual Reachability library, but that turned out not to be the case.
I considered ditching this utility that does not support injection or testing, but decided against it to focus on #24165 instead.