Skip to content

Jetpack Extensions: Use different keys to avoid conflicts between WP and JP extensions - #19665

Merged
hassaanelgarem merged 24 commits into
trunkfrom
fix/19591-extensions-diff-keys
Nov 28, 2022
Merged

Jetpack Extensions: Use different keys to avoid conflicts between WP and JP extensions#19665
hassaanelgarem merged 24 commits into
trunkfrom
fix/19591-extensions-diff-keys

Conversation

@hassaanelgarem

Copy link
Copy Markdown
Contributor

Fixes #19591

Description

This PR fixes an issue where jetpack extensions were conflicting with WP extensions. This is done by using different keys for the WP and JP extensions.

P.S: This change means we will have to migrate the extensions' data since they are no longer shared between WP and JP. This will be done in a coming PR and will follow the same pattern as the one in #19663, that's why this PR depends on #19663's branch.

Testing Instructions

  1. Install & run Jetpack
  2. Sign in using account A
  3. Install & run WordPress
  4. Sign in using account B
  5. Go to photos
  6. Select a photo
  7. Tap on the share button
  8. Select Jetpack
  9. Make sure that the site list displayed is the one from account A, not account B.

Regression Notes

  1. Potential unintended areas of impact
    N/A

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    N/A

  3. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@peril-wordpress-mobile

peril-wordpress-mobile Bot commented Nov 25, 2022

Copy link
Copy Markdown
Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@wpmobilebot

wpmobilebot commented Nov 25, 2022

Copy link
Copy Markdown
Contributor
You can test the changes in Jetpack from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr19665-ca11d56 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@wpmobilebot

wpmobilebot commented Nov 25, 2022

Copy link
Copy Markdown
Contributor
You can test the changes in WordPress from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr19665-ca11d56 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@dvdchr dvdchr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hassaanelgarem 👋🏼 . Thank you for working on this! I left one non-blocking suggestion, and the changes are looking good to me.

This change means we will have to migrate the extensions' data since they are no longer shared between WP and JP. This will be done in a coming PR [...]

Please note that this PR and the changes you've planned in the next PR need to be all-or-nothing; If we merge this, we must also merge the addition to the migration process.

My recommendation is to either put everything in this PR or don't merge this PR until both the PRs are green. I can't help but think about the risks due to the very tight time constraints 😅

What do you think?


import Foundation

@objc extension AppConfiguration {

@dvdchr dvdchr Nov 25, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we will be having a couple of "similar-but-different" configuration files, (e.g., WidgetConfiguration, AppConfiguration, AppConstants), I think it would help to add some documentation/warning here (and in the counterpart file) stating that the keys must be in-sync with the counterpart file.

While this doesn't entirely prevent mistakes, I feel it still helps to deter human errors. More detail on this: #19479 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for linking this comment thread 👍.

Yes, we went for this solution without too many discussions, simply following the pattern that was already established with AppConfiguration files. However, it does have drawbacks with discoverability and the necessity to build both targets to ensure there're no errors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point @dvdchr!
I've added documentation here and in the other configuration files c9a58f2 👍


import Foundation

@objc extension AppConfiguration {

@dvdchr dvdchr Nov 25, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see the comment above)

@momo-ozawa momo-ozawa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described. Will we be able to target 21.3, given the code freeze is coming up very soon?

Base automatically changed from feature/19657-migrate-today-widget to trunk November 25, 2022 12:13
var wordPressNotificationsEnabled: Bool {
get {
guard let userDefaults = userDefaults,
userDefaults.value(forKey: WPNotificationsEnabledKey) != nil else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There'll be conflicts with these after my latest merge.

WPNotificationsEnabledKey and subsequently AppConfiguration.Extension.NotificationsService.enabledKey are no longer needed and could be deleted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up @staskus 🙇

# Conflicts:
#	WordPress/Classes/Services/NotificationFilteringService.swift
#	WordPress/Classes/System/Constants.m
…ns-copy-data

# Conflicts:
#	WordPress/Jetpack/Classes/Utility/DataMigrator.swift
@hassaanelgarem

hassaanelgarem commented Nov 27, 2022

Copy link
Copy Markdown
Contributor Author

Please note that this PR and the changes you've planned in the next PR need to be all-or-nothing; If we merge this, we must also merge the addition to the migration process.

@dvdchr Agreed. I've added a "Do not merge" label, and I'll remove it once #19666 is ready.

@mokagio FYI. Also, given the time, I don't think #19666 will be ready and approved before the code freeze. Do you think we can include these two PRs in a beta release?
Edit: #19666 is merged into this PR, and I've enabled auto-merge on this PR, so it will be merged once the CI passes 👍

@dvdchr dvdchr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed a typo 😅 But it's looking good overall. :shipit:

Comment thread WordPress/Jetpack/ExtensionConfiguration.swift Outdated
Comment thread WordPress/Jetpack/AppStyleGuide.swift Outdated
Comment thread WordPress/Jetpack/AppDependency.swift Outdated
Comment thread WordPress/Jetpack/AppConstants.swift Outdated
Comment thread WordPress/Jetpack/AppConfiguration.swift Outdated
Comment thread WordPress/Classes/Utility/App Configuration/WidgetConfiguration.swift Outdated
@hassaanelgarem
hassaanelgarem merged commit 4fadf5c into trunk Nov 28, 2022
@hassaanelgarem
hassaanelgarem deleted the fix/19591-extensions-diff-keys branch November 28, 2022 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jetpack Share Extension: Site list not accurate if WordPress and Jetpack are both installed

5 participants