Clear user collections on logout

This commit is contained in:
Angelo Stavrow 2020-08-25 11:29:17 -04:00
parent 18ce54bd89
commit 21e8a4ca35
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
3 changed files with 9 additions and 2 deletions

View File

@ -79,6 +79,7 @@ private extension WriteFreelyModel {
client = nil
DispatchQueue.main.async {
self.account.logout()
self.collections.clearUserCollection()
}
} catch WFError.notFound {
// The user token is invalid or doesn't exist, so it's been invalidated by the server. Proceed with
@ -86,6 +87,7 @@ private extension WriteFreelyModel {
client = nil
DispatchQueue.main.async {
self.account.logout()
self.collections.clearUserCollection()
}
} catch {
// We get a 'cannot parse response' (similar to what we were seeing in the Swift package) NSURLError here,

View File

@ -10,4 +10,9 @@ class CollectionListModel: ObservableObject {
}
collectionsList.append(contentsOf: self.userCollections)
}
func clearUserCollection() {
userCollections = []
collectionsList = [ allPostsCollection, draftsCollection ]
}
}

View File

@ -7,12 +7,12 @@
<key>WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<key>WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>