Minor cleanup (IOS-241)
This commit is contained in:
parent
5925d84dd9
commit
67e1e5e3b4
|
@ -168,6 +168,7 @@
|
|||
D85DF9712C481B1100A01408 /* NotificationRequestsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85DF96E2C481B1100A01408 /* NotificationRequestsTableViewController.swift */; };
|
||||
D85DF9722C481B1100A01408 /* NotificationRequestTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85DF96F2C481B1100A01408 /* NotificationRequestTableViewCell.swift */; };
|
||||
D85DF9742C481B3500A01408 /* DataSourceFacade+Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85DF9732C481B3500A01408 /* DataSourceFacade+Notifications.swift */; };
|
||||
D85DF9762C4965A900A01408 /* NotificationRequestsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85DF9752C4965A900A01408 /* NotificationRequestsViewModel.swift */; };
|
||||
D87364F92AE28DB500C8F919 /* Kanna in Frameworks */ = {isa = PBXBuildFile; productRef = D87364F82AE28DB500C8F919 /* Kanna */; };
|
||||
D87BFC8B291D5C6B00FEE264 /* MastodonLoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87BFC8A291D5C6B00FEE264 /* MastodonLoginView.swift */; };
|
||||
D87BFC8D291EB81200FEE264 /* MastodonLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87BFC8C291EB81200FEE264 /* MastodonLoginViewModel.swift */; };
|
||||
|
@ -813,6 +814,7 @@
|
|||
D85DF96E2C481B1100A01408 /* NotificationRequestsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationRequestsTableViewController.swift; sourceTree = "<group>"; };
|
||||
D85DF96F2C481B1100A01408 /* NotificationRequestTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationRequestTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D85DF9732C481B3500A01408 /* DataSourceFacade+Notifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+Notifications.swift"; sourceTree = "<group>"; };
|
||||
D85DF9752C4965A900A01408 /* NotificationRequestsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationRequestsViewModel.swift; sourceTree = "<group>"; };
|
||||
D87BFC8A291D5C6B00FEE264 /* MastodonLoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonLoginView.swift; sourceTree = "<group>"; };
|
||||
D87BFC8C291EB81200FEE264 /* MastodonLoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonLoginViewModel.swift; sourceTree = "<group>"; };
|
||||
D87BFC8E291EC26A00FEE264 /* MastodonLoginServerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonLoginServerTableViewCell.swift; sourceTree = "<group>"; };
|
||||
|
@ -1850,6 +1852,7 @@
|
|||
children = (
|
||||
D85DF96E2C481B1100A01408 /* NotificationRequestsTableViewController.swift */,
|
||||
D85DF96F2C481B1100A01408 /* NotificationRequestTableViewCell.swift */,
|
||||
D85DF9752C4965A900A01408 /* NotificationRequestsViewModel.swift */,
|
||||
);
|
||||
name = Requests;
|
||||
path = "Notification Filtering/Requests";
|
||||
|
@ -3597,6 +3600,7 @@
|
|||
DB6180DD263918E30018D199 /* MediaPreviewViewController.swift in Sources */,
|
||||
DBE3CDEC261C6B2900430CC6 /* FavoriteViewController.swift in Sources */,
|
||||
DB938EE62623F50700E5B6C1 /* ThreadViewController.swift in Sources */,
|
||||
D85DF9762C4965A900A01408 /* NotificationRequestsViewModel.swift in Sources */,
|
||||
DB6180F426391D110018D199 /* MediaPreviewImageView.swift in Sources */,
|
||||
DBF9814A265E24F500E4BA07 /* ProfileFieldCollectionViewHeaderFooterView.swift in Sources */,
|
||||
2D939AB525EDD8A90076FA61 /* String.swift in Sources */,
|
||||
|
|
|
@ -564,8 +564,7 @@ private extension SceneCoordinator {
|
|||
let composeViewController = ComposeViewController(viewModel: viewModel)
|
||||
viewController = composeViewController
|
||||
case .notificationRequests(let viewModel):
|
||||
//FIXME: Put either AuthContext or Everything in ViewModel
|
||||
viewController = NotificationRequestsTableViewController(viewModel: viewModel, appContext: appContext, coordinator: self)
|
||||
viewController = NotificationRequestsTableViewController(viewModel: viewModel)
|
||||
case .notificationPolicy(let viewModel):
|
||||
viewController = NotificationPolicyViewController(viewModel: viewModel)
|
||||
case .notificationTimeline(let viewModel):
|
||||
|
|
|
@ -13,7 +13,7 @@ extension DataSourceFacade {
|
|||
|
||||
do {
|
||||
let notificationRequests = try await provider.context.apiService.notificationRequests(authenticationBox: provider.authContext.mastodonAuthenticationBox).value
|
||||
let viewModel = NotificationRequestsViewModel(requests: notificationRequests, authContext: provider.authContext)
|
||||
let viewModel = NotificationRequestsViewModel(appContext: provider.context, authContext: provider.authContext, coordinator: provider.coordinator, requests: notificationRequests)
|
||||
|
||||
provider.coordinator.hideLoading()
|
||||
|
||||
|
@ -31,17 +31,10 @@ extension DataSourceFacade {
|
|||
) async {
|
||||
provider.coordinator.showLoading()
|
||||
|
||||
do {
|
||||
// load notifications for request.account
|
||||
// show NotificationTimelineViewController with NotificationTimelineViewModel
|
||||
let notificationTimelineViewModel = NotificationTimelineViewModel(context: provider.context, authContext: provider.authContext, scope: .fromAccount(request.account))
|
||||
let notificationTimelineViewModel = NotificationTimelineViewModel(context: provider.context, authContext: provider.authContext, scope: .fromAccount(request.account))
|
||||
|
||||
provider.coordinator.hideLoading()
|
||||
provider.coordinator.present(scene: .notificationTimeline(viewModel: notificationTimelineViewModel), transition: .show)
|
||||
} catch {
|
||||
//TODO: Error Handling
|
||||
provider.coordinator.hideLoading()
|
||||
}
|
||||
provider.coordinator.hideLoading()
|
||||
provider.coordinator.present(scene: .notificationTimeline(viewModel: notificationTimelineViewModel), transition: .show)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,6 @@ import UIKit
|
|||
import MastodonSDK
|
||||
import MastodonCore
|
||||
|
||||
struct NotificationRequestsViewModel {
|
||||
var requests: [Mastodon.Entity.NotificationRequest]
|
||||
let authContext: AuthContext
|
||||
}
|
||||
|
||||
enum NotificationRequestsSection: Hashable {
|
||||
case main
|
||||
}
|
||||
|
@ -30,11 +25,11 @@ class NotificationRequestsTableViewController: UIViewController, NeedsDependency
|
|||
var viewModel: NotificationRequestsViewModel
|
||||
var dataSource: UITableViewDiffableDataSource<NotificationRequestsSection, NotificationRequestItem>?
|
||||
|
||||
init(viewModel: NotificationRequestsViewModel, appContext: AppContext, coordinator: SceneCoordinator) {
|
||||
init(viewModel: NotificationRequestsViewModel) {
|
||||
|
||||
self.viewModel = viewModel
|
||||
self.context = appContext
|
||||
self.coordinator = coordinator
|
||||
self.context = viewModel.appContext
|
||||
self.coordinator = viewModel.coordinator
|
||||
|
||||
tableView = UITableView(frame: .zero)
|
||||
tableView.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright © 2024 Mastodon gGmbH. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
import MastodonSDK
|
||||
import MastodonCore
|
||||
|
||||
struct NotificationRequestsViewModel {
|
||||
let appContext: AppContext
|
||||
let authContext: AuthContext
|
||||
let coordinator: SceneCoordinator
|
||||
|
||||
var requests: [Mastodon.Entity.NotificationRequest]
|
||||
|
||||
init(appContext: AppContext, authContext: AuthContext, coordinator: SceneCoordinator, requests: [Mastodon.Entity.NotificationRequest]) {
|
||||
self.appContext = appContext
|
||||
self.authContext = authContext
|
||||
self.coordinator = coordinator
|
||||
self.requests = requests
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue