Minor cleanup (IOS-186)
This commit is contained in:
parent
2f5169d0c3
commit
395da6f0c3
|
@ -5,9 +5,7 @@
|
||||||
// Created by Marcus Kida on 22.11.22.
|
// Created by Marcus Kida on 22.11.22.
|
||||||
//
|
//
|
||||||
|
|
||||||
import os
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
|
||||||
import MastodonAsset
|
import MastodonAsset
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
import MastodonUI
|
import MastodonUI
|
||||||
|
@ -42,14 +40,11 @@ final class FollowedTagsViewController: UIViewController, NeedsDependency {
|
||||||
|
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
|
||||||
let title = L10n.Scene.FollowedTags.title
|
title = L10n.Scene.FollowedTags.title
|
||||||
self.title = title
|
|
||||||
|
|
||||||
view.backgroundColor = .secondarySystemBackground
|
view.backgroundColor = .secondarySystemBackground
|
||||||
|
|
||||||
view.addSubview(tableView)
|
view.addSubview(tableView)
|
||||||
tableView.pinToParent()
|
tableView.pinToParent()
|
||||||
|
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
|
|
||||||
refreshControl.addTarget(self, action: #selector(FollowedTagsViewController.refresh(_:)), for: .valueChanged)
|
refreshControl.addTarget(self, action: #selector(FollowedTagsViewController.refresh(_:)), for: .valueChanged)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,11 @@
|
||||||
// Created by Marcus Kida on 23.11.22.
|
// Created by Marcus Kida on 23.11.22.
|
||||||
//
|
//
|
||||||
|
|
||||||
import os
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import MastodonCore
|
import MastodonCore
|
||||||
|
|
||||||
final class FollowedTagsViewModel: NSObject {
|
final class FollowedTagsViewModel: NSObject {
|
||||||
var disposeBag = Set<AnyCancellable>()
|
|
||||||
private(set) var followedTags: [Mastodon.Entity.Tag]
|
private(set) var followedTags: [Mastodon.Entity.Tag]
|
||||||
|
|
||||||
private weak var tableView: UITableView?
|
private weak var tableView: UITableView?
|
||||||
|
@ -21,10 +18,7 @@ final class FollowedTagsViewModel: NSObject {
|
||||||
// input
|
// input
|
||||||
let context: AppContext
|
let context: AppContext
|
||||||
let authContext: AuthContext
|
let authContext: AuthContext
|
||||||
|
|
||||||
// output
|
|
||||||
let presentHashtagTimeline = PassthroughSubject<HashtagTimelineViewModel, Never>()
|
|
||||||
|
|
||||||
init(context: AppContext, authContext: AuthContext) {
|
init(context: AppContext, authContext: AuthContext) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.authContext = authContext
|
self.authContext = authContext
|
||||||
|
@ -43,18 +37,20 @@ extension FollowedTagsViewModel {
|
||||||
|
|
||||||
func fetchFollowedTags(completion: (() -> Void)? = nil ) {
|
func fetchFollowedTags(completion: (() -> Void)? = nil ) {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
followedTags = try await context.apiService.getFollowedTags(
|
do {
|
||||||
domain: authContext.mastodonAuthenticationBox.domain,
|
followedTags = try await context.apiService.getFollowedTags(
|
||||||
query: Mastodon.API.Account.FollowedTagsQuery(limit: nil),
|
domain: authContext.mastodonAuthenticationBox.domain,
|
||||||
authenticationBox: authContext.mastodonAuthenticationBox
|
query: Mastodon.API.Account.FollowedTagsQuery(limit: nil),
|
||||||
).value
|
authenticationBox: authContext.mastodonAuthenticationBox
|
||||||
|
).value
|
||||||
|
|
||||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||||
snapshot.appendSections([.main])
|
snapshot.appendSections([.main])
|
||||||
let items = followedTags.compactMap { Item.hashtag($0) }
|
let items = followedTags.compactMap { Item.hashtag($0) }
|
||||||
snapshot.appendItems(items, toSection: .main)
|
snapshot.appendItems(items, toSection: .main)
|
||||||
|
|
||||||
await diffableDataSource?.apply(snapshot)
|
await diffableDataSource?.apply(snapshot)
|
||||||
|
} catch {}
|
||||||
|
|
||||||
completion?()
|
completion?()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue