mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-29 03:21:02 +00:00
Cleanup
This commit is contained in:
parent
c3ca23d736
commit
b0d0792014
2 changed files with 5 additions and 7 deletions
|
@ -34,8 +34,6 @@ public struct IdentityService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension IdentityService {
|
public extension IdentityService {
|
||||||
var isAuthorized: Bool { mastodonAPIClient.accessToken != nil }
|
|
||||||
|
|
||||||
func updateLastUse() -> AnyPublisher<Never, Error> {
|
func updateLastUse() -> AnyPublisher<Never, Error> {
|
||||||
identityDatabase.updateLastUsedAt(identityID: identityID)
|
identityDatabase.updateLastUsedAt(identityID: identityID)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ public final class NavigationViewModel: ObservableObject {
|
||||||
|
|
||||||
public init(identification: Identification) {
|
public init(identification: Identification) {
|
||||||
self.identification = identification
|
self.identification = identification
|
||||||
timeline = identification.service.isAuthorized ? .home : .local
|
timeline = identification.identity.authenticated ? .home : .local
|
||||||
timelinesAndLists = identification.service.isAuthorized
|
timelinesAndLists = identification.identity.authenticated
|
||||||
? Timeline.authenticatedDefaults
|
? Timeline.authenticatedDefaults
|
||||||
: Timeline.unauthenticatedDefaults
|
: Timeline.unauthenticatedDefaults
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public final class NavigationViewModel: ObservableObject {
|
||||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
||||||
.assign(to: &$recentIdentities)
|
.assign(to: &$recentIdentities)
|
||||||
|
|
||||||
if identification.service.isAuthorized {
|
if identification.identity.authenticated {
|
||||||
identification.service.listsObservation()
|
identification.service.listsObservation()
|
||||||
.map { Timeline.authenticatedDefaults + $0 }
|
.map { Timeline.authenticatedDefaults + $0 }
|
||||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
||||||
|
@ -42,7 +42,7 @@ public final class NavigationViewModel: ObservableObject {
|
||||||
|
|
||||||
public extension NavigationViewModel {
|
public extension NavigationViewModel {
|
||||||
var tabs: [Tab] {
|
var tabs: [Tab] {
|
||||||
if identification.service.isAuthorized {
|
if identification.identity.authenticated {
|
||||||
return Tab.allCases
|
return Tab.allCases
|
||||||
} else {
|
} else {
|
||||||
return [.timelines, .explore]
|
return [.timelines, .explore]
|
||||||
|
@ -59,7 +59,7 @@ public extension NavigationViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshIdentity() {
|
func refreshIdentity() {
|
||||||
if identification.service.isAuthorized {
|
if identification.identity.authenticated {
|
||||||
identification.service.verifyCredentials()
|
identification.service.verifyCredentials()
|
||||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
||||||
.sink { _ in }
|
.sink { _ in }
|
||||||
|
|
Loading…
Reference in a new issue