-
Notifications
You must be signed in to change notification settings - Fork 121
[Universal Links] Do not enter undetermined state if the user does not have access to the passed blog Id #7866
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
toupper
merged 5 commits into
trunk
from
issue/7864-app-in-wrong-state-link-wrong-blog-id
Oct 17, 2022
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7d32d07
Check if the user has actually access to the site and woocommerce is …
toupper 49cf426
Move logic to a new method to avoid undesired effects with existing c…
toupper 378beca
Better naming
toupper 95566c8
Fix documentation text.
toupper 59b0d71
Remove unneeded self.
toupper 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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||
| import UIKit | ||||||
| import Yosemite | ||||||
| import protocol Storage.StorageManagerType | ||||||
|
|
||||||
| protocol SwitchStoreUseCaseProtocol { | ||||||
| func switchStore(with storeID: Int64, onCompletion: @escaping (Bool) -> Void) | ||||||
|
|
@@ -10,9 +11,19 @@ protocol SwitchStoreUseCaseProtocol { | |||||
| final class SwitchStoreUseCase: SwitchStoreUseCaseProtocol { | ||||||
|
|
||||||
| private let stores: StoresManager | ||||||
| private let storageManager: StorageManagerType | ||||||
|
|
||||||
| init(stores: StoresManager) { | ||||||
| private lazy var resultsController: ResultsController<StorageSite> = { | ||||||
| return ResultsController(storageManager: storageManager, sortedBy: []) | ||||||
| }() | ||||||
|
|
||||||
| private var wooCommerceSites: [Site] { | ||||||
| resultsController.fetchedObjects.filter { $0.isWooCommerceActive == true } | ||||||
| } | ||||||
|
|
||||||
| init(stores: StoresManager, storageManager: StorageManagerType = ServiceLocator.storageManager) { | ||||||
| self.stores = stores | ||||||
| self.storageManager = storageManager | ||||||
| } | ||||||
|
|
||||||
| /// The async version of `switchStore` that wraps the completion block version. | ||||||
|
|
@@ -28,6 +39,25 @@ final class SwitchStoreUseCase: SwitchStoreUseCaseProtocol { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| /// Switches the to store with the given id if it was previously synced and stored. | ||||||
| /// This is done to check whether the user has access to that store, avoiding undetermined states if we log out | ||||||
| /// from the current one and try to switch to a store they don't have access to. | ||||||
| /// | ||||||
| /// - Parameter storeID: target store ID. | ||||||
| /// - Returns: a boolean that indicates whether the site was changed. | ||||||
| /// | ||||||
| func switchToStoreIfSiteIsStored(with storeID: Int64, onCompletion: @escaping (Bool) -> Void) { | ||||||
| self.refreshStoredSites() | ||||||
|
|
||||||
| let siteWasStored = self.wooCommerceSites.first(where: { $0.siteID == storeID }) != nil | ||||||
|
||||||
| let siteWasStored = self.wooCommerceSites.first(where: { $0.siteID == storeID }) != nil | |
| let siteWasStored = wooCommerceSites.first(where: { $0.siteID == storeID }) != 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
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.