Conversation
|
|
||
|
|
||
| extension SharingAccountViewController: NoResultsViewControllerDelegate | ||
| { |
There was a problem hiding this comment.
Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
| let title = NSLocalizedString("No Accounts Found", | ||
| comment:"Title of an error message. There were no third-party service accounts found to setup sharing.") | ||
| let message = NSLocalizedString("Sorry. The social service did not tell us which account could be used for sharing.", | ||
| comment:"An error message shown if a third-party social service does not specify any accounts that an be used with publicize sharing.") |
There was a problem hiding this comment.
Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)
|
|
||
| fileprivate func showNoResultsViewController() { | ||
| let title = NSLocalizedString("No Accounts Found", | ||
| comment:"Title of an error message. There were no third-party service accounts found to setup sharing.") |
There was a problem hiding this comment.
Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)
…nto issues/update-facebook-sharing
Generated by 🚫 Danger |
|
@aerych I believe this should be merged into |
|
|
||
| extension SharingAccountViewController: NoResultsViewControllerDelegate { | ||
| func actionButtonPressed() { | ||
| if let url = URL(string: "https://en.support.wordpress.com/publicize/#facebook-pages") { |
There was a problem hiding this comment.
@aerych do you think we should show the blog post instead?
There was a problem hiding this comment.
This should match the behavior in Calypso where the support page is linked from the message shown when attempting to link a Facebook account with no pages. The blog post is linked from the message shown for a pre-existing connection that needs to be disconnected.
Unless I somehow got that backwards 😬
This isn't really a trivial patch so I'm not too keen targeting 10.5. The changes include linking to updated pod(s) and adds a new model revision -- things that really need to go through the normal QA cycle. |
@aerych totally fair, but I don't think we should wait the full two weeks to release this after the facebook change. We have 200+ people adding a connection a day (I don't know how many are facebook) What do you think about a hotfix for 10.5.1 after testing for a couple days? |
Sounds good. |
| @objc var immutableHandler: ImmuTableViewHandler! | ||
| @objc var delegate: SharingAccountSelectionDelegate? | ||
|
|
||
| lazy var noResultsViewController: NoResultsViewController = { |
There was a problem hiding this comment.
Would it make sense to declare this var as private? Or do we really need it to be fully mutable?
|
|
||
|
|
||
| fileprivate func showNoResultsViewController() { | ||
| let title = NSLocalizedString("No Accounts Found", |
There was a problem hiding this comment.
This is a completely personal preference, but I tend to declare strings as constants (or as static cases in an enumeration), so that, at the call site, like here, it would read similar to this:
fileprivate func showNoResultsViewController() {
noResultsViewController.configure(title: "", buttonTitle: NoResults.buttonTitle, subtitle: NoResults.message, image: nil, accessoryView: nil)
noResultsViewController.delegate = self
}
I have found that makes the code slightly easier to parse for me. What do you think?
There was a problem hiding this comment.
I'm a fan of that when a string is reused. When used only once I like declaring a string in the context of its usage as a way of having as much context as possible in one place.
| var accounts = keyringAccountsFromKeyringConnections(keyringConnections) | ||
|
|
||
| if accounts.count == 0 { | ||
| if publicizeService.externalUsersOnly && publicizeService.serviceID == PublicizeService.facebookServiceID { |
There was a problem hiding this comment.
Would it make sense to encapsulate this boolean check in a method in PublicizeService, named in a way that provides a clear explanation of why we want to call showFacebookNotice()?
If I read this code, without any context, I don't really know what is going on. I mean, I can understand it, but I don't really understand why this boolean check is necessary, what is the meaning of it.
In a way, it's also leaking the abstraction a little bit. This view controller needs to know about the specific internal "state" of the PublicizeService, when it probably should not need to be aware of it.
There was a problem hiding this comment.
Looking a bit closer at this. The publicizeService.externalUsersOnly is redundant here so we can remove it. This will make it a check for Facebook to see if it needs special handling which will hopefully make things a bit clearer.
| cell.textLabel.text = connection.externalDisplay; | ||
|
|
||
| if ([connection isBroken]) { | ||
| if ([connection isBroken] || [connection mustDisconnect]) { |
There was a problem hiding this comment.
I tend to encapsulate these boolean checks into a single method. In my experience, that makes the code more readable, in the long term, because it provides a name that can clearly explain what is happening and why it is important.
In this case, also, I think it might make sense to encapsulate that logic in the PublicizeConnection object as well, so this view controller does not need to know about isBroken and / or mustDisconnect.
What do you think?
|
|
||
| - (BOOL)mustDisconnectFacebook | ||
| { | ||
| return [self.publicizeConnection mustDisconnect] && [[self.publicizeConnection service] isEqualToString: [PublicizeService facebookServiceID]]; |
There was a problem hiding this comment.
Would this logic belong in the PublicizeConnection object?
| - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView | ||
| { | ||
| if ([self.publicizeConnection isBroken]) { | ||
| if ([self.publicizeConnection isBroken] || [self mustDisconnectFacebook]) { |
There was a problem hiding this comment.
This boolean check is also done in SharingConnectionsViewController. In my opinion, that also supports moving this logic to the PublicizeConnection object. In this case, also, this boolean check is split in between two classes: part of the logic is defined in the "connection" object, while another part of it is in the mustDisconnectFacebook method, which also pulls properties from the connection. What do you think?
| NSString *title = NSLocalizedString(@"There is an issue connecting to %@. Reconnect to continue publicizing.", @"Informs the user about an issue connecting to the third-party sharing service. The `%@` is a placeholder for the service name."); | ||
| return [NSString stringWithFormat:title, self.publicizeConnection.label]; | ||
|
|
||
| if (section == 1) { |
There was a problem hiding this comment.
I would suggest extracting each logical branch to a separate method. That way titleForFooterInSection would be easier to read and parse, which might also make it. in the long term, more difficult to get wrong.
| cell.textLabel.textAlignment = NSTextAlignmentCenter; | ||
| cell.textLabel.textColor = [WPStyleGuide jazzyOrange]; | ||
| } else if (indexPath.section == 1) { | ||
| if ([self.publicizeConnection isBroken]) { |
There was a problem hiding this comment.
I would also suggest extracting each logical branch to a separate method, if possible. That would make this code easier to read, to begin with. Also, there seems to be an issue with this title (more in another comment), so making this code simpler to read might have the extra advantage of fixing that :)
| // Check if any of the connections are broken. | ||
| for (PublicizeConnection *pubConn in connections) { | ||
| if ([pubConn isBroken]) { | ||
| if ([pubConn isBroken] || [pubConn mustDisconnect]) { |
There was a problem hiding this comment.
This seems to be the third different place where this boolean check is done, which, in my opinion, supports encapsulating it in the PublicizeConnetion object
|
Hi @aerych! Thanks for attacking this, and thanks also for thinking of me for the review. The code looks great, I just have a made a few comments to trigger a couple of discussions. 😉 Scenario #1 works great. Something seems to be slightly off in the "Learn More" button title for the other two scenarios though. For the Scenario #2, I get a button with an empty label: And for Scenario #3, I get a "Reconnect" instead of "Learn More" I have tested the feature by upgrading from a previous build, but also after a clean install, and on both cases I get the same results |
|
Well, that's embarrassing 😬. I see the issue with the missing button labels now. Not sure how I missed this before. Thanks for spotting it! |
|
Hiya @ctarda ! Thanks for the review and suggestions. :) I think I've implemented the changes the way you intended but if I misunderstood let me know and I'll revise. (The branching logic makes me wish refactoring the table views to use ImmuTable was in scope. It would make things clearer, I think. Something for a future revision.) Ready for another peek! |
|
Hi @aerych ! Thanks for taking the suggestions into consideration. One thing that I've just noticed (it might be after the latest update, but I am not completely sure it wasn't there before) is that a When it comes to the functionality, something seems to be slightly off. Scenario 1 is always prompting that the connection could not be made because there are no pages (even though there are pages in the testing account I am using) |
Nicely spotted. It looks like the
Hmm... I'm not sure what this could be. This is what I'm seeing with my test Facebook account with a single Facebook page: What are you seeing that's different? |
|
👋 sorry for the delay, @aerych ! This is what I see: This is a wordpress.com site, in case it is relevant. |
|
Closing this in favor of #9872 so we're not branching off develop. |




This is an 11th hour patch to address Facebook's privacy changes that affect publicize sharing to Facebook Profiles. As of August 1st, sharing to Facebook Profiles is no longer allowed.
This patch changes how Facebook sharing is handled so only sharing to Facebook Pages is supported. Attempting to share to a profile will result in a notice.

An existing connection to a Facebook profile will show up as broken. On the detail page new messaging is shown.

Clicking
Learn Moreon either screen will open Safari to an FAQ. The destination is different for each button and should match the behavior in calypso.To test:
You'll want a Facebook account to test with.
Scenario 1:
Attempt to set up a sharing connection to a Facebook profile. You should see the prompt that the connection could not be made because their are no pages.
Confirm clicking the Learn More button opens the support page in Safari.
Scenario 2:
Create a Facebook Page.
Attempt to set up sharing to Facebook again, and this time confirm that your newly created page is shown as an option. Go ahead and make the connection.
Scenario 3:
Edit
SharingDetailViewController.msomustDisconnectFacebookalways returns true.Navigate to the Facebook connection details screen and confirm that instead of a "Reconnect" option, you see a "Learn More" option and the appropriate footer text.
Confirm that the FAQ link opens in Safari.
FYI @loremattei
@ctarda could I trouble you for a review?
cc @kwonye who is wrangling the Android version of this patch.