From b0d0792014c3a8e16ee45b3c2d7edf3a6fd0e05d Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Wed, 9 Sep 2020 21:26:13 -0700 Subject: [PATCH] Cleanup --- .../ServiceLayer/Services/IdentityService.swift | 2 -- .../Sources/ViewModels/NavigationViewModel.swift | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift b/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift index 5e1fc38..08a8919 100644 --- a/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift +++ b/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift @@ -34,8 +34,6 @@ public struct IdentityService { } public extension IdentityService { - var isAuthorized: Bool { mastodonAPIClient.accessToken != nil } - func updateLastUse() -> AnyPublisher { identityDatabase.updateLastUsedAt(identityID: identityID) } diff --git a/ViewModels/Sources/ViewModels/NavigationViewModel.swift b/ViewModels/Sources/ViewModels/NavigationViewModel.swift index b06c583..6f4528c 100644 --- a/ViewModels/Sources/ViewModels/NavigationViewModel.swift +++ b/ViewModels/Sources/ViewModels/NavigationViewModel.swift @@ -18,8 +18,8 @@ public final class NavigationViewModel: ObservableObject { public init(identification: Identification) { self.identification = identification - timeline = identification.service.isAuthorized ? .home : .local - timelinesAndLists = identification.service.isAuthorized + timeline = identification.identity.authenticated ? .home : .local + timelinesAndLists = identification.identity.authenticated ? Timeline.authenticatedDefaults : Timeline.unauthenticatedDefaults @@ -31,7 +31,7 @@ public final class NavigationViewModel: ObservableObject { .assignErrorsToAlertItem(to: \.alertItem, on: self) .assign(to: &$recentIdentities) - if identification.service.isAuthorized { + if identification.identity.authenticated { identification.service.listsObservation() .map { Timeline.authenticatedDefaults + $0 } .assignErrorsToAlertItem(to: \.alertItem, on: self) @@ -42,7 +42,7 @@ public final class NavigationViewModel: ObservableObject { public extension NavigationViewModel { var tabs: [Tab] { - if identification.service.isAuthorized { + if identification.identity.authenticated { return Tab.allCases } else { return [.timelines, .explore] @@ -59,7 +59,7 @@ public extension NavigationViewModel { } func refreshIdentity() { - if identification.service.isAuthorized { + if identification.identity.authenticated { identification.service.verifyCredentials() .assignErrorsToAlertItem(to: \.alertItem, on: self) .sink { _ in }