-
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
Merge/release 21.8 finalized into trunk #20243
Closed
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5be1d95
Don't bounce to Safari when both apps are installed
dvdchr 06090e9
Add a router to convert eligible routes to WPAdmin
dvdchr 8acd7e4
Return nil if the siteID is not found
dvdchr 324b004
Only convert to wp-admin when the URL cannot be handled
dvdchr 407ff3f
Bump version number
mokagio 851dc30
Add options to migrate the imported WordPress database automatically
wargcm b91c18b
Fix migration logic in `migrateDataModelsIfNecessary`
wargcm f353613
Attempt to manually migrate the imported database before using it
wargcm 1f4f9a7
Fix database migration issue with different database models (#20217)
mokagio 5faf182
Merge remote-tracking branch 'origin/release/21.8' into merge/hotfix-…
mokagio 68f6127
Merge pull request #20213 from wordpress-mobile/fix/19755-infinite-ap…
dvdchr a02f146
Merge 21.7.2 hotfix into 21.8 (#20221)
mokagio dc5ee77
Release script: Update gutenberg-mobile ref
dcalhoun a9f3845
docs: Add release note
dcalhoun c19644a
build: Update Gutenberg ref
dcalhoun 8683b88
Merge pull request #20231 from wordpress-mobile/gutenberg/integrate_r…
dcalhoun f9ff4f1
Update app translations – `Localizable.strings`
mokagio 637a9a9
Update WordPress metadata translations
mokagio dde547b
Update Jetpack metadata translations
mokagio 7eb6e88
Bump version number
mokagio f596f9d
Merge 'origin/trunk' into merge/release-21.8-finalized-into-trunk
mokagio 4388c84
Fix "can" verb conjugation in a comment
mokagio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
WordPress/Classes/Utility/Universal Links/Migration/WPAdminConvertibleRouter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/// A router that handles routes that can be converted to /wp-admin links. | ||
/// | ||
/// Note that this is a workaround for an infinite redirect issue between WordPress and Jetpack | ||
/// when both apps are installed. | ||
/// | ||
/// This can be removed once we remove the Universal Link routes for the WordPress app. | ||
struct WPAdminConvertibleRouter: LinkRouter { | ||
static let shared = WPAdminConvertibleRouter(routes: [ | ||
EditPostRoute() | ||
]) | ||
|
||
let routes: [Route] | ||
let matcher: RouteMatcher | ||
|
||
init(routes: [Route]) { | ||
self.routes = routes | ||
matcher = RouteMatcher(routes: routes) | ||
} | ||
|
||
func canHandle(url: URL) -> Bool { | ||
return matcher.routesMatching(url).count > 0 | ||
} | ||
|
||
func handle(url: URL, shouldTrack track: Bool = false, source: DeepLinkSource? = nil) { | ||
matcher.routesMatching(url).forEach { route in | ||
route.action.perform(route.values, source: nil, router: self) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Routes | ||
|
||
struct EditPostRoute: Route { | ||
let path = "/post/:domain/:postID" | ||
let section: DeepLinkSection? = nil | ||
let action: NavigationAction = WPAdminConvertibleNavigationAction.editPost | ||
let jetpackPowered: Bool = false | ||
} | ||
|
||
// MARK: - Navigation Action | ||
|
||
enum WPAdminConvertibleNavigationAction: NavigationAction { | ||
case editPost | ||
|
||
func perform(_ values: [String: String], source: UIViewController?, router: LinkRouter) { | ||
let wpAdminURL: URL? = { | ||
switch self { | ||
case .editPost: | ||
guard let url = blogURLString(from: values), | ||
let postID = postID(from: values) else { | ||
return nil | ||
} | ||
|
||
var components = URLComponents(string: "https://\(url)/wp-admin/post.php") | ||
components?.queryItems = [ | ||
.init(name: "post", value: postID), | ||
.init(name: "action", value: "edit"), | ||
.init(name: "calypsoify", value: "1") | ||
] | ||
return components?.url | ||
} | ||
}() | ||
|
||
guard let wpAdminURL else { | ||
return | ||
} | ||
|
||
UIApplication.shared.open(wpAdminURL) | ||
} | ||
} | ||
|
||
private extension WPAdminConvertibleNavigationAction { | ||
func blogURLString(from values: [String: String]?) -> String? { | ||
guard let domain = values?["domain"] else { | ||
return nil | ||
} | ||
|
||
// First, check if the provided domain is a siteID. | ||
// If it is, then try to look up existing blogs and return the URL instead. | ||
if let siteID = Int(domain) { | ||
let blog = try? Blog.lookup(withID: siteID, in: ContextManager.shared.mainContext) | ||
return blog?.hostURL as? String | ||
} | ||
|
||
if let _ = URL(string: domain) { | ||
return domain | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func postID(from values: [String: String]?) -> String? { | ||
return values?["postID"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
https://github.com/wordpress-mobile/WordPress-iOS/pull/20231/files#r1124063801