mirror of
https://github.com/metabolist/metatext.git
synced 2024-12-21 21:26:26 +00:00
Renaming
This commit is contained in:
parent
0173c118ae
commit
7f75b27ce2
18 changed files with 52 additions and 55 deletions
|
@ -6,7 +6,7 @@ import GRDB
|
|||
struct AccountStatusJoin: Codable, FetchableRecord, PersistableRecord {
|
||||
let accountId: String
|
||||
let statusId: String
|
||||
let collection: AccountStatusCollection
|
||||
let collection: ProfileCollection
|
||||
|
||||
static let status = belongsTo(StatusRecord.self, using: ForeignKey([Column("statusId")]))
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public extension ContentDatabase {
|
|||
func insert(
|
||||
statuses: [Status],
|
||||
accountID: String,
|
||||
collection: AccountStatusCollection) -> AnyPublisher<Never, Error> {
|
||||
collection: ProfileCollection) -> AnyPublisher<Never, Error> {
|
||||
databaseQueue.writePublisher {
|
||||
for status in statuses {
|
||||
try status.save($0)
|
||||
|
@ -202,7 +202,7 @@ public extension ContentDatabase {
|
|||
|
||||
func statusesObservation(
|
||||
accountID: String,
|
||||
collection: AccountStatusCollection) -> AnyPublisher<[[Status]], Error> {
|
||||
collection: ProfileCollection) -> AnyPublisher<[[Status]], Error> {
|
||||
ValueObservation.tracking { db -> [[StatusResult]] in
|
||||
let statuses = try StatusRecord.filter(
|
||||
AccountStatusJoin
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
public enum AccountStatusCollection: String, Codable, CaseIterable {
|
||||
public enum ProfileCollection: String, Codable, CaseIterable {
|
||||
case statuses
|
||||
case statusesAndReplies
|
||||
case media
|
|
@ -3,7 +3,7 @@
|
|||
import Foundation
|
||||
import ViewModels
|
||||
|
||||
extension AccountStatusCollection {
|
||||
extension ProfileCollection {
|
||||
var title: String {
|
||||
switch self {
|
||||
case .statuses:
|
|
@ -18,7 +18,7 @@
|
|||
D0625E5F250F0CFF00502611 /* StatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0625E5E250F0CFF00502611 /* StatusView.swift */; };
|
||||
D06B492324D4611300642749 /* KingfisherSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = D06B492224D4611300642749 /* KingfisherSwiftUI */; };
|
||||
D0B32F50250B373600311912 /* RegistrationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B32F4F250B373600311912 /* RegistrationView.swift */; };
|
||||
D0B5FE9B251583DB00478838 /* AccountStatusCollection+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B5FE9A251583DB00478838 /* AccountStatusCollection+Extensions.swift */; };
|
||||
D0B5FE9B251583DB00478838 /* ProfileCollection+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B5FE9A251583DB00478838 /* ProfileCollection+Extensions.swift */; };
|
||||
D0B7434925100DBB00C13DB6 /* StatusView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D0B7434825100DBB00C13DB6 /* StatusView.xib */; };
|
||||
D0BEB1F324F8EE8C001B0F04 /* AttachmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BEB1F224F8EE8C001B0F04 /* AttachmentView.swift */; };
|
||||
D0BEB1F724F9A84B001B0F04 /* LoadingTableFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0BEB1F624F9A84B001B0F04 /* LoadingTableFooterView.swift */; };
|
||||
|
@ -106,7 +106,7 @@
|
|||
D085C3BB25008DEC008A6C5E /* DB */ = {isa = PBXFileReference; lastKnownFileType = folder; path = DB; sourceTree = "<group>"; };
|
||||
D0AD03552505814D0085A466 /* Base16 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Base16; sourceTree = "<group>"; };
|
||||
D0B32F4F250B373600311912 /* RegistrationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegistrationView.swift; sourceTree = "<group>"; };
|
||||
D0B5FE9A251583DB00478838 /* AccountStatusCollection+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountStatusCollection+Extensions.swift"; sourceTree = "<group>"; };
|
||||
D0B5FE9A251583DB00478838 /* ProfileCollection+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileCollection+Extensions.swift"; sourceTree = "<group>"; };
|
||||
D0B7434825100DBB00C13DB6 /* StatusView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = StatusView.xib; sourceTree = "<group>"; };
|
||||
D0BDF66524FD7A6400C7FA1C /* ServiceLayer */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ServiceLayer; sourceTree = "<group>"; };
|
||||
D0BEB1F224F8EE8C001B0F04 /* AttachmentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttachmentView.swift; sourceTree = "<group>"; };
|
||||
|
@ -326,7 +326,7 @@
|
|||
D0C7D46824F76169001EBDBB /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D0B5FE9A251583DB00478838 /* AccountStatusCollection+Extensions.swift */,
|
||||
D0B5FE9A251583DB00478838 /* ProfileCollection+Extensions.swift */,
|
||||
D01C6FAB252024BD003D0300 /* Array+Extensions.swift */,
|
||||
D0F0B135251AA12700942152 /* CollectionItemKind+Extensions.swift */,
|
||||
D0C7D46E24F76169001EBDBB /* KingfisherOptionsInfo+Extensions.swift */,
|
||||
|
@ -533,7 +533,7 @@
|
|||
D0625E5F250F0CFF00502611 /* StatusView.swift in Sources */,
|
||||
D0625E59250F092900502611 /* StatusListCell.swift in Sources */,
|
||||
D0C7D49D24F7616A001EBDBB /* PostingReadingPreferencesView.swift in Sources */,
|
||||
D0B5FE9B251583DB00478838 /* AccountStatusCollection+Extensions.swift in Sources */,
|
||||
D0B5FE9B251583DB00478838 /* ProfileCollection+Extensions.swift in Sources */,
|
||||
D0C7D49E24F7616A001EBDBB /* SecondaryNavigationView.swift in Sources */,
|
||||
D0C7D4DA24F7616A001EBDBB /* View+Extensions.swift in Sources */,
|
||||
D0C7D4D524F7616A001EBDBB /* String+Extensions.swift in Sources */,
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
// Copyright © 2020 Metabolist. All rights reserved.
|
||||
|
||||
import DB
|
||||
|
||||
public typealias AccountStatusCollection = DB.AccountStatusCollection
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright © 2020 Metabolist. All rights reserved.
|
||||
|
||||
import DB
|
||||
|
||||
public typealias ProfileCollection = DB.ProfileCollection
|
|
@ -9,7 +9,7 @@ import MastodonAPI
|
|||
public enum Navigation {
|
||||
case url(URL)
|
||||
case statusList(StatusListService)
|
||||
case accountStatuses(AccountStatusesService)
|
||||
case profile(ProfileService)
|
||||
case webfingerStart
|
||||
case webfingerEnd
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public extension NavigationService {
|
|||
contentDatabase: contentDatabase)))
|
||||
.eraseToAnyPublisher()
|
||||
} else if let accountID = accountID(url: url) {
|
||||
return Just(.accountStatuses(accountStatusesService(id: accountID))).eraseToAnyPublisher()
|
||||
return Just(.profile(profileService(id: accountID))).eraseToAnyPublisher()
|
||||
} else if mastodonAPIClient.instanceURL.host == url.host, let statusID = url.statusID {
|
||||
return Just(
|
||||
.statusList(
|
||||
|
@ -59,12 +59,12 @@ public extension NavigationService {
|
|||
StatusListService(statusID: id, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
||||
}
|
||||
|
||||
func accountStatusesService(id: String) -> AccountStatusesService {
|
||||
AccountStatusesService(id: id, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
||||
func profileService(id: String) -> ProfileService {
|
||||
ProfileService(id: id, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
||||
}
|
||||
|
||||
func accountStatusesService(account: Account) -> AccountStatusesService {
|
||||
AccountStatusesService(account: account, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
||||
func profileService(account: Account) -> ProfileService {
|
||||
ProfileService(account: account, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
||||
}
|
||||
|
||||
func statusService(status: Status) -> StatusService {
|
||||
|
@ -114,7 +114,7 @@ private extension NavigationService {
|
|||
mastodonAPIClient: mastodonAPIClient,
|
||||
contentDatabase: contentDatabase))
|
||||
} else if let account = results.accounts.first {
|
||||
return .accountStatuses(accountStatusesService(account: account))
|
||||
return .profile(profileService(account: account))
|
||||
} else if let status = results.statuses.first {
|
||||
return .statusList(
|
||||
StatusListService(
|
||||
|
|
|
@ -6,7 +6,7 @@ import Foundation
|
|||
import Mastodon
|
||||
import MastodonAPI
|
||||
|
||||
public struct AccountStatusesService {
|
||||
public struct ProfileService {
|
||||
public let accountService: AnyPublisher<AccountService, Error>
|
||||
|
||||
private let accountID: String
|
||||
|
@ -50,9 +50,9 @@ public struct AccountStatusesService {
|
|||
}
|
||||
}
|
||||
|
||||
public extension AccountStatusesService {
|
||||
public extension ProfileService {
|
||||
func statusListService(
|
||||
collectionPublisher: CurrentValueSubject<AccountStatusCollection, Never>) -> StatusListService {
|
||||
collectionPublisher: CurrentValueSubject<ProfileCollection, Never>) -> StatusListService {
|
||||
StatusListService(
|
||||
accountID: accountID,
|
||||
collection: collectionPublisher,
|
|
@ -81,7 +81,7 @@ extension StatusListService {
|
|||
|
||||
init(
|
||||
accountID: String,
|
||||
collection: CurrentValueSubject<AccountStatusCollection, Never>,
|
||||
collection: CurrentValueSubject<ProfileCollection, Never>,
|
||||
mastodonAPIClient: MastodonAPIClient,
|
||||
contentDatabase: ContentDatabase) {
|
||||
let nextPageMaxIDsSubject = PassthroughSubject<String?, Never>()
|
||||
|
|
|
@ -160,7 +160,7 @@ private extension TableViewController {
|
|||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
if let accountsStatusesViewModel = viewModel as? AccountStatusesViewModel {
|
||||
if let accountsStatusesViewModel = viewModel as? ProfileViewModel {
|
||||
// Initial size is to avoid unsatisfiable constraint warning
|
||||
let accountHeaderView = AccountHeaderView(
|
||||
frame: .init(
|
||||
|
|
|
@ -66,18 +66,15 @@ extension AccountListViewModel: CollectionViewModel {
|
|||
switch item.kind {
|
||||
case .account:
|
||||
let navigationService = accountListService.navigationService
|
||||
let accountStatusesService: AccountStatusesService
|
||||
let profileService: ProfileService
|
||||
|
||||
if let account = accounts[item.id] {
|
||||
accountStatusesService = navigationService.accountStatusesService(account: account)
|
||||
profileService = navigationService.profileService(account: account)
|
||||
} else {
|
||||
accountStatusesService = navigationService.accountStatusesService(id: item.id)
|
||||
profileService = navigationService.profileService(id: item.id)
|
||||
}
|
||||
|
||||
navigationEventsSubject.send(
|
||||
.collectionNavigation(
|
||||
AccountStatusesViewModel(
|
||||
accountStatusesService: accountStatusesService)))
|
||||
navigationEventsSubject.send(.collectionNavigation(ProfileViewModel(profileService: profileService)))
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
// Copyright © 2020 Metabolist. All rights reserved.
|
||||
|
||||
import ServiceLayer
|
||||
|
||||
public typealias AccountStatusCollection = ServiceLayer.AccountStatusCollection
|
|
@ -21,8 +21,8 @@ extension NavigationEvent {
|
|||
self = .urlNavigation(url)
|
||||
case let .statusList(statusListService):
|
||||
self = .collectionNavigation(StatusListViewModel(statusListService: statusListService))
|
||||
case let .accountStatuses(accountStatusesService):
|
||||
self = .collectionNavigation(AccountStatusesViewModel(accountStatusesService: accountStatusesService))
|
||||
case let .profile(profileService):
|
||||
self = .collectionNavigation(ProfileViewModel(profileService: profileService))
|
||||
case .webfingerStart:
|
||||
self = .webfingerStart
|
||||
case .webfingerEnd:
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright © 2020 Metabolist. All rights reserved.
|
||||
|
||||
import ServiceLayer
|
||||
|
||||
public typealias ProfileCollection = ServiceLayer.ProfileCollection
|
|
@ -5,24 +5,24 @@ import Foundation
|
|||
import Mastodon
|
||||
import ServiceLayer
|
||||
|
||||
public class AccountStatusesViewModel: StatusListViewModel {
|
||||
public class ProfileViewModel: StatusListViewModel {
|
||||
@Published public private(set) var accountViewModel: AccountViewModel?
|
||||
@Published public var collection = AccountStatusCollection.statuses
|
||||
private let accountStatusesService: AccountStatusesService
|
||||
@Published public var collection = ProfileCollection.statuses
|
||||
private let profileService: ProfileService
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
init(accountStatusesService: AccountStatusesService) {
|
||||
self.accountStatusesService = accountStatusesService
|
||||
init(profileService: ProfileService) {
|
||||
self.profileService = profileService
|
||||
|
||||
let collectionSubject = CurrentValueSubject<AccountStatusCollection, Never>(.statuses)
|
||||
let collectionSubject = CurrentValueSubject<ProfileCollection, Never>(.statuses)
|
||||
|
||||
super.init(
|
||||
statusListService: accountStatusesService.statusListService(
|
||||
statusListService: profileService.statusListService(
|
||||
collectionPublisher: collectionSubject))
|
||||
|
||||
$collection.sink(receiveValue: collectionSubject.send).store(in: &cancellables)
|
||||
|
||||
accountStatusesService.accountService
|
||||
profileService.accountService
|
||||
.map(AccountViewModel.init(accountService:))
|
||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
||||
.assign(to: &$accountViewModel)
|
||||
|
@ -53,7 +53,7 @@ public class AccountStatusesViewModel: StatusListViewModel {
|
|||
|
||||
public override func request(maxID: String? = nil, minID: String? = nil) {
|
||||
if case .statuses = collection, maxID == nil {
|
||||
accountStatusesService.fetchPinnedStatuses()
|
||||
profileService.fetchPinnedStatuses()
|
||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
||||
.sink { _ in }
|
||||
.store(in: &cancellables)
|
||||
|
@ -67,9 +67,9 @@ public class AccountStatusesViewModel: StatusListViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
public extension AccountStatusesViewModel {
|
||||
public extension ProfileViewModel {
|
||||
func fetchAccount() {
|
||||
accountStatusesService.fetchAccount()
|
||||
profileService.fetchAccount()
|
||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
||||
.sink { _ in }
|
||||
.store(in: &cancellables)
|
|
@ -118,8 +118,8 @@ public extension StatusViewModel {
|
|||
func accountSelected() {
|
||||
eventsSubject.send(
|
||||
Just(CollectionItemEvent.navigation(
|
||||
.accountStatuses(
|
||||
statusService.navigationService.accountStatusesService(
|
||||
.profile(
|
||||
statusService.navigationService.profileService(
|
||||
account: statusService.status.displayStatus.account))))
|
||||
.setFailureType(to: Error.self)
|
||||
.eraseToAnyPublisher())
|
||||
|
|
|
@ -9,7 +9,7 @@ class AccountHeaderView: UIView {
|
|||
let noteTextView = TouchFallthroughTextView()
|
||||
let segmentedControl = UISegmentedControl()
|
||||
|
||||
var viewModel: AccountStatusesViewModel? {
|
||||
var viewModel: ProfileViewModel? {
|
||||
didSet {
|
||||
if let accountViewModel = viewModel?.accountViewModel {
|
||||
headerImageView.kf.setImage(with: accountViewModel.headerURL)
|
||||
|
@ -75,7 +75,7 @@ private extension AccountHeaderView {
|
|||
noteTextView.delegate = self
|
||||
baseStackView.addArrangedSubview(noteTextView)
|
||||
|
||||
for (index, collection) in AccountStatusCollection.allCases.enumerated() {
|
||||
for (index, collection) in ProfileCollection.allCases.enumerated() {
|
||||
segmentedControl.insertSegment(
|
||||
action: UIAction(title: collection.title) { [weak self] _ in
|
||||
self?.viewModel?.collection = collection
|
||||
|
|
Loading…
Reference in a new issue