-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Tweak a few file to allow WordPressData to compile #24375
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4e73411
Move code `localIconImage` to app targets / Keystone
mokagio 8a5e249
Use `BuildSettings` over `AppConfiguration` in `SharedDataIssueSolver`
mokagio 643db9a
Use `BuildSettings` over `AppConfiguration` in `WPAccount+Lookup`
mokagio 9f73590
Use `_private_wordPressComRestApi` in `Blog.m` to work around deps
mokagio 6bc1aed
Properly call `alloc` in `PostService.m`
mokagio 75f416c
Move `Blog` `wordPressComRestApi` and consumers from ObjC to Swift
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 hidden or 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
74 changes: 74 additions & 0 deletions
74
WordPress/Classes/Models/Blog/Blog+SupportDescription.swift
This file contains hidden or 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,74 @@ | ||
| import WordPressData | ||
|
|
||
| extension Blog { | ||
|
|
||
| /// Formatted information to send to Support when user creates a new ticket. | ||
| var supportDescription: String { | ||
| let blogType = "Type: \(stateDescription)" | ||
| let urlType = wordPressComRestApi != nil ? "REST" : "Self-hosted" | ||
| let urlString = "URL: \(url ?? "'no url!'")" | ||
|
|
||
| let username: String? | ||
| let planDescription: String? | ||
| if account == nil { | ||
| if let jetpackConnectedUsername = jetpack?.connectedUsername { | ||
| username = jetpackConnectedUsername | ||
| } else { | ||
| username = nil | ||
| } | ||
| planDescription = nil | ||
| } else { | ||
| let planIDString: String | ||
| if let planID { | ||
| planIDString = "\(planID)" | ||
| } else { | ||
| planIDString = "'no id'" | ||
| } | ||
| planDescription = "Plan: \(planTitle ?? "'no title'") (\(planIDString))" | ||
| username = nil | ||
| } | ||
|
|
||
| var blogInformation: [String] = [] | ||
|
|
||
| // Add information to array in the order we want to display it. | ||
| blogInformation.append(blogType) | ||
|
|
||
| if let username { | ||
| blogInformation.append(username) | ||
| } | ||
|
|
||
| blogInformation.append(urlType) | ||
| blogInformation.append(urlString) | ||
|
|
||
| if let planDescription { | ||
| blogInformation.append(planDescription) | ||
| } | ||
|
|
||
| if let jetpack, jetpack.isInstalled, let version = jetpack.version { | ||
| blogInformation.append("Jetpack-version: \(version)") | ||
| } | ||
|
|
||
| return blogInformation.joined(separator: " ") | ||
| } | ||
|
|
||
| var stateDescription: String { | ||
| guard account == nil else { | ||
| return "wpcom" | ||
| } | ||
|
|
||
| guard let jetpack else { | ||
| return "self_hosted" | ||
| } | ||
|
|
||
| if jetpack.isConnected { | ||
| let apiType = wordPressComRestApi != nil ? "REST" : "XML-RPC" | ||
| return "jetpack_connected - \(apiType)" | ||
| } | ||
|
|
||
| if jetpack.isInstalled { | ||
| return "self-hosted - jetpack_installed" | ||
| } | ||
|
|
||
| return "self_hosted" | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
WordPress/Classes/Models/Blog/Blog+WordPressComRestAPI.swift
This file contains hidden or 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,22 @@ | ||
| import WordPressData | ||
| import WordPressKit | ||
|
|
||
| public extension Blog { | ||
|
|
||
| /// Returns a REST API client, if available | ||
| /// | ||
| /// If the blog is a WordPress.com one or it has Jetpack it will return a REST API client. | ||
| /// Otherwise, the XML-RPC API should be used. | ||
| /// | ||
| /// - Warning: this method doesn't know if a Jetpack blog has the JSON API disabled. | ||
| @objc | ||
| var wordPressComRestApi: WordPressComRestApi? { | ||
| account?.wordPressComRestApi | ||
| } | ||
|
|
||
| /// Whether the blog is hosted on WordPress.com or connected through Jetpack. | ||
| @objc | ||
| func isAccessibleThroughWPCom() -> Bool { | ||
| wordPressComRestApi != nil | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -41,11 +41,6 @@ public extension PublicizeService { | |
| case threads | ||
| case unknown | ||
|
|
||
| /// Returns the local image for the icon representing the social network. | ||
| var localIconImage: UIImage { | ||
| WPStyleGuide.socialIcon(for: rawValue as NSString) | ||
| } | ||
|
|
||
|
Comment on lines
-44
to
-48
Contributor
Author
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.
By moving it away from here, we unblock adding this required extension to the framework. |
||
| /// A string describing the service in a human-readable format. | ||
| public var description: String { | ||
| rawValue.split(separator: "-").joined(separator: " ").localizedCapitalized | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Using
BuildSettingsoverAppConfigurationallows moving to WordPressData where the latter is not available.