Persist user after login (IOS-192)

This commit is contained in:
Nathan Mattes 2023-12-19 22:21:15 +01:00
parent 6aea178609
commit e7c1edbbc3
2 changed files with 4 additions and 12 deletions

View File

@ -1883,13 +1883,6 @@
path = Localization;
sourceTree = "<group>";
};
D8AC98742B0F615E0045EC2B /* Persistence */ = {
isa = PBXGroup;
children = (
);
path = Persistence;
sourceTree = "<group>";
};
D8E5C347296DB896007E76A7 /* Edit History */ = {
isa = PBXGroup;
children = (
@ -2175,7 +2168,6 @@
DB427DD425BAA00100D1B89D /* Mastodon */ = {
isa = PBXGroup;
children = (
D8AC98742B0F615E0045EC2B /* Persistence */,
DB89BA1025C10FF5008580ED /* Mastodon.entitlements */,
DB427DE325BAA00100D1B89D /* Info.plist */,
2D76319C25C151DE00929FB9 /* Diffable */,

View File

@ -142,10 +142,10 @@ class MastodonLoginViewController: UIViewController, NeedsDependency {
authenticationViewModel
.authenticated
.asyncMap { domain, user -> Result<Bool, Error> in
.asyncMap { domain, user -> Result<Mastodon.Entity.Account, Error> in
do {
let result = try await self.context.authenticationService.activeMastodonUser(domain: domain, userID: user.id)
return .success(result)
return .success(user)
} catch {
return .failure(error)
}
@ -156,8 +156,8 @@ class MastodonLoginViewController: UIViewController, NeedsDependency {
switch result {
case .failure(let error):
assertionFailure(error.localizedDescription)
case .success(let isActived):
assert(isActived)
case .success(let account):
FileManager.default.store(account: account, forUserID: account.id)
self.coordinator.setup()
}
}