-
Notifications
You must be signed in to change notification settings - Fork 45
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
Logout option full reset #1107
Draft
dfsm
wants to merge
3
commits into
main
Choose a base branch
from
logout-option-full-reset
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Logout option full reset #1107
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,9 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { | |
if ForumsClient.shared.isLoggedIn { | ||
setRootViewController(rootViewControllerStack.rootViewController, animated: false, completion: nil) | ||
} else { | ||
if loginViewController == nil { | ||
newLoginController() | ||
} | ||
setRootViewController(loginViewController.enclosingNavigationController, animated: false, completion: nil) | ||
} | ||
|
||
|
@@ -121,13 +124,13 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { | |
return true | ||
} | ||
|
||
func applicationWillResignActive(_ application: UIApplication) { | ||
func applicationDidEnterBackground(_ application: UIApplication) { | ||
SmilieKeyboardSetIsAwfulAppActive(false) | ||
|
||
updateShortcutItems() | ||
} | ||
|
||
func applicationDidBecomeActive(_ application: UIApplication) { | ||
func applicationWillEnterForeground(_ application: UIApplication) { | ||
SmilieKeyboardSetIsAwfulAppActive(true) | ||
|
||
// Screen brightness may have changed while the app wasn't paying attention. | ||
|
@@ -155,12 +158,19 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { | |
try! managedObjectContext.save() | ||
} | ||
|
||
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { | ||
AppDelegate.instance.application(app, open: url, | ||
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, | ||
annotation: options[UIApplication.OpenURLOptionsKey.annotation] as Any | ||
) | ||
} | ||
|
||
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. Why was this necessary? |
||
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { | ||
guard | ||
ForumsClient.shared.isLoggedIn, | ||
let route = try? AwfulRoute(url) | ||
else { return false } | ||
|
||
else { return false } | ||
open(route: route) | ||
return true | ||
} | ||
|
@@ -170,23 +180,29 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { | |
return router.route(route) | ||
} | ||
|
||
func fullReset() { | ||
UserDefaults.standard.removeAllObjectsInMainBundleDomain() | ||
emptyCache() | ||
dataStore.deleteStoreAndReset() | ||
logOut() | ||
} | ||
|
||
func logOut() { | ||
// Logging out doubles as an "empty cache" button. | ||
let cookieJar = HTTPCookieStorage.shared | ||
for cookie in cookieJar.cookies ?? [] { | ||
cookieJar.deleteCookie(cookie) | ||
} | ||
UserDefaults.standard.removeAllObjectsInMainBundleDomain() | ||
emptyCache() | ||
|
||
// Do this after resetting settings so that it gets the default baseURL. | ||
|
||
updateClientBaseURL() | ||
|
||
if loginViewController == nil { | ||
newLoginController() | ||
} | ||
|
||
setRootViewController(loginViewController.enclosingNavigationController, animated: true) { [weak self] in | ||
self?._rootViewControllerStack = nil | ||
|
||
self?.urlRouter = nil | ||
|
||
self?.dataStore.deleteStoreAndReset() | ||
} | ||
} | ||
|
||
|
@@ -255,7 +271,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { | |
return stack | ||
} | ||
|
||
private lazy var loginViewController: LoginViewController! = { | ||
private func createLoginViewController() -> LoginViewController! { | ||
let loginVC = LoginViewController.newFromStoryboard() | ||
loginVC.completionBlock = { [weak self] (login) in | ||
guard let self = self else { return } | ||
|
@@ -266,7 +282,16 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { | |
}) | ||
} | ||
return loginVC | ||
} | ||
|
||
private lazy var loginViewController : LoginViewController! = { | ||
return self.createLoginViewController() | ||
}() | ||
|
||
private func newLoginController() { | ||
loginViewController = createLoginViewController() | ||
} | ||
|
||
} | ||
|
||
private extension AppDelegate { | ||
|
56 changes: 0 additions & 56 deletions
56
App/Resources/Assets.xcassets/onepassword-button.imageset/Contents.json
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-701 Bytes
...ources/Assets.xcassets/onepassword-button.imageset/onepassword-button-light.png
Binary file not shown.
Binary file removed
BIN
-1.69 KB
...ces/Assets.xcassets/onepassword-button.imageset/[email protected]
Binary file not shown.
Binary file removed
BIN
-2.75 KB
...ces/Assets.xcassets/onepassword-button.imageset/[email protected]
Binary file not shown.
Binary file removed
BIN
-965 Bytes
App/Resources/Assets.xcassets/onepassword-button.imageset/onepassword-button.png
Binary file not shown.
Binary file removed
BIN
-1.78 KB
...Resources/Assets.xcassets/onepassword-button.imageset/[email protected]
Binary file not shown.
Binary file removed
BIN
-2.92 KB
...Resources/Assets.xcassets/onepassword-button.imageset/[email protected]
Binary file not shown.
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
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.
What's the reasoning here and with DidBecomeActive/WillEnterForeground below? (Not saying it's wrong!)