Minor cleanup (IOS-186)

This commit is contained in:
Nathan Mattes 2023-11-10 13:52:49 +01:00
parent 2f5169d0c3
commit 395da6f0c3
3 changed files with 14 additions and 24 deletions

View File

@ -5,9 +5,7 @@
// Created by Marcus Kida on 22.11.22.
//
import os
import UIKit
import Combine
import MastodonAsset
import MastodonCore
import MastodonUI
@ -42,14 +40,11 @@ final class FollowedTagsViewController: UIViewController, NeedsDependency {
super.init(nibName: nil, bundle: nil)
let title = L10n.Scene.FollowedTags.title
self.title = title
title = L10n.Scene.FollowedTags.title
view.backgroundColor = .secondarySystemBackground
view.addSubview(tableView)
tableView.pinToParent()
tableView.delegate = self
refreshControl.addTarget(self, action: #selector(FollowedTagsViewController.refresh(_:)), for: .valueChanged)

View File

@ -6,7 +6,6 @@
//
import UIKit
import Combine
import MastodonSDK
import MastodonCore

View File

@ -5,14 +5,11 @@
// Created by Marcus Kida on 23.11.22.
//
import os
import UIKit
import Combine
import MastodonSDK
import MastodonCore
final class FollowedTagsViewModel: NSObject {
var disposeBag = Set<AnyCancellable>()
private(set) var followedTags: [Mastodon.Entity.Tag]
private weak var tableView: UITableView?
@ -22,9 +19,6 @@ final class FollowedTagsViewModel: NSObject {
let context: AppContext
let authContext: AuthContext
// output
let presentHashtagTimeline = PassthroughSubject<HashtagTimelineViewModel, Never>()
init(context: AppContext, authContext: AuthContext) {
self.context = context
self.authContext = authContext
@ -43,18 +37,20 @@ extension FollowedTagsViewModel {
func fetchFollowedTags(completion: (() -> Void)? = nil ) {
Task { @MainActor in
followedTags = try await context.apiService.getFollowedTags(
domain: authContext.mastodonAuthenticationBox.domain,
query: Mastodon.API.Account.FollowedTagsQuery(limit: nil),
authenticationBox: authContext.mastodonAuthenticationBox
).value
do {
followedTags = try await context.apiService.getFollowedTags(
domain: authContext.mastodonAuthenticationBox.domain,
query: Mastodon.API.Account.FollowedTagsQuery(limit: nil),
authenticationBox: authContext.mastodonAuthenticationBox
).value
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
snapshot.appendSections([.main])
let items = followedTags.compactMap { Item.hashtag($0) }
snapshot.appendItems(items, toSection: .main)
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
snapshot.appendSections([.main])
let items = followedTags.compactMap { Item.hashtag($0) }
snapshot.appendItems(items, toSection: .main)
await diffableDataSource?.apply(snapshot)
await diffableDataSource?.apply(snapshot)
} catch {}
completion?()
}