Remove AuthContext
MastodonAuthenticationBox, which already wraps the MastodonAuthentication, is now used directly.
This commit is contained in:
parent
4acb163074
commit
04108fd0e4
@ -22,7 +22,7 @@ final public class SceneCoordinator {
|
||||
private weak var sceneDelegate: SceneDelegate!
|
||||
private(set) weak var appContext: AppContext!
|
||||
|
||||
private(set) var authContext: AuthContext?
|
||||
private(set) var authenticationBox: MastodonAuthenticationBox?
|
||||
|
||||
let id = UUID().uuidString
|
||||
|
||||
@ -52,7 +52,7 @@ final public class SceneCoordinator {
|
||||
[weak self] pushNotification in
|
||||
guard let self else { return }
|
||||
Task { @MainActor in
|
||||
guard let currentActiveAuthenticationBox = self.authContext?.mastodonAuthenticationBox else { return }
|
||||
guard let currentActiveAuthenticationBox = self.authenticationBox else { return }
|
||||
let accessToken = pushNotification.accessToken // use raw accessToken value without normalize
|
||||
if currentActiveAuthenticationBox.userAuthorization.accessToken == accessToken {
|
||||
// do nothing if notification for current account
|
||||
@ -92,22 +92,22 @@ final public class SceneCoordinator {
|
||||
|
||||
// show notification related content
|
||||
guard let type = Mastodon.Entity.Notification.NotificationType(rawValue: pushNotification.notificationType) else { return }
|
||||
guard let authContext = self.authContext else { return }
|
||||
guard let me = authContext.mastodonAuthenticationBox.authentication.account() else { return }
|
||||
guard let authenticationBox = self.authenticationBox else { return }
|
||||
guard let me = authenticationBox.authentication.account() else { return }
|
||||
let notificationID = String(pushNotification.notificationID)
|
||||
|
||||
switch type {
|
||||
case .follow:
|
||||
let account = try await appContext.apiService.notification(
|
||||
notificationID: notificationID,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value.account
|
||||
|
||||
let relationship = try await appContext.apiService.relationship(forAccounts: [account], authenticationBox: authContext.mastodonAuthenticationBox).value.first
|
||||
let relationship = try await appContext.apiService.relationship(forAccounts: [account], authenticationBox: authenticationBox).value.first
|
||||
|
||||
let profileViewModel = ProfileViewModel(
|
||||
context: appContext,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
account: account,
|
||||
relationship: relationship,
|
||||
me: me
|
||||
@ -123,7 +123,7 @@ final public class SceneCoordinator {
|
||||
case .mention, .reblog, .favourite, .poll, .status:
|
||||
let threadViewModel = RemoteThreadViewModel(
|
||||
context: appContext,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
notificationID: notificationID
|
||||
)
|
||||
_ = self.present(
|
||||
@ -253,18 +253,18 @@ extension SceneCoordinator {
|
||||
let rootViewController: UIViewController
|
||||
|
||||
AuthenticationServiceProvider.shared.prepareForUse()
|
||||
let _authentication = AuthenticationServiceProvider.shared.authenticationSortedByActivation().first
|
||||
let _authContext = _authentication.flatMap { AuthContext(authentication: $0) }
|
||||
self.authContext = _authContext
|
||||
if let _authentication = AuthenticationServiceProvider.shared.authenticationSortedByActivation().first {
|
||||
self.authenticationBox = MastodonAuthenticationBox(authentication: _authentication)
|
||||
}
|
||||
|
||||
switch UIDevice.current.userInterfaceIdiom {
|
||||
case .phone:
|
||||
let viewController = MainTabBarController(context: appContext, coordinator: self, authContext: _authContext)
|
||||
let viewController = MainTabBarController(context: appContext, coordinator: self, authenticationBox: authenticationBox)
|
||||
self.splitViewController = nil
|
||||
self.tabBarController = viewController
|
||||
rootViewController = viewController
|
||||
default:
|
||||
let splitViewController = RootSplitViewController(context: appContext, coordinator: self, authContext: _authContext)
|
||||
let splitViewController = RootSplitViewController(context: appContext, coordinator: self, authenticationBox: authenticationBox)
|
||||
self.splitViewController = splitViewController
|
||||
self.tabBarController = splitViewController.contentSplitViewController.mainTabBarController
|
||||
rootViewController = splitViewController
|
||||
@ -273,7 +273,7 @@ extension SceneCoordinator {
|
||||
sceneDelegate.window?.rootViewController = rootViewController // base: main
|
||||
self.rootViewController = rootViewController
|
||||
|
||||
if _authContext == nil { // entry #1: welcome
|
||||
if authenticationBox == nil { // entry #1: welcome
|
||||
DispatchQueue.main.async {
|
||||
_ = self.present(
|
||||
scene: .welcome,
|
||||
@ -434,7 +434,7 @@ private extension SceneCoordinator {
|
||||
let _viewController = WebViewController(viewModel)
|
||||
viewController = _viewController
|
||||
case .searchDetail(let viewModel):
|
||||
let _viewController = SearchDetailViewController(appContext: appContext, sceneCoordinator: self, authContext: viewModel.authContext)
|
||||
let _viewController = SearchDetailViewController(appContext: appContext, sceneCoordinator: self, authenticationBox: viewModel.authenticationBox)
|
||||
_viewController.viewModel = viewModel
|
||||
viewController = _viewController
|
||||
case .searchResult(let viewModel):
|
||||
@ -470,9 +470,9 @@ private extension SceneCoordinator {
|
||||
_viewController.viewModel = viewModel
|
||||
viewController = _viewController
|
||||
case .followedTags(let viewModel):
|
||||
guard let authContext else { return nil }
|
||||
guard let authenticationBox else { return nil }
|
||||
|
||||
viewController = FollowedTagsViewController(appContext: appContext, sceneCoordinator: self, authContext: authContext, viewModel: viewModel)
|
||||
viewController = FollowedTagsViewController(appContext: appContext, sceneCoordinator: self, authenticationBox: authenticationBox, viewModel: viewModel)
|
||||
case .favorite(let viewModel):
|
||||
let _viewController = FavoriteViewController()
|
||||
_viewController.viewModel = viewModel
|
||||
@ -544,15 +544,15 @@ private extension SceneCoordinator {
|
||||
viewController = activityViewController
|
||||
case .settings(let setting):
|
||||
guard let presentedOn = sender,
|
||||
let accountName = authContext?.mastodonAuthenticationBox.authentication.username,
|
||||
let authContext
|
||||
let accountName = authenticationBox?.authentication.username,
|
||||
let authenticationBox
|
||||
else { return nil }
|
||||
|
||||
let settingsCoordinator = SettingsCoordinator(presentedOn: presentedOn,
|
||||
accountName: accountName,
|
||||
setting: setting,
|
||||
appContext: appContext,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
sceneCoordinator: self
|
||||
)
|
||||
settingsCoordinator.delegate = self
|
||||
@ -643,15 +643,15 @@ extension SceneCoordinator: SettingsCoordinatorDelegate {
|
||||
|
||||
let cancelAction = UIAlertAction(title: L10n.Common.Controls.Actions.cancel, style: .cancel)
|
||||
let signOutAction = UIAlertAction(title: L10n.Common.Alerts.SignOut.confirm, style: .destructive) { [weak self] _ in
|
||||
guard let self, let authContext = self.authContext else { return }
|
||||
guard let self, let authenticationBox = self.authenticationBox else { return }
|
||||
|
||||
self.appContext.notificationService.clearNotificationCountForActiveUser()
|
||||
|
||||
Task { @MainActor in
|
||||
try await self.appContext.authenticationService.signOutMastodonUser(
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
let userIdentifier = authContext.mastodonAuthenticationBox
|
||||
let userIdentifier = authenticationBox
|
||||
FileManager.default.invalidateHomeTimelineCache(for: userIdentifier)
|
||||
FileManager.default.invalidateNotificationsAll(for: userIdentifier)
|
||||
FileManager.default.invalidateNotificationsMentions(for: userIdentifier)
|
||||
@ -679,9 +679,9 @@ extension SceneCoordinator: SettingsCoordinatorDelegate {
|
||||
|
||||
@MainActor
|
||||
func openPrivacyURL(_ settingsCoordinator: SettingsCoordinator) {
|
||||
guard let authContext else { return }
|
||||
guard let authenticationBox else { return }
|
||||
|
||||
let domain = authContext.mastodonAuthenticationBox.domain
|
||||
let domain = authenticationBox.domain
|
||||
let privacyURL = Mastodon.API.privacyURL(domain: domain)
|
||||
|
||||
_ = present(scene: .safari(url: privacyURL),
|
||||
@ -691,9 +691,9 @@ extension SceneCoordinator: SettingsCoordinatorDelegate {
|
||||
}
|
||||
|
||||
func openProfileSettingsURL(_ settingsCoordinator: SettingsCoordinator) {
|
||||
guard let authContext else { return }
|
||||
guard let authenticationBox else { return }
|
||||
|
||||
let domain = authContext.mastodonAuthenticationBox.domain
|
||||
let domain = authenticationBox.domain
|
||||
let profileSettingsURL = Mastodon.API.profileSettingsURL(domain: domain)
|
||||
|
||||
let authenticationController = MastodonAuthenticationController(context: appContext, authenticateURL: profileSettingsURL)
|
||||
|
@ -23,7 +23,7 @@ enum ReportSection: Equatable, Hashable {
|
||||
extension ReportSection {
|
||||
|
||||
struct Configuration {
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
}
|
||||
|
||||
static func diffableDataSource(
|
||||
@ -91,12 +91,12 @@ extension ReportSection {
|
||||
) {
|
||||
StatusSection.setupStatusPollDataSource(
|
||||
context: context,
|
||||
authContext: configuration.authContext,
|
||||
authenticationBox: configuration.authenticationBox,
|
||||
statusView: cell.statusView
|
||||
)
|
||||
|
||||
cell.statusView.viewModel.context = context
|
||||
cell.statusView.viewModel.authContext = configuration.authContext
|
||||
cell.statusView.viewModel.authenticationBox = configuration.authenticationBox
|
||||
|
||||
cell.configure(
|
||||
tableView: tableView,
|
||||
|
@ -25,7 +25,7 @@ extension StatusSection {
|
||||
|
||||
struct Configuration {
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
weak var statusTableViewCellDelegate: StatusTableViewCellDelegate?
|
||||
weak var timelineMiddleLoaderTableViewCellDelegate: TimelineMiddleLoaderTableViewCellDelegate?
|
||||
let filterContext: Mastodon.Entity.Filter.Context?
|
||||
@ -141,7 +141,7 @@ extension StatusSection {
|
||||
|
||||
public static func setupStatusPollDataSource(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
statusView: StatusView
|
||||
) {
|
||||
statusView.pollTableViewDiffableDataSource = UITableViewDiffableDataSource<PollSection, PollItem>(tableView: statusView.pollTableView) { tableView, indexPath, item in
|
||||
@ -156,7 +156,7 @@ extension StatusSection {
|
||||
return _cell ?? PollOptionTableViewCell()
|
||||
}()
|
||||
|
||||
cell.pollOptionView.viewModel.authContext = authContext
|
||||
cell.pollOptionView.viewModel.authenticationBox = authenticationBox
|
||||
|
||||
cell.pollOptionView.configure(pollOption: record)
|
||||
|
||||
@ -173,7 +173,7 @@ extension StatusSection {
|
||||
|
||||
public static func setupStatusPollHistoryDataSource(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
statusView: StatusView
|
||||
) {
|
||||
statusView.pollTableViewDiffableDataSource = UITableViewDiffableDataSource<PollSection, PollItem>(tableView: statusView.pollTableView) { tableView, indexPath, item in
|
||||
@ -207,12 +207,12 @@ extension StatusSection {
|
||||
) {
|
||||
setupStatusPollDataSource(
|
||||
context: context,
|
||||
authContext: configuration.authContext,
|
||||
authenticationBox: configuration.authenticationBox,
|
||||
statusView: cell.statusView
|
||||
)
|
||||
|
||||
cell.statusView.viewModel.context = configuration.context
|
||||
cell.statusView.viewModel.authContext = configuration.authContext
|
||||
cell.statusView.viewModel.authenticationBox = configuration.authenticationBox
|
||||
|
||||
cell.configure(
|
||||
tableView: tableView,
|
||||
@ -235,12 +235,12 @@ extension StatusSection {
|
||||
) {
|
||||
setupStatusPollDataSource(
|
||||
context: context,
|
||||
authContext: configuration.authContext,
|
||||
authenticationBox: configuration.authenticationBox,
|
||||
statusView: cell.statusView
|
||||
)
|
||||
|
||||
cell.statusView.viewModel.context = configuration.context
|
||||
cell.statusView.viewModel.authContext = configuration.authContext
|
||||
cell.statusView.viewModel.authenticationBox = configuration.authenticationBox
|
||||
|
||||
cell.configure(
|
||||
tableView: tableView,
|
||||
|
@ -22,7 +22,7 @@ extension UserSection {
|
||||
static func diffableDataSource(
|
||||
tableView: UITableView,
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
userTableViewCellDelegate: UserTableViewCellDelegate?
|
||||
) -> UITableViewDiffableDataSource<UserSection, UserItem> {
|
||||
tableView.register(UserTableViewCell.self, forCellReuseIdentifier: String(describing: UserTableViewCell.self))
|
||||
@ -37,7 +37,7 @@ extension UserSection {
|
||||
case .account(let account, let relationship):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UserTableViewCell.self), for: indexPath) as! UserTableViewCell
|
||||
|
||||
guard let me = authContext.mastodonAuthenticationBox.authentication.account() else { return cell }
|
||||
guard let me = authenticationBox.authentication.account() else { return cell }
|
||||
|
||||
cell.userView.setButtonState(.loading)
|
||||
cell.configure(
|
||||
|
@ -9,13 +9,13 @@ import MastodonCore
|
||||
import MastodonSDK
|
||||
|
||||
extension AppContext {
|
||||
func nextAccount(in authContext: AuthContext) -> MastodonAuthentication? {
|
||||
func nextAccount(in authenticationBox: MastodonAuthenticationBox) -> MastodonAuthentication? {
|
||||
let accounts = AuthenticationServiceProvider.shared.authentications
|
||||
guard accounts.count > 1 else { return nil }
|
||||
|
||||
let nextSelectedAccountIndex: Int? = {
|
||||
for (index, account) in accounts.enumerated() {
|
||||
guard account == authContext.mastodonAuthenticationBox
|
||||
guard account == authenticationBox
|
||||
.authentication
|
||||
else { continue }
|
||||
|
||||
|
@ -18,7 +18,7 @@ extension DataSourceFacade {
|
||||
FeedbackGenerator.shared.generate(.selectionChanged)
|
||||
|
||||
let apiService = dependency.context.apiService
|
||||
let authBox = dependency.authContext.mastodonAuthenticationBox
|
||||
let authBox = dependency.authenticationBox
|
||||
|
||||
let response = try await apiService.toggleBlock(
|
||||
account: account,
|
||||
@ -41,7 +41,7 @@ extension DataSourceFacade {
|
||||
FeedbackGenerator.shared.generate(.selectionChanged)
|
||||
|
||||
let apiService = dependency.context.apiService
|
||||
let authBox = dependency.authContext.mastodonAuthenticationBox
|
||||
let authBox = dependency.authenticationBox
|
||||
|
||||
let response = try await apiService.toggleDomainBlock(account: account, authenticationBox: authBox)
|
||||
|
||||
|
@ -21,7 +21,7 @@ extension DataSourceFacade {
|
||||
|
||||
let updatedStatus = try await provider.context.apiService.bookmark(
|
||||
record: status,
|
||||
authenticationBox: provider.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: provider.authenticationBox
|
||||
).value
|
||||
|
||||
let newStatus: MastodonStatus = .fromEntity(updatedStatus)
|
||||
|
@ -20,7 +20,7 @@ extension DataSourceFacade {
|
||||
|
||||
let updatedStatus = try await provider.context.apiService.favorite(
|
||||
status: status,
|
||||
authenticationBox: provider.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: provider.authenticationBox
|
||||
).value
|
||||
|
||||
let newStatus: MastodonStatus = .fromEntity(updatedStatus)
|
||||
|
@ -17,7 +17,7 @@ extension DataSourceFacade {
|
||||
dependency: ViewControllerWithDependencies & AuthContextProvider,
|
||||
account: Mastodon.Entity.Account
|
||||
) async throws -> Mastodon.Entity.Relationship {
|
||||
let authBox = dependency.authContext.mastodonAuthenticationBox
|
||||
let authBox = dependency.authenticationBox
|
||||
let relationship = try await dependency.context.apiService.relationship(
|
||||
forAccounts: [account], authenticationBox: authBox
|
||||
).value.first
|
||||
@ -29,7 +29,7 @@ extension DataSourceFacade {
|
||||
|
||||
let response = try await dependency.context.apiService.toggleFollow(
|
||||
account: account,
|
||||
authenticationBox: dependency.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: dependency.authenticationBox
|
||||
).value
|
||||
|
||||
dependency.context.authenticationService.fetchFollowingAndBlockedAsync()
|
||||
@ -97,13 +97,13 @@ extension DataSourceFacade {
|
||||
notification.transientFollowRequestState = .init(state: .isRejecting)
|
||||
}
|
||||
|
||||
await notificationView.configure(notification: notification, authenticationBox: dependency.authContext.mastodonAuthenticationBox)
|
||||
await notificationView.configure(notification: notification, authenticationBox: dependency.authenticationBox)
|
||||
|
||||
do {
|
||||
let newRelationship = try await dependency.context.apiService.followRequest(
|
||||
userID: userID,
|
||||
query: query,
|
||||
authenticationBox: dependency.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: dependency.authenticationBox
|
||||
).value
|
||||
|
||||
switch query {
|
||||
@ -118,11 +118,11 @@ extension DataSourceFacade {
|
||||
UserInfoKey.relationship: newRelationship
|
||||
])
|
||||
|
||||
await notificationView.configure(notification: notification, authenticationBox: dependency.authContext.mastodonAuthenticationBox)
|
||||
await notificationView.configure(notification: notification, authenticationBox: dependency.authenticationBox)
|
||||
} catch {
|
||||
// reset state when failure
|
||||
notification.transientFollowRequestState = .init(state: .none)
|
||||
await notificationView.configure(notification: notification, authenticationBox: dependency.authContext.mastodonAuthenticationBox)
|
||||
await notificationView.configure(notification: notification, authenticationBox: dependency.authenticationBox)
|
||||
|
||||
if let error = error as? Mastodon.API.Error {
|
||||
switch error.httpResponseStatus {
|
||||
@ -151,7 +151,7 @@ extension DataSourceFacade {
|
||||
) async throws {
|
||||
let newRelationship = try await dependency.context.apiService.toggleShowReblogs(
|
||||
for: account,
|
||||
authenticationBox: dependency.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: dependency.authenticationBox
|
||||
)
|
||||
|
||||
let userInfo = [
|
||||
|
@ -18,7 +18,7 @@ extension DataSourceFacade {
|
||||
) async {
|
||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(
|
||||
context: provider.context,
|
||||
authContext: provider.authContext,
|
||||
authenticationBox: provider.authenticationBox,
|
||||
hashtag: tag.name
|
||||
)
|
||||
|
||||
|
@ -53,7 +53,7 @@ extension DataSourceFacade {
|
||||
url: url
|
||||
)
|
||||
case .hashtag(_, let hashtag, _):
|
||||
let hashtagTimelineViewModel = await HashtagTimelineViewModel(context: provider.context, authContext: provider.authContext, hashtag: hashtag)
|
||||
let hashtagTimelineViewModel = await HashtagTimelineViewModel(context: provider.context, authenticationBox: provider.authenticationBox, hashtag: hashtag)
|
||||
_ = await provider.coordinator.present(scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel), from: provider, transition: .show)
|
||||
case .mention(_, let mention, let userInfo):
|
||||
await coordinateToProfileScene(
|
||||
|
@ -17,7 +17,7 @@ extension DataSourceFacade {
|
||||
FeedbackGenerator.shared.generate(.selectionChanged)
|
||||
|
||||
let response = try await dependency.context.apiService.toggleMute(
|
||||
authenticationBox: dependency.authContext.mastodonAuthenticationBox,
|
||||
authenticationBox: dependency.authenticationBox,
|
||||
account: account
|
||||
)
|
||||
|
||||
|
@ -12,8 +12,8 @@ extension DataSourceFacade {
|
||||
provider.coordinator.showLoading()
|
||||
|
||||
do {
|
||||
let notificationRequests = try await provider.context.apiService.notificationRequests(authenticationBox: provider.authContext.mastodonAuthenticationBox).value
|
||||
let viewModel = NotificationRequestsViewModel(appContext: provider.context, authContext: provider.authContext, coordinator: provider.coordinator, requests: notificationRequests)
|
||||
let notificationRequests = try await provider.context.apiService.notificationRequests(authenticationBox: provider.authenticationBox).value
|
||||
let viewModel = NotificationRequestsViewModel(appContext: provider.context, authenticationBox: provider.authenticationBox, coordinator: provider.coordinator, requests: notificationRequests)
|
||||
|
||||
provider.coordinator.hideLoading()
|
||||
|
||||
@ -39,7 +39,7 @@ extension DataSourceFacade {
|
||||
) async -> AccountNotificationTimelineViewController? {
|
||||
provider.coordinator.showLoading()
|
||||
|
||||
let notificationTimelineViewModel = NotificationTimelineViewModel(context: provider.context, authContext: provider.authContext, scope: .fromAccount(request.account))
|
||||
let notificationTimelineViewModel = NotificationTimelineViewModel(context: provider.context, authenticationBox: provider.authenticationBox, scope: .fromAccount(request.account))
|
||||
|
||||
provider.coordinator.hideLoading()
|
||||
|
||||
|
@ -30,9 +30,9 @@ extension DataSourceFacade {
|
||||
|
||||
let _redirectRecord = try? await Mastodon.API.Account.lookupAccount(
|
||||
session: .shared,
|
||||
domain: provider.authContext.mastodonAuthenticationBox.domain,
|
||||
domain: provider.authenticationBox.domain,
|
||||
query: .init(acct: acct),
|
||||
authorization: provider.authContext.mastodonAuthenticationBox.userAuthorization
|
||||
authorization: provider.authenticationBox.userAuthorization
|
||||
).singleOutput().value
|
||||
|
||||
provider.coordinator.hideLoading()
|
||||
@ -60,7 +60,7 @@ extension DataSourceFacade {
|
||||
guard let account = try await provider.context.apiService.fetchUser(
|
||||
username: username,
|
||||
domain: domain,
|
||||
authenticationBox: provider.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: provider.authenticationBox
|
||||
) else {
|
||||
return provider.coordinator.hideLoading()
|
||||
}
|
||||
@ -85,7 +85,7 @@ extension DataSourceFacade {
|
||||
let account = try await provider.context.apiService.accountInfo(
|
||||
domain: domain,
|
||||
userID: accountID,
|
||||
authorization: provider.authContext.mastodonAuthenticationBox.userAuthorization
|
||||
authorization: provider.authenticationBox.userAuthorization
|
||||
).value
|
||||
|
||||
provider.coordinator.hideLoading()
|
||||
@ -103,8 +103,8 @@ extension DataSourceFacade {
|
||||
) async {
|
||||
provider.coordinator.showLoading()
|
||||
|
||||
guard let me = provider.authContext.mastodonAuthenticationBox.authentication.account(),
|
||||
let relationship = try? await provider.context.apiService.relationship(forAccounts: [account], authenticationBox: provider.authContext.mastodonAuthenticationBox).value.first else {
|
||||
guard let me = provider.authenticationBox.authentication.account(),
|
||||
let relationship = try? await provider.context.apiService.relationship(forAccounts: [account], authenticationBox: provider.authenticationBox).value.first else {
|
||||
return provider.coordinator.hideLoading()
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ extension DataSourceFacade {
|
||||
|
||||
let profileViewModel = ProfileViewModel(
|
||||
context: provider.context,
|
||||
authContext: provider.authContext,
|
||||
authenticationBox: provider.authenticationBox,
|
||||
account: account,
|
||||
relationship: relationship,
|
||||
me: me
|
||||
@ -135,7 +135,7 @@ extension DataSourceFacade {
|
||||
mention: String, // username,
|
||||
userInfo: [AnyHashable: Any]?
|
||||
) async {
|
||||
let domain = provider.authContext.mastodonAuthenticationBox.domain
|
||||
let domain = provider.authenticationBox.domain
|
||||
|
||||
guard
|
||||
let href = userInfo?["href"] as? String,
|
||||
|
@ -51,7 +51,7 @@ private extension DataSourceFacade {
|
||||
|
||||
let updatedStatus = try await provider.context.apiService.reblog(
|
||||
status: status,
|
||||
authenticationBox: provider.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: provider.authenticationBox
|
||||
).value
|
||||
|
||||
let newStatus: MastodonStatus = .fromEntity(updatedStatus)
|
||||
|
@ -19,7 +19,7 @@ extension DataSourceFacade {
|
||||
switch item {
|
||||
case .account(account: let account, relationship: _):
|
||||
let now = Date()
|
||||
let userID = provider.authContext.mastodonAuthenticationBox.userID
|
||||
let userID = provider.authenticationBox.userID
|
||||
let searchEntry = Persistence.SearchHistory.Item(
|
||||
updatedAt: now,
|
||||
userID: userID,
|
||||
@ -27,11 +27,11 @@ extension DataSourceFacade {
|
||||
hashtag: nil
|
||||
)
|
||||
|
||||
try? FileManager.default.addSearchItem(searchEntry, for: provider.authContext.mastodonAuthenticationBox)
|
||||
try? FileManager.default.addSearchItem(searchEntry, for: provider.authenticationBox)
|
||||
case .hashtag(let tag):
|
||||
|
||||
let now = Date()
|
||||
let userID = provider.authContext.mastodonAuthenticationBox.userID
|
||||
let userID = provider.authenticationBox.userID
|
||||
let searchEntry = Persistence.SearchHistory.Item(
|
||||
updatedAt: now,
|
||||
userID: userID,
|
||||
@ -39,7 +39,7 @@ extension DataSourceFacade {
|
||||
hashtag: tag
|
||||
)
|
||||
|
||||
try? FileManager.default.addSearchItem(searchEntry, for: provider.authContext.mastodonAuthenticationBox)
|
||||
try? FileManager.default.addSearchItem(searchEntry, for: provider.authenticationBox)
|
||||
case .status, .notification, .notificationBanner(_):
|
||||
break
|
||||
|
||||
|
@ -10,7 +10,7 @@ extension DataSourceFacade {
|
||||
forStatus status: Status,
|
||||
provider: NeedsDependency & AuthContextProvider
|
||||
) async throws -> [Mastodon.Entity.StatusEdit] {
|
||||
let reponse = try await provider.context.apiService.getHistory(forStatusID: status.id, authenticationBox: provider.authContext.mastodonAuthenticationBox)
|
||||
let reponse = try await provider.context.apiService.getHistory(forStatusID: status.id, authenticationBox: provider.authenticationBox)
|
||||
|
||||
return reponse.value
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ extension DataSourceFacade {
|
||||
) async throws {
|
||||
let deletedStatus = try await dependency.context.apiService.deleteStatus(
|
||||
status: status,
|
||||
authenticationBox: dependency.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: dependency.authenticationBox
|
||||
).value.asMastodonStatus
|
||||
|
||||
dependency.update(status: deletedStatus, intent: .delete)
|
||||
@ -102,7 +102,7 @@ extension DataSourceFacade {
|
||||
|
||||
let composeViewModel = ComposeViewModel(
|
||||
context: provider.context,
|
||||
authContext: provider.authContext,
|
||||
authenticationBox: provider.authenticationBox,
|
||||
composeContext: .composeStatus,
|
||||
destination: .reply(parent: _status)
|
||||
)
|
||||
@ -234,11 +234,11 @@ extension DataSourceFacade {
|
||||
alertController.addAction(cancelAction)
|
||||
dependency.present(alertController, animated: true)
|
||||
case .reportUser:
|
||||
guard let relationship = try? await dependency.context.apiService.relationship(forAccounts: [menuContext.author], authenticationBox: dependency.authContext.mastodonAuthenticationBox).value.first else { return }
|
||||
guard let relationship = try? await dependency.context.apiService.relationship(forAccounts: [menuContext.author], authenticationBox: dependency.authenticationBox).value.first else { return }
|
||||
|
||||
let reportViewModel = ReportViewModel(
|
||||
context: dependency.context,
|
||||
authContext: dependency.authContext,
|
||||
authenticationBox: dependency.authenticationBox,
|
||||
account: menuContext.author,
|
||||
relationship: relationship,
|
||||
status: menuContext.statusViewModel?.originalStatus
|
||||
@ -335,12 +335,12 @@ extension DataSourceFacade {
|
||||
|
||||
let statusSource = try await dependency.context.apiService.getStatusSource(
|
||||
forStatusID: status.id,
|
||||
authenticationBox: dependency.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: dependency.authenticationBox
|
||||
).value
|
||||
|
||||
let editStatusViewModel = ComposeViewModel(
|
||||
context: dependency.coordinator.appContext,
|
||||
authContext: dependency.authContext,
|
||||
authenticationBox: dependency.authenticationBox,
|
||||
composeContext: .editStatus(status: status, statusSource: statusSource),
|
||||
destination: .topLevel)
|
||||
_ = dependency.coordinator.present(scene: .editStatus(viewModel: editStatusViewModel), transition: .modal(animated: true))
|
||||
|
@ -44,7 +44,7 @@ extension DataSourceFacade {
|
||||
) async {
|
||||
let threadViewModel = ThreadViewModel(
|
||||
context: provider.context,
|
||||
authContext: provider.authContext,
|
||||
authenticationBox: provider.authenticationBox,
|
||||
optionalRoot: root
|
||||
)
|
||||
_ = provider.coordinator.present(
|
||||
|
@ -29,7 +29,7 @@ extension DataSourceFacade {
|
||||
.apiService
|
||||
.translateStatus(
|
||||
statusID: status.id,
|
||||
authenticationBox: provider.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: provider.authenticationBox
|
||||
).value
|
||||
|
||||
if let content = value.content, content.isNotEmpty {
|
||||
|
@ -16,14 +16,14 @@ extension DataSourceFacade {
|
||||
provider: DataSourceProvider & AuthContextProvider,
|
||||
url: URL
|
||||
) async {
|
||||
let domain = provider.authContext.mastodonAuthenticationBox.domain
|
||||
let domain = provider.authenticationBox.domain
|
||||
if url.host == domain,
|
||||
url.pathComponents.count >= 4,
|
||||
url.pathComponents[0] == "/",
|
||||
url.pathComponents[1] == "web",
|
||||
url.pathComponents[2] == "statuses" {
|
||||
let statusID = url.pathComponents[3]
|
||||
let threadViewModel = RemoteThreadViewModel(context: provider.context, authContext: provider.authContext, statusID: statusID)
|
||||
let threadViewModel = RemoteThreadViewModel(context: provider.context, authenticationBox: provider.authenticationBox, statusID: statusID)
|
||||
_ = await provider.coordinator.present(scene: .thread(viewModel: threadViewModel), from: nil, transition: .show)
|
||||
} else {
|
||||
_ = await provider.coordinator.present(scene: .safari(url: url), from: nil, transition: .safariPresent(animated: true, completion: nil))
|
||||
|
@ -46,7 +46,7 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
|
||||
completion: { (newRelationship: Mastodon.Entity.Relationship) in
|
||||
notification.relationship = newRelationship
|
||||
Task { @MainActor in
|
||||
notificationView.configure(notification: notification, authenticationBox: self.authContext.mastodonAuthenticationBox)
|
||||
notificationView.configure(notification: notification, authenticationBox: self.authenticationBox)
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -571,7 +571,7 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
|
||||
let newPoll = try await context.apiService.vote(
|
||||
poll: poll.entity,
|
||||
choices: choices,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
|
||||
guard let entity = poll.status?.entity else { return }
|
||||
|
@ -203,7 +203,7 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte
|
||||
self.coordinator.present(
|
||||
scene: .compose(viewModel: ComposeViewModel(
|
||||
context: self.context,
|
||||
authContext: self.authContext,
|
||||
authenticationBox: self.authenticationBox,
|
||||
composeContext: .composeStatus,
|
||||
destination: .topLevel,
|
||||
initialContent: L10n.Common.Controls.Status.linkViaUser(url.absoluteString, "@" + (statusView.viewModel.authorUsername ?? ""))
|
||||
@ -313,7 +313,7 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte
|
||||
let newPoll = try await context.apiService.vote(
|
||||
poll: poll.entity,
|
||||
choices: choices,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
|
||||
guard let entity = poll.status?.entity else { return }
|
||||
@ -536,7 +536,7 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte
|
||||
}
|
||||
let userListViewModel = UserListViewModel(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
kind: .rebloggedBy(status: status)
|
||||
)
|
||||
_ = await coordinator.present(
|
||||
@ -560,7 +560,7 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte
|
||||
}
|
||||
let userListViewModel = UserListViewModel(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
kind: .favoritedBy(status: status)
|
||||
)
|
||||
_ = await coordinator.present(
|
||||
@ -584,11 +584,11 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte
|
||||
}
|
||||
|
||||
do {
|
||||
let edits = try await context.apiService.getHistory(forStatusID: status.id, authenticationBox: authContext.mastodonAuthenticationBox).value
|
||||
let edits = try await context.apiService.getHistory(forStatusID: status.id, authenticationBox: authenticationBox).value
|
||||
|
||||
await coordinator.hideLoading()
|
||||
|
||||
let viewModel = StatusEditHistoryViewModel(status: status, edits: edits, appContext: context, authContext: authContext)
|
||||
let viewModel = StatusEditHistoryViewModel(status: status, edits: edits, appContext: context, authenticationBox: authenticationBox)
|
||||
_ = await coordinator.present(scene: .editHistory(viewModel: viewModel), from: self, transition: .show)
|
||||
} catch {
|
||||
await coordinator.hideLoading()
|
||||
|
@ -89,7 +89,7 @@ extension StatusTableViewControllerNavigateableCore where Self: DataSourceProvid
|
||||
|
||||
let composeViewModel = ComposeViewModel(
|
||||
context: self.context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
composeContext: .composeStatus,
|
||||
destination: .reply(parent: status)
|
||||
)
|
||||
|
@ -44,7 +44,7 @@ extension UITableViewDelegate where Self: DataSourceProvider & AuthContextProvid
|
||||
status: status
|
||||
)
|
||||
} else if let accountWarning = notification.entity.accountWarning {
|
||||
let url = Mastodon.API.disputesEndpoint(domain: authContext.mastodonAuthenticationBox.domain, strikeId: accountWarning.id)
|
||||
let url = Mastodon.API.disputesEndpoint(domain: authenticationBox.domain, strikeId: accountWarning.id)
|
||||
_ = coordinator.present(
|
||||
scene: .safari(url: url),
|
||||
from: self,
|
||||
|
@ -20,16 +20,16 @@ final class AccountListViewModel: NSObject {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
// output
|
||||
@Published var items: [Item] = []
|
||||
|
||||
var diffableDataSource: UITableViewDiffableDataSource<Section, Item>!
|
||||
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
|
||||
super.init()
|
||||
// end init
|
||||
|
@ -49,7 +49,7 @@ final class ComposeViewController: UIViewController, NeedsDependency {
|
||||
|
||||
return ComposeContentViewModel(
|
||||
context: context,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
composeContext: composeContext,
|
||||
destination: viewModel.destination,
|
||||
initialContent: initialContent
|
||||
@ -247,7 +247,7 @@ extension ComposeViewController {
|
||||
let statusPublisher = try composeContentViewModel.statusPublisher()
|
||||
viewModel.context.publisherService.enqueue(
|
||||
statusPublisher: statusPublisher,
|
||||
authContext: viewModel.authContext
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
} catch {
|
||||
let alertController = UIAlertController.standardAlert(of: error)
|
||||
@ -296,7 +296,7 @@ extension ComposeViewController {
|
||||
guard let editStatusPublisher = try composeContentViewModel.statusEditPublisher() else { return }
|
||||
viewModel.context.publisherService.enqueue(
|
||||
statusPublisher: editStatusPublisher,
|
||||
authContext: viewModel.authContext
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
} catch {
|
||||
let alertController = UIAlertController.standardAlert(of: error)
|
||||
@ -326,7 +326,7 @@ extension ComposeViewController {
|
||||
let attachmentViewModels = images.map { image in
|
||||
return AttachmentViewModel(
|
||||
api: viewModel.context.apiService,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
input: .image(image),
|
||||
sizeLimit: composeContentViewModel.sizeLimit,
|
||||
delegate: composeContentViewModel
|
||||
|
@ -30,7 +30,7 @@ final class ComposeViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let composeContext: Context
|
||||
let destination: ComposeContentViewModel.Destination
|
||||
let initialContent: String
|
||||
@ -44,13 +44,13 @@ final class ComposeViewModel {
|
||||
|
||||
init(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
composeContext: ComposeViewModel.Context,
|
||||
destination: ComposeContentViewModel.Destination,
|
||||
initialContent: String = ""
|
||||
) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.destination = destination
|
||||
self.initialContent = initialContent
|
||||
self.composeContext = composeContext
|
||||
|
@ -20,16 +20,16 @@ enum DiscoverySection: CaseIterable {
|
||||
extension DiscoverySection {
|
||||
|
||||
class Configuration {
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
weak var profileCardTableViewCellDelegate: ProfileCardTableViewCellDelegate?
|
||||
let familiarFollowers: Published<[Mastodon.Entity.FamiliarFollowers]>.Publisher?
|
||||
|
||||
public init(
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
profileCardTableViewCellDelegate: ProfileCardTableViewCellDelegate? = nil,
|
||||
familiarFollowers: Published<[Mastodon.Entity.FamiliarFollowers]>.Publisher? = nil
|
||||
) {
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.profileCardTableViewCellDelegate = profileCardTableViewCellDelegate
|
||||
self.familiarFollowers = familiarFollowers
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ final class DiscoveryViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let discoveryPostsViewController: DiscoveryPostsViewController
|
||||
let discoveryHashtagsViewController: DiscoveryHashtagsViewController
|
||||
let discoveryNewsViewController: DiscoveryNewsViewController
|
||||
@ -26,9 +26,9 @@ final class DiscoveryViewModel {
|
||||
@Published var viewControllers: [ScrollViewContainer]
|
||||
|
||||
@MainActor
|
||||
init(context: AppContext, coordinator: SceneCoordinator, authContext: AuthContext) {
|
||||
init(context: AppContext, coordinator: SceneCoordinator, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
|
||||
func setupDependency(_ needsDependency: NeedsDependency) {
|
||||
needsDependency.context = context
|
||||
@ -38,25 +38,25 @@ final class DiscoveryViewModel {
|
||||
discoveryPostsViewController = {
|
||||
let viewController = DiscoveryPostsViewController()
|
||||
setupDependency(viewController)
|
||||
viewController.viewModel = DiscoveryPostsViewModel(context: context, authContext: authContext)
|
||||
viewController.viewModel = DiscoveryPostsViewModel(context: context, authenticationBox: authenticationBox)
|
||||
return viewController
|
||||
}()
|
||||
discoveryHashtagsViewController = {
|
||||
let viewController = DiscoveryHashtagsViewController()
|
||||
setupDependency(viewController)
|
||||
viewController.viewModel = DiscoveryHashtagsViewModel(context: context, authContext: authContext)
|
||||
viewController.viewModel = DiscoveryHashtagsViewModel(context: context, authenticationBox: authenticationBox)
|
||||
return viewController
|
||||
}()
|
||||
discoveryNewsViewController = {
|
||||
let viewController = DiscoveryNewsViewController()
|
||||
setupDependency(viewController)
|
||||
viewController.viewModel = DiscoveryNewsViewModel(context: context, authContext: authContext)
|
||||
viewController.viewModel = DiscoveryNewsViewModel(context: context, authenticationBox: authenticationBox)
|
||||
return viewController
|
||||
}()
|
||||
discoveryForYouViewController = {
|
||||
let viewController = DiscoveryForYouViewController()
|
||||
setupDependency(viewController)
|
||||
viewController.viewModel = DiscoveryForYouViewModel(context: context, authContext: authContext)
|
||||
viewController.viewModel = DiscoveryForYouViewModel(context: context, authenticationBox: authenticationBox)
|
||||
return viewController
|
||||
}()
|
||||
self.viewControllers = [
|
||||
|
@ -90,7 +90,7 @@ extension DiscoveryForYouViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension DiscoveryForYouViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
@ -121,7 +121,7 @@ extension DiscoveryForYouViewController: ProfileCardTableViewCellDelegate {
|
||||
Task {
|
||||
let newRelationship = try await DataSourceFacade.responseToUserFollowAction(dependency: self, account: account)
|
||||
|
||||
let isMe = (account.id == authContext.mastodonAuthenticationBox.userID)
|
||||
let isMe = (account.id == authenticationBox.userID)
|
||||
|
||||
await MainActor.run {
|
||||
cell.profileCardView.updateButtonState(with: newRelationship, isMe: isMe)
|
||||
@ -145,13 +145,13 @@ extension DiscoveryForYouViewController: ProfileCardTableViewCellDelegate {
|
||||
do {
|
||||
let userID = account.id
|
||||
let familiarFollowers = viewModel.familiarFollowers.first(where: { $0.id == userID })?.accounts ?? []
|
||||
let relationships = try await context.apiService.relationship(forAccounts: familiarFollowers, authenticationBox: authContext.mastodonAuthenticationBox).value
|
||||
let relationships = try await context.apiService.relationship(forAccounts: familiarFollowers, authenticationBox: authenticationBox).value
|
||||
|
||||
coordinator.hideLoading()
|
||||
|
||||
let familiarFollowersViewModel = FamiliarFollowersViewModel(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
accounts: familiarFollowers,
|
||||
relationships: relationships
|
||||
)
|
||||
|
@ -19,7 +19,7 @@ extension DiscoveryForYouViewModel {
|
||||
tableView: tableView,
|
||||
context: context,
|
||||
configuration: DiscoverySection.Configuration(
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
profileCardTableViewCellDelegate: profileCardTableViewCellDelegate,
|
||||
familiarFollowers: $familiarFollowers
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ final class DiscoveryForYouViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
@MainActor
|
||||
@Published var familiarFollowers: [Mastodon.Entity.FamiliarFollowers] = []
|
||||
@ -29,9 +29,9 @@ final class DiscoveryForYouViewModel {
|
||||
var diffableDataSource: UITableViewDiffableDataSource<DiscoverySection, DiscoveryItem>?
|
||||
let didLoadLatest = PassthroughSubject<Void, Never>()
|
||||
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.accounts = []
|
||||
self.relationships = []
|
||||
}
|
||||
@ -50,12 +50,12 @@ extension DiscoveryForYouViewModel {
|
||||
|
||||
let familiarFollowersResponse = try? await context.apiService.familiarFollowers(
|
||||
query: .init(ids: suggestedAccounts.compactMap { $0.id }),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
|
||||
let relationships = try? await context.apiService.relationship(
|
||||
forAccounts: suggestedAccounts,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
|
||||
familiarFollowers = familiarFollowersResponse ?? []
|
||||
@ -87,14 +87,14 @@ extension DiscoveryForYouViewModel {
|
||||
do {
|
||||
let response = try await context.apiService.suggestionAccountV2(
|
||||
query: nil,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
return response.compactMap { $0.account }
|
||||
} catch {
|
||||
// fallback V1
|
||||
let response = try await context.apiService.suggestionAccount(
|
||||
query: nil,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
|
||||
return response
|
||||
|
@ -88,7 +88,7 @@ extension DiscoveryHashtagsViewController: UITableViewDelegate {
|
||||
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
guard case let .hashtag(tag) = viewModel.diffableDataSource?.itemIdentifier(for: indexPath) else { return }
|
||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: context, authContext: viewModel.authContext, hashtag: tag.name)
|
||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: context, authenticationBox: viewModel.authenticationBox, hashtag: tag.name)
|
||||
_ = coordinator.present(
|
||||
scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel),
|
||||
from: self,
|
||||
@ -198,7 +198,7 @@ extension DiscoveryHashtagsViewController: TableViewControllerNavigateable {
|
||||
guard let item = diffableDataSource.itemIdentifier(for: indexPathForSelectedRow) else { return }
|
||||
|
||||
guard case let .hashtag(tag) = item else { return }
|
||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: context, authContext: viewModel.authContext, hashtag: tag.name)
|
||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: context, authenticationBox: viewModel.authenticationBox, hashtag: tag.name)
|
||||
_ = coordinator.present(
|
||||
scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel),
|
||||
from: self,
|
||||
|
@ -15,7 +15,7 @@ extension DiscoveryHashtagsViewModel {
|
||||
diffableDataSource = DiscoverySection.diffableDataSource(
|
||||
tableView: tableView,
|
||||
context: context,
|
||||
configuration: DiscoverySection.Configuration(authContext: authContext)
|
||||
configuration: DiscoverySection.Configuration(authenticationBox: authenticationBox)
|
||||
)
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<DiscoverySection, DiscoveryItem>()
|
||||
|
@ -19,22 +19,22 @@ final class DiscoveryHashtagsViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let viewDidAppeared = PassthroughSubject<Void, Never>()
|
||||
|
||||
// output
|
||||
var diffableDataSource: UITableViewDiffableDataSource<DiscoverySection, DiscoveryItem>?
|
||||
@Published var hashtags: [Mastodon.Entity.Tag] = []
|
||||
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
// end init
|
||||
|
||||
viewDidAppeared
|
||||
.throttle(for: 3, scheduler: DispatchQueue.main, latest: true)
|
||||
.asyncMap { _ in
|
||||
let authenticationBox = authContext.mastodonAuthenticationBox
|
||||
let authenticationBox = authenticationBox
|
||||
return try await context.apiService.trendHashtags(domain: authenticationBox.domain,
|
||||
query: nil,
|
||||
authenticationBox: authenticationBox
|
||||
@ -62,7 +62,7 @@ extension DiscoveryHashtagsViewModel {
|
||||
@MainActor
|
||||
func fetch() async throws {
|
||||
|
||||
let authenticationBox = authContext.mastodonAuthenticationBox
|
||||
let authenticationBox = authenticationBox
|
||||
let response = try await context.apiService.trendHashtags(domain: authenticationBox.domain,
|
||||
query: nil,
|
||||
authenticationBox: authenticationBox
|
||||
|
@ -16,7 +16,7 @@ extension DiscoveryNewsViewModel {
|
||||
diffableDataSource = DiscoverySection.diffableDataSource(
|
||||
tableView: tableView,
|
||||
context: context,
|
||||
configuration: DiscoverySection.Configuration(authContext: authContext)
|
||||
configuration: DiscoverySection.Configuration(authenticationBox: authenticationBox)
|
||||
)
|
||||
|
||||
stateMachine.enter(State.Reloading.self)
|
||||
|
@ -124,12 +124,12 @@ extension DiscoveryNewsViewModel.State {
|
||||
Task {
|
||||
do {
|
||||
let response = try await viewModel.context.apiService.trendLinks(
|
||||
domain: viewModel.authContext.mastodonAuthenticationBox.domain,
|
||||
domain: viewModel.authenticationBox.domain,
|
||||
query: Mastodon.API.Trends.StatusQuery(
|
||||
offset: offset,
|
||||
limit: nil
|
||||
),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
let newOffset: Int? = {
|
||||
guard let offset = response.link?.offset else { return nil }
|
||||
|
@ -19,7 +19,7 @@ final class DiscoveryNewsViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
// output
|
||||
@Published var links: [Mastodon.Entity.Link] = []
|
||||
@ -40,9 +40,9 @@ final class DiscoveryNewsViewModel {
|
||||
let didLoadLatest = PassthroughSubject<Void, Never>()
|
||||
@Published var isServerSupportEndpoint = true
|
||||
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
// end init
|
||||
|
||||
Task {
|
||||
@ -56,9 +56,9 @@ extension DiscoveryNewsViewModel {
|
||||
func checkServerEndpoint() async {
|
||||
do {
|
||||
_ = try await context.apiService.trendLinks(
|
||||
domain: authContext.mastodonAuthenticationBox.domain,
|
||||
domain: authenticationBox.domain,
|
||||
query: .init(offset: nil, limit: nil),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
} catch let error as Mastodon.API.Error where error.httpResponseStatus.code == 404 {
|
||||
isServerSupportEndpoint = false
|
||||
|
@ -98,7 +98,7 @@ extension DiscoveryPostsViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension DiscoveryPostsViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
@ -19,7 +19,7 @@ extension DiscoveryPostsViewModel {
|
||||
context: context,
|
||||
configuration: StatusSection.Configuration(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
statusTableViewCellDelegate: statusTableViewCellDelegate,
|
||||
timelineMiddleLoaderTableViewCellDelegate: nil,
|
||||
filterContext: .none,
|
||||
|
@ -123,12 +123,12 @@ extension DiscoveryPostsViewModel.State {
|
||||
Task {
|
||||
do {
|
||||
let response = try await viewModel.context.apiService.trendStatuses(
|
||||
domain: viewModel.authContext.mastodonAuthenticationBox.domain,
|
||||
domain: viewModel.authenticationBox.domain,
|
||||
query: Mastodon.API.Trends.StatusQuery(
|
||||
offset: offset,
|
||||
limit: nil
|
||||
),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
let newOffset: Int? = {
|
||||
guard let offset = response.link?.offset else { return nil }
|
||||
|
@ -19,7 +19,7 @@ final class DiscoveryPostsViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let dataController: StatusDataController
|
||||
|
||||
// output
|
||||
@ -41,9 +41,9 @@ final class DiscoveryPostsViewModel {
|
||||
@Published var isServerSupportEndpoint = true
|
||||
|
||||
@MainActor
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.dataController = StatusDataController()
|
||||
|
||||
Task {
|
||||
@ -56,9 +56,9 @@ extension DiscoveryPostsViewModel {
|
||||
func checkServerEndpoint() async {
|
||||
do {
|
||||
_ = try await context.apiService.trendStatuses(
|
||||
domain: authContext.mastodonAuthenticationBox.domain,
|
||||
domain: authenticationBox.domain,
|
||||
query: .init(offset: nil, limit: nil),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
} catch let error as Mastodon.API.Error where error.httpResponseStatus.code == 404 {
|
||||
isServerSupportEndpoint = false
|
||||
|
@ -11,17 +11,17 @@ class NewDonationNavigationFlow: NavigationFlow {
|
||||
|
||||
private let campaign: DonationCampaignViewModel
|
||||
private let appContext: AppContext
|
||||
private let authContext: AuthContext
|
||||
private let authenticationBox: MastodonAuthenticationBox
|
||||
private let sceneCoordinator: SceneCoordinator
|
||||
|
||||
init(
|
||||
flowPresenter: NavigationFlowPresenter,
|
||||
campaign: DonationCampaignViewModel, appContext: AppContext,
|
||||
authContext: AuthContext, sceneCoordinator: SceneCoordinator
|
||||
authenticationBox: MastodonAuthenticationBox, sceneCoordinator: SceneCoordinator
|
||||
) {
|
||||
self.campaign = campaign
|
||||
self.appContext = appContext
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.sceneCoordinator = sceneCoordinator
|
||||
super.init(flowPresenter: flowPresenter)
|
||||
}
|
||||
@ -107,7 +107,7 @@ class NewDonationNavigationFlow: NavigationFlow {
|
||||
private func composeDonationSuccessPost(_ suggestedText: String) {
|
||||
let composeViewModel = ComposeViewModel(
|
||||
context: appContext,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
composeContext: .composeStatus,
|
||||
destination: .topLevel,
|
||||
initialContent: suggestedText
|
||||
|
@ -185,7 +185,7 @@ extension HashtagTimelineViewController {
|
||||
UITextChecker.learnWord(hashtag)
|
||||
let composeViewModel = ComposeViewModel(
|
||||
context: context,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
composeContext: .composeStatus,
|
||||
destination: .topLevel,
|
||||
initialContent: hashtag
|
||||
@ -197,7 +197,7 @@ extension HashtagTimelineViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension HashtagTimelineViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
@ -20,7 +20,7 @@ extension HashtagTimelineViewModel {
|
||||
context: context,
|
||||
configuration: StatusSection.Configuration(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
statusTableViewCellDelegate: statusTableViewCellDelegate,
|
||||
timelineMiddleLoaderTableViewCellDelegate: nil,
|
||||
filterContext: .none,
|
||||
|
@ -129,7 +129,7 @@ extension HashtagTimelineViewModel.State {
|
||||
let response = try await viewModel.context.apiService.hashtagTimeline(
|
||||
maxID: maxID,
|
||||
hashtag: viewModel.hashtag,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
|
||||
let newMaxID: String? = {
|
||||
|
@ -23,7 +23,7 @@ final class HashtagTimelineViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let dataController: StatusDataController
|
||||
let isFetchingLatestTimeline = CurrentValueSubject<Bool, Never>(false)
|
||||
let timelinePredicate = CurrentValueSubject<NSPredicate?, Never>(nil)
|
||||
@ -50,9 +50,9 @@ final class HashtagTimelineViewModel {
|
||||
}()
|
||||
|
||||
@MainActor
|
||||
init(context: AppContext, authContext: AuthContext, hashtag: String) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox, hashtag: String) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.hashtag = hashtag
|
||||
self.dataController = StatusDataController()
|
||||
updateTagInformation()
|
||||
@ -70,7 +70,7 @@ extension HashtagTimelineViewModel {
|
||||
Task { @MainActor in
|
||||
let tag = try? await context.apiService.followTag(
|
||||
for: hashtag,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
self.hashtagDetails.send(tag)
|
||||
}
|
||||
@ -81,7 +81,7 @@ extension HashtagTimelineViewModel {
|
||||
Task { @MainActor in
|
||||
let tag = try? await context.apiService.unfollowTag(
|
||||
for: hashtag,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
self.hashtagDetails.send(tag)
|
||||
}
|
||||
@ -93,7 +93,7 @@ private extension HashtagTimelineViewModel {
|
||||
Task { @MainActor in
|
||||
let tag = try? await context.apiService.getTagInformation(
|
||||
for: hashtag,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
|
||||
self.hashtagDetails.send(tag)
|
||||
|
@ -166,8 +166,8 @@ final class HomeTimelineViewController: UIViewController, NeedsDependency, Media
|
||||
Task { @MainActor in
|
||||
let lists = (try? await Mastodon.API.Lists.getLists(
|
||||
session: .shared,
|
||||
domain: self.authContext.mastodonAuthenticationBox.domain,
|
||||
authorization: self.authContext.mastodonAuthenticationBox.userAuthorization
|
||||
domain: self.authenticationBox.domain,
|
||||
authorization: self.authenticationBox.userAuthorization
|
||||
).singleOutput().value) ?? []
|
||||
|
||||
var listEntries = lists.map { entry in
|
||||
@ -207,9 +207,9 @@ final class HomeTimelineViewController: UIViewController, NeedsDependency, Media
|
||||
Task { @MainActor in
|
||||
let lists = (try? await Mastodon.API.Account.followedTags(
|
||||
session: .shared,
|
||||
domain: self.authContext.mastodonAuthenticationBox.domain,
|
||||
domain: self.authenticationBox.domain,
|
||||
query: .init(limit: nil),
|
||||
authorization: self.authContext.mastodonAuthenticationBox.userAuthorization
|
||||
authorization: self.authenticationBox.userAuthorization
|
||||
).singleOutput().value) ?? []
|
||||
|
||||
var listEntries = lists.map { entry in
|
||||
@ -354,8 +354,8 @@ extension HomeTimelineViewController {
|
||||
self?.showEmptyView(state)
|
||||
|
||||
let userDoesntFollowPeople: Bool
|
||||
if let authContext = self?.authContext,
|
||||
let me = authContext.mastodonAuthenticationBox.authentication.account() {
|
||||
if let authenticationBox = self?.authenticationBox,
|
||||
let me = authenticationBox.authentication.account() {
|
||||
userDoesntFollowPeople = me.followersCount == 0
|
||||
} else {
|
||||
userDoesntFollowPeople = true
|
||||
@ -606,9 +606,9 @@ extension HomeTimelineViewController {
|
||||
extension HomeTimelineViewController {
|
||||
|
||||
@objc private func findPeopleButtonPressed(_ sender: Any?) {
|
||||
guard let authContext = viewModel?.authContext else { return }
|
||||
guard let authenticationBox = viewModel?.authenticationBox else { return }
|
||||
|
||||
let suggestionAccountViewModel = SuggestionAccountViewModel(context: context, authContext: authContext)
|
||||
let suggestionAccountViewModel = SuggestionAccountViewModel(context: context, authenticationBox: authenticationBox)
|
||||
suggestionAccountViewModel.delegate = viewModel
|
||||
_ = coordinator.present(
|
||||
scene: .suggestionAccount(viewModel: suggestionAccountViewModel),
|
||||
@ -618,9 +618,9 @@ extension HomeTimelineViewController {
|
||||
}
|
||||
|
||||
@objc private func manuallySearchButtonPressed(_ sender: UIButton) {
|
||||
guard let authContext = viewModel?.authContext else { return }
|
||||
guard let authenticationBox = viewModel?.authenticationBox else { return }
|
||||
|
||||
let searchDetailViewModel = SearchDetailViewModel(authContext: authContext)
|
||||
let searchDetailViewModel = SearchDetailViewModel(authenticationBox: authenticationBox)
|
||||
_ = coordinator.present(scene: .searchDetail(viewModel: searchDetailViewModel), from: self, transition: .modal(animated: true, completion: nil))
|
||||
}
|
||||
|
||||
@ -638,11 +638,11 @@ extension HomeTimelineViewController {
|
||||
}
|
||||
|
||||
@objc func signOutAction(_ sender: UIAction) {
|
||||
guard let authContext = viewModel?.authContext else { return }
|
||||
guard let authContext = viewModel?.authenticationBox else { return }
|
||||
|
||||
Task { @MainActor in
|
||||
try await context.authenticationService.signOutMastodonUser(authenticationBox: authContext.mastodonAuthenticationBox)
|
||||
let userIdentifier = authContext.mastodonAuthenticationBox
|
||||
try await context.authenticationService.signOutMastodonUser(authenticationBox: authenticationBox)
|
||||
let userIdentifier = authenticationBox
|
||||
FileManager.default.invalidateHomeTimelineCache(for: userIdentifier)
|
||||
FileManager.default.invalidateNotificationsAll(for: userIdentifier)
|
||||
FileManager.default.invalidateNotificationsMentions(for: userIdentifier)
|
||||
@ -737,7 +737,7 @@ extension HomeTimelineViewController {
|
||||
|
||||
private func showDonationCampaign(_ campaign: Mastodon.Entity.DonationCampaign) {
|
||||
hideDonationCampaignBanner()
|
||||
navigationFlow = NewDonationNavigationFlow(flowPresenter: self, campaign: campaign, appContext: context, authContext: authContext, sceneCoordinator: coordinator)
|
||||
navigationFlow = NewDonationNavigationFlow(flowPresenter: self, campaign: campaign, appContext: context, authenticationBox: authenticationBox, sceneCoordinator: coordinator)
|
||||
navigationFlow?.presentFlow { [weak self] in
|
||||
self?.navigationFlow = nil
|
||||
}
|
||||
@ -832,7 +832,7 @@ extension HomeTimelineViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension HomeTimelineViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel!.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel!.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
@ -21,7 +21,7 @@ extension HomeTimelineViewModel {
|
||||
context: context,
|
||||
configuration: StatusSection.Configuration(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
statusTableViewCellDelegate: statusTableViewCellDelegate,
|
||||
timelineMiddleLoaderTableViewCellDelegate: timelineMiddleLoaderTableViewCellDelegate,
|
||||
filterContext: .home,
|
||||
|
@ -8,10 +8,10 @@ import MastodonCore
|
||||
extension HomeTimelineViewModel {
|
||||
|
||||
func askForDonationIfPossible() async {
|
||||
let userAuthentication = authContext.mastodonAuthenticationBox
|
||||
let userAuthentication = authenticationBox
|
||||
.authentication
|
||||
guard let accountCreatedAt = userAuthentication.accountCreatedAt else {
|
||||
let updated = try? await context.apiService.accountVerifyCredentials(domain: userAuthentication.domain, authorization: authContext.mastodonAuthenticationBox.userAuthorization)
|
||||
let updated = try? await context.apiService.accountVerifyCredentials(domain: userAuthentication.domain, authorization: authenticationBox.userAuthorization)
|
||||
guard let accountCreatedAt = updated?.createdAt else { return }
|
||||
AuthenticationServiceProvider.shared.updateAccountCreatedAt(accountCreatedAt, forAuthentication: userAuthentication)
|
||||
return
|
||||
|
@ -126,23 +126,23 @@ extension HomeTimelineViewModel.LoadLatestState {
|
||||
case .home:
|
||||
response = try await viewModel.context.apiService.homeTimeline(
|
||||
sinceID: sinceID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
case .public:
|
||||
response = try await viewModel.context.apiService.publicTimeline(
|
||||
query: .init(local: true, sinceID: sinceID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
case let .list(id):
|
||||
response = try await viewModel.context.apiService.listTimeline(
|
||||
id: id,
|
||||
query: .init(sinceID: sinceID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
case let .hashtag(tag):
|
||||
response = try await viewModel.context.apiService.hashtagTimeline(
|
||||
hashtag: tag,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -67,23 +67,23 @@ extension HomeTimelineViewModel.LoadOldestState {
|
||||
case .home:
|
||||
response = try await viewModel.context.apiService.homeTimeline(
|
||||
maxID: maxID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
case .public:
|
||||
response = try await viewModel.context.apiService.publicTimeline(
|
||||
query: .init(local: true, maxID: maxID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
case let .list(id):
|
||||
response = try await viewModel.context.apiService.listTimeline(
|
||||
id: id,
|
||||
query: .init(local: true, maxID: maxID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
case let .hashtag(tag):
|
||||
response = try await viewModel.context.apiService.hashtagTimeline(
|
||||
hashtag: tag,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ final class HomeTimelineViewModel: NSObject {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let dataController: FeedDataController
|
||||
|
||||
var presentedSuggestions = false
|
||||
@ -90,12 +90,12 @@ final class HomeTimelineViewModel: NSObject {
|
||||
|
||||
var cellFrameCache = NSCache<NSNumber, NSValue>()
|
||||
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.dataController = FeedDataController(context: context, authContext: authContext)
|
||||
self.authenticationBox = authenticationBox
|
||||
self.dataController = FeedDataController(context: context, authenticationBox: authenticationBox)
|
||||
super.init()
|
||||
self.dataController.records = (try? FileManager.default.cachedHomeTimeline(for: authContext.mastodonAuthenticationBox).map {
|
||||
self.dataController.records = (try? FileManager.default.cachedHomeTimeline(for: authenticationBox).map {
|
||||
MastodonFeed.fromStatus($0, kind: .home)
|
||||
}) ?? []
|
||||
|
||||
@ -114,7 +114,7 @@ final class HomeTimelineViewModel: NSObject {
|
||||
guard let status = feed.status else { return nil }
|
||||
return status
|
||||
}
|
||||
FileManager.default.cacheHomeTimeline(items: items, for: authContext.mastodonAuthenticationBox)
|
||||
FileManager.default.cacheHomeTimeline(items: items, for: authenticationBox)
|
||||
})
|
||||
.store(in: &disposeBag)
|
||||
|
||||
@ -172,23 +172,23 @@ extension HomeTimelineViewModel {
|
||||
case .home:
|
||||
response = try? await context.apiService.homeTimeline(
|
||||
maxID: status.id,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
case .public:
|
||||
response = try? await context.apiService.publicTimeline(
|
||||
query: .init(local: true, maxID: status.id),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
case let .list(id):
|
||||
response = try? await context.apiService.listTimeline(
|
||||
id: id,
|
||||
query: .init(local: true, maxID: status.id),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
case let .hashtag(tag):
|
||||
response = try? await context.apiService.hashtagTimeline(
|
||||
hashtag: tag,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ extension NotificationRequestsTableViewController: UITableViewDelegate {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension NotificationRequestsTableViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
extension NotificationRequestsTableViewController: NotificationRequestTableViewCellDelegate {
|
||||
@ -136,10 +136,10 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC
|
||||
}
|
||||
|
||||
private func acceptNotificationRequest(_ notificationRequest: MastodonSDK.Mastodon.Entity.NotificationRequest) async throws {
|
||||
_ = try await context.apiService.acceptNotificationRequests(authenticationBox: authContext.mastodonAuthenticationBox,
|
||||
_ = try await context.apiService.acceptNotificationRequests(authenticationBox: authenticationBox,
|
||||
id: notificationRequest.id)
|
||||
|
||||
let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value
|
||||
let requests = try await context.apiService.notificationRequests(authenticationBox: authenticationBox).value
|
||||
|
||||
NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil)
|
||||
|
||||
@ -183,10 +183,10 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC
|
||||
}
|
||||
|
||||
private func rejectNotificationRequest(_ notificationRequest: MastodonSDK.Mastodon.Entity.NotificationRequest) async throws {
|
||||
_ = try await context.apiService.rejectNotificationRequests(authenticationBox: authContext.mastodonAuthenticationBox,
|
||||
_ = try await context.apiService.rejectNotificationRequests(authenticationBox: authenticationBox,
|
||||
id: notificationRequest.id)
|
||||
|
||||
let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value
|
||||
let requests = try await context.apiService.notificationRequests(authenticationBox: authenticationBox).value
|
||||
|
||||
NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil)
|
||||
|
||||
|
@ -6,14 +6,14 @@ import MastodonCore
|
||||
|
||||
struct NotificationRequestsViewModel {
|
||||
let appContext: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let coordinator: SceneCoordinator
|
||||
|
||||
var requests: [Mastodon.Entity.NotificationRequest]
|
||||
|
||||
init(appContext: AppContext, authContext: AuthContext, coordinator: SceneCoordinator, requests: [Mastodon.Entity.NotificationRequest]) {
|
||||
init(appContext: AppContext, authenticationBox: MastodonAuthenticationBox, coordinator: SceneCoordinator, requests: [Mastodon.Entity.NotificationRequest]) {
|
||||
self.appContext = appContext
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.coordinator = coordinator
|
||||
self.requests = requests
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ enum NotificationSection: Equatable, Hashable {
|
||||
extension NotificationSection {
|
||||
|
||||
struct Configuration {
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
weak var notificationTableViewCellDelegate: NotificationTableViewCellDelegate?
|
||||
let filterContext: Mastodon.Entity.Filter.Context?
|
||||
let activeFilters: Published<[Mastodon.Entity.Filter]>.Publisher?
|
||||
@ -90,13 +90,13 @@ extension NotificationSection {
|
||||
) {
|
||||
StatusSection.setupStatusPollDataSource(
|
||||
context: context,
|
||||
authContext: configuration.authContext,
|
||||
authenticationBox: configuration.authenticationBox,
|
||||
statusView: cell.notificationView.statusView
|
||||
)
|
||||
|
||||
StatusSection.setupStatusPollDataSource(
|
||||
context: context,
|
||||
authContext: configuration.authContext,
|
||||
authenticationBox: configuration.authenticationBox,
|
||||
statusView: cell.notificationView.quoteStatusView
|
||||
)
|
||||
|
||||
@ -104,7 +104,7 @@ extension NotificationSection {
|
||||
tableView: tableView,
|
||||
viewModel: viewModel,
|
||||
delegate: configuration.notificationTableViewCellDelegate,
|
||||
authenticationBox: configuration.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: configuration.authenticationBox
|
||||
)
|
||||
|
||||
cell.notificationView.statusView.viewModel.filterContext = configuration.filterContext
|
||||
|
@ -126,7 +126,7 @@ extension NotificationTimelineViewController {
|
||||
|
||||
@objc private func refreshControlValueChanged(_ sender: RefreshControl) {
|
||||
Task {
|
||||
let policy = try? await context.apiService.notificationPolicy(authenticationBox: authContext.mastodonAuthenticationBox)
|
||||
let policy = try? await context.apiService.notificationPolicy(authenticationBox: authenticationBox)
|
||||
viewModel.notificationPolicy = policy?.value
|
||||
|
||||
await viewModel.loadLatest()
|
||||
@ -137,7 +137,7 @@ extension NotificationTimelineViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension NotificationTimelineViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
@ -289,7 +289,7 @@ extension NotificationTimelineViewController: TableViewControllerNavigateable {
|
||||
if let status = notification.status {
|
||||
let threadViewModel = ThreadViewModel(
|
||||
context: self.context,
|
||||
authContext: self.viewModel.authContext,
|
||||
authenticationBox: self.viewModel.authenticationBox,
|
||||
optionalRoot: .root(context: .init(status: .fromEntity(status)))
|
||||
)
|
||||
_ = self.coordinator.present(
|
||||
|
@ -19,7 +19,7 @@ extension NotificationTimelineViewModel {
|
||||
tableView: tableView,
|
||||
context: context,
|
||||
configuration: NotificationSection.Configuration(
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
notificationTableViewCellDelegate: notificationTableViewCellDelegate,
|
||||
filterContext: .notifications,
|
||||
activeFilters: context.statusFilterService.$activeFilters
|
||||
|
@ -81,7 +81,7 @@ extension NotificationTimelineViewModel.LoadOldestState {
|
||||
maxID: maxID,
|
||||
accountID: accountID,
|
||||
scope: scope,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
|
||||
let notifications = response.value
|
||||
|
@ -19,7 +19,7 @@ final class NotificationTimelineViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let scope: Scope
|
||||
var notificationPolicy: Mastodon.Entity.NotificationPolicy?
|
||||
let dataController: FeedDataController
|
||||
@ -47,23 +47,23 @@ final class NotificationTimelineViewModel {
|
||||
@MainActor
|
||||
init(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
scope: Scope,
|
||||
notificationPolicy: Mastodon.Entity.NotificationPolicy? = nil
|
||||
) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.scope = scope
|
||||
self.dataController = FeedDataController(context: context, authContext: authContext)
|
||||
self.dataController = FeedDataController(context: context, authenticationBox: authenticationBox)
|
||||
self.notificationPolicy = notificationPolicy
|
||||
|
||||
switch scope {
|
||||
case .everything:
|
||||
self.dataController.records = (try? FileManager.default.cachedNotificationsAll(for: authContext.mastodonAuthenticationBox))?.map({ notification in
|
||||
self.dataController.records = (try? FileManager.default.cachedNotificationsAll(for: authenticationBox))?.map({ notification in
|
||||
MastodonFeed.fromNotification(notification, relationship: nil, kind: .notificationAll)
|
||||
}) ?? []
|
||||
case .mentions:
|
||||
self.dataController.records = (try? FileManager.default.cachedNotificationsMentions(for: authContext.mastodonAuthenticationBox))?.map({ notification in
|
||||
self.dataController.records = (try? FileManager.default.cachedNotificationsMentions(for: authenticationBox))?.map({ notification in
|
||||
MastodonFeed.fromNotification(notification, relationship: nil, kind: .notificationMentions)
|
||||
}) ?? []
|
||||
case .fromAccount(_):
|
||||
@ -80,9 +80,9 @@ final class NotificationTimelineViewModel {
|
||||
}
|
||||
switch self.scope {
|
||||
case .everything:
|
||||
FileManager.default.cacheNotificationsAll(items: items, for: authContext.mastodonAuthenticationBox)
|
||||
FileManager.default.cacheNotificationsAll(items: items, for: authenticationBox)
|
||||
case .mentions:
|
||||
FileManager.default.cacheNotificationsMentions(items: items, for: authContext.mastodonAuthenticationBox)
|
||||
FileManager.default.cacheNotificationsMentions(items: items, for: authenticationBox)
|
||||
case .fromAccount(_):
|
||||
//NOTE: we don't persist these
|
||||
break
|
||||
@ -99,7 +99,7 @@ final class NotificationTimelineViewModel {
|
||||
Task { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
let policy = try await self.context.apiService.notificationPolicy(authenticationBox: self.authContext.mastodonAuthenticationBox)
|
||||
let policy = try await self.context.apiService.notificationPolicy(authenticationBox: self.authenticationBox)
|
||||
self.notificationPolicy = policy.value
|
||||
|
||||
await self.loadLatest()
|
||||
|
@ -157,7 +157,7 @@ extension NotificationViewController {
|
||||
let viewController = NotificationTimelineViewController(
|
||||
viewModel: NotificationTimelineViewModel(
|
||||
context: context,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
scope: scope, notificationPolicy: viewModel.notificationPolicy
|
||||
),
|
||||
context: context,
|
||||
|
@ -19,7 +19,7 @@ final class NotificationViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
var notificationPolicy: Mastodon.Entity.NotificationPolicy?
|
||||
let viewDidLoad = PassthroughSubject<Void, Never>()
|
||||
|
||||
@ -34,7 +34,7 @@ final class NotificationViewModel {
|
||||
private var lastPageIndex: Int {
|
||||
get {
|
||||
guard let selectedTabName = UserDefaults.shared.getLastSelectedNotificationsTabName(
|
||||
accessToken: authContext.mastodonAuthenticationBox.userAuthorization.accessToken
|
||||
accessToken: authenticationBox.userAuthorization.accessToken
|
||||
), let scope = APIService.MastodonNotificationScope(rawValue: selectedTabName) else {
|
||||
return 0
|
||||
}
|
||||
@ -43,20 +43,20 @@ final class NotificationViewModel {
|
||||
}
|
||||
set {
|
||||
UserDefaults.shared.setLastSelectedNotificationsTabName(
|
||||
accessToken: authContext.mastodonAuthenticationBox.userAuthorization.accessToken,
|
||||
accessToken: authenticationBox.userAuthorization.accessToken,
|
||||
value: APIService.MastodonNotificationScope.allCases[newValue].rawValue
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
|
||||
// end init
|
||||
Task {
|
||||
do {
|
||||
let policy = try await context.apiService.notificationPolicy(authenticationBox: authContext.mastodonAuthenticationBox)
|
||||
let policy = try await context.apiService.notificationPolicy(authenticationBox: authenticationBox)
|
||||
self.notificationPolicy = policy.value
|
||||
} catch {
|
||||
// we won't show the filtering-options.
|
||||
|
@ -102,7 +102,7 @@ extension BookmarkViewController: StatusTableViewCellDelegate { }
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension BookmarkViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
extension BookmarkViewController {
|
||||
|
@ -18,7 +18,7 @@ extension BookmarkViewModel {
|
||||
context: context,
|
||||
configuration: StatusSection.Configuration(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
statusTableViewCellDelegate: statusTableViewCellDelegate,
|
||||
timelineMiddleLoaderTableViewCellDelegate: nil,
|
||||
filterContext: .none,
|
||||
|
@ -126,7 +126,7 @@ extension BookmarkViewModel.State {
|
||||
do {
|
||||
let response = try await viewModel.context.apiService.bookmarkedStatuses(
|
||||
maxID: maxID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
|
@ -18,7 +18,7 @@ final class BookmarkViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
let dataController: StatusDataController
|
||||
|
||||
@ -38,9 +38,9 @@ final class BookmarkViewModel {
|
||||
}()
|
||||
|
||||
@MainActor
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.dataController = StatusDataController()
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ final class FamiliarFollowersViewController: UIViewController, NeedsDependency {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension FamiliarFollowersViewController: AuthContextProvider {
|
||||
var authContext: AuthContext {
|
||||
viewModel.authContext
|
||||
var authenticationBox: MastodonAuthenticationBox {
|
||||
viewModel.authenticationBox
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import MastodonSDK
|
||||
|
||||
final class FamiliarFollowersViewModel {
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
var accounts: [Mastodon.Entity.Account]
|
||||
var relationships: [Mastodon.Entity.Relationship]
|
||||
@ -19,9 +19,9 @@ final class FamiliarFollowersViewModel {
|
||||
// output
|
||||
var diffableDataSource: UITableViewDiffableDataSource<UserSection, UserItem>?
|
||||
|
||||
init(context: AppContext, authContext: AuthContext, accounts: [Mastodon.Entity.Account], relationships: [Mastodon.Entity.Relationship]) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox, accounts: [Mastodon.Entity.Account], relationships: [Mastodon.Entity.Relationship]) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.accounts = accounts
|
||||
self.relationships = relationships
|
||||
}
|
||||
@ -33,7 +33,7 @@ final class FamiliarFollowersViewModel {
|
||||
diffableDataSource = UserSection.diffableDataSource(
|
||||
tableView: tableView,
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
userTableViewCellDelegate: userTableViewCellDelegate
|
||||
)
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ extension FavoriteViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension FavoriteViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
@ -18,7 +18,7 @@ extension FavoriteViewModel {
|
||||
context: context,
|
||||
configuration: StatusSection.Configuration(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
statusTableViewCellDelegate: statusTableViewCellDelegate,
|
||||
timelineMiddleLoaderTableViewCellDelegate: nil,
|
||||
filterContext: .none,
|
||||
|
@ -125,7 +125,7 @@ extension FavoriteViewModel.State {
|
||||
do {
|
||||
let response = try await viewModel.context.apiService.favoritedStatuses(
|
||||
maxID: maxID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
|
@ -18,7 +18,7 @@ final class FavoriteViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let dataController: StatusDataController
|
||||
|
||||
// output
|
||||
@ -37,9 +37,9 @@ final class FavoriteViewModel {
|
||||
}()
|
||||
|
||||
@MainActor
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.dataController = StatusDataController()
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import MastodonLocalization
|
||||
final class FollowedTagsViewController: UIViewController, NeedsDependency {
|
||||
var context: AppContext!
|
||||
var coordinator: SceneCoordinator!
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
var viewModel: FollowedTagsViewModel
|
||||
|
||||
@ -22,10 +22,10 @@ final class FollowedTagsViewController: UIViewController, NeedsDependency {
|
||||
let tableView: UITableView
|
||||
let refreshControl: UIRefreshControl
|
||||
|
||||
init(appContext: AppContext, sceneCoordinator: SceneCoordinator, authContext: AuthContext, viewModel: FollowedTagsViewModel) {
|
||||
init(appContext: AppContext, sceneCoordinator: SceneCoordinator, authenticationBox: MastodonAuthenticationBox, viewModel: FollowedTagsViewModel) {
|
||||
self.context = appContext
|
||||
self.coordinator = sceneCoordinator
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.viewModel = viewModel
|
||||
|
||||
refreshControl = UIRefreshControl()
|
||||
@ -77,7 +77,7 @@ extension FollowedTagsViewController: UITableViewDelegate {
|
||||
|
||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(
|
||||
context: self.context,
|
||||
authContext: self.authContext,
|
||||
authenticationBox: self.authenticationBox,
|
||||
hashtag: object.name
|
||||
)
|
||||
|
||||
|
@ -17,11 +17,11 @@ final class FollowedTagsViewModel: NSObject {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
init(context: AppContext, authContext: AuthContext) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.followedTags = []
|
||||
|
||||
super.init()
|
||||
@ -39,9 +39,9 @@ extension FollowedTagsViewModel {
|
||||
Task { @MainActor in
|
||||
do {
|
||||
followedTags = try await context.apiService.getFollowedTags(
|
||||
domain: authContext.mastodonAuthenticationBox.domain,
|
||||
domain: authenticationBox.domain,
|
||||
query: Mastodon.API.Account.FollowedTagsQuery(limit: nil),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
@ -61,12 +61,12 @@ extension FollowedTagsViewModel {
|
||||
if tag.following ?? false {
|
||||
_ = try? await context.apiService.unfollowTag(
|
||||
for: tag.name,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
} else {
|
||||
_ = try? await context.apiService.followTag(
|
||||
for: tag.name,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ extension FollowerListViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension FollowerListViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ extension FollowerListViewModel {
|
||||
diffableDataSource = UserSection.diffableDataSource(
|
||||
tableView: tableView,
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
userTableViewCellDelegate: userTableViewCellDelegate
|
||||
)
|
||||
|
||||
@ -53,7 +53,7 @@ extension FollowerListViewModel {
|
||||
snapshot.appendItems([.bottomLoader], toSection: .main)
|
||||
case is State.NoMore:
|
||||
guard let userID = self.userID,
|
||||
userID != self.authContext.mastodonAuthenticationBox.userID
|
||||
userID != self.authenticationBox.userID
|
||||
else { break }
|
||||
// display footer exclude self
|
||||
let text = L10n.Scene.Following.footer
|
||||
|
@ -141,7 +141,7 @@ extension FollowerListViewModel.State {
|
||||
let accountResponse = try await viewModel.context.apiService.followers(
|
||||
userID: userID,
|
||||
maxID: maxID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
|
||||
if accountResponse.value.isEmpty {
|
||||
@ -154,7 +154,7 @@ extension FollowerListViewModel.State {
|
||||
|
||||
var hasNewAppend = false
|
||||
|
||||
let newRelationships = try await viewModel.context.apiService.relationship(forAccounts: accountResponse.value, authenticationBox: viewModel.authContext.mastodonAuthenticationBox)
|
||||
let newRelationships = try await viewModel.context.apiService.relationship(forAccounts: accountResponse.value, authenticationBox: viewModel.authenticationBox)
|
||||
|
||||
var accounts = viewModel.accounts
|
||||
|
||||
|
@ -16,7 +16,7 @@ final class FollowerListViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
@Published var accounts: [Mastodon.Entity.Account]
|
||||
@Published var relationships: [Mastodon.Entity.Relationship]
|
||||
|
||||
@ -44,12 +44,12 @@ final class FollowerListViewModel {
|
||||
|
||||
init(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
domain: String?,
|
||||
userID: String?
|
||||
) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.domain = domain
|
||||
self.userID = userID
|
||||
self.accounts = []
|
||||
|
@ -109,7 +109,7 @@ final class FollowingListViewController: UIViewController, NeedsDependency {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension FollowingListViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
@ -19,7 +19,7 @@ extension FollowingListViewModel {
|
||||
diffableDataSource = UserSection.diffableDataSource(
|
||||
tableView: tableView,
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
userTableViewCellDelegate: userTableViewCellDelegate
|
||||
)
|
||||
|
||||
@ -54,7 +54,7 @@ extension FollowingListViewModel {
|
||||
snapshot.appendItems([.bottomLoader], toSection: .main)
|
||||
case is State.NoMore:
|
||||
guard let userID = self.userID,
|
||||
userID != self.authContext.mastodonAuthenticationBox.userID
|
||||
userID != self.authenticationBox.userID
|
||||
else { break }
|
||||
// display footer exclude self
|
||||
let text = L10n.Scene.Following.footer
|
||||
|
@ -136,7 +136,7 @@ extension FollowingListViewModel.State {
|
||||
let accountResponse = try await viewModel.context.apiService.following(
|
||||
userID: userID,
|
||||
maxID: maxID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
|
||||
if accountResponse.value.isEmpty {
|
||||
@ -149,7 +149,7 @@ extension FollowingListViewModel.State {
|
||||
|
||||
var hasNewAppend = false
|
||||
|
||||
let newRelationships = try await viewModel.context.apiService.relationship(forAccounts: accountResponse.value, authenticationBox: viewModel.authContext.mastodonAuthenticationBox)
|
||||
let newRelationships = try await viewModel.context.apiService.relationship(forAccounts: accountResponse.value, authenticationBox: viewModel.authenticationBox)
|
||||
|
||||
var accounts = viewModel.accounts
|
||||
|
||||
|
@ -17,7 +17,7 @@ final class FollowingListViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
@Published var accounts: [Mastodon.Entity.Account]
|
||||
@Published var relationships: [Mastodon.Entity.Relationship]
|
||||
|
||||
@ -45,12 +45,12 @@ final class FollowingListViewModel {
|
||||
|
||||
init(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
domain: String?,
|
||||
userID: String?
|
||||
) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.domain = domain
|
||||
self.userID = userID
|
||||
self.accounts = []
|
||||
|
@ -82,10 +82,10 @@ final class ProfileHeaderViewController: UIViewController, NeedsDependency, Medi
|
||||
return documentPickerController
|
||||
}()
|
||||
|
||||
init(context: AppContext, authContext: AuthContext, coordinator: SceneCoordinator, profileViewModel: ProfileViewModel) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox, coordinator: SceneCoordinator, profileViewModel: ProfileViewModel) {
|
||||
self.context = context
|
||||
self.coordinator = coordinator
|
||||
self.viewModel = ProfileHeaderViewModel(context: context, authContext: authContext, account: profileViewModel.account, me: profileViewModel.me, relationship: profileViewModel.relationship)
|
||||
self.viewModel = ProfileHeaderViewModel(context: context, authenticationBox: authenticationBox, account: profileViewModel.account, me: profileViewModel.me, relationship: profileViewModel.relationship)
|
||||
self.profileHeaderView = ProfileHeaderView(account: profileViewModel.account, me: profileViewModel.me, relationship: profileViewModel.relationship)
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
@ -342,7 +342,7 @@ extension ProfileHeaderViewController: ProfileHeaderViewDelegate {
|
||||
let userID = viewModel.account.id
|
||||
let followerListViewModel = FollowerListViewModel(
|
||||
context: context,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
domain: domain,
|
||||
userID: userID
|
||||
)
|
||||
@ -358,7 +358,7 @@ extension ProfileHeaderViewController: ProfileHeaderViewDelegate {
|
||||
let userID = viewModel.account.id
|
||||
let followingListViewModel = FollowingListViewModel(
|
||||
context: context,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
domain: domain,
|
||||
userID: userID
|
||||
)
|
||||
|
@ -24,7 +24,7 @@ final class ProfileHeaderViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
@Published var me: Mastodon.Entity.Account
|
||||
@Published var account: Mastodon.Entity.Account
|
||||
@ -45,9 +45,9 @@ final class ProfileHeaderViewModel {
|
||||
@Published var isTitleViewDisplaying = false
|
||||
@Published var isTitleViewContentOffsetSet = false
|
||||
|
||||
init(context: AppContext, authContext: AuthContext, account: Mastodon.Entity.Account, me: Mastodon.Entity.Account, relationship: Mastodon.Entity.Relationship?) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox, account: Mastodon.Entity.Account, me: Mastodon.Entity.Account, relationship: Mastodon.Entity.Relationship?) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.account = account
|
||||
self.me = me
|
||||
self.relationship = relationship
|
||||
|
@ -144,7 +144,7 @@ final class ProfileViewController: UIViewController, NeedsDependency, MediaPrevi
|
||||
}
|
||||
|
||||
private func createProfileHeaderViewController(viewModel: ProfileViewModel) -> ProfileHeaderViewController {
|
||||
let viewController = ProfileHeaderViewController(context: context, authContext: viewModel.authContext, coordinator: coordinator, profileViewModel: viewModel)
|
||||
let viewController = ProfileHeaderViewController(context: context, authenticationBox: viewModel.authenticationBox, coordinator: coordinator, profileViewModel: viewModel)
|
||||
return viewController
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ extension ProfileViewController {
|
||||
_ = coordinator.present(scene: .safari(url: url), from: nil, transition: .safariPresent(animated: true, completion: nil))
|
||||
case .hashtag(_, let hashtag, _):
|
||||
guard let viewModel = viewModel else { break }
|
||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: context, authContext: viewModel.authContext, hashtag: hashtag)
|
||||
let hashtagTimelineViewModel = HashtagTimelineViewModel(context: context, authenticationBox: viewModel.authenticationBox, hashtag: hashtag)
|
||||
_ = coordinator.present(scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel), from: nil, transition: .show)
|
||||
case .email, .emoji:
|
||||
break
|
||||
@ -602,14 +602,14 @@ extension ProfileViewController {
|
||||
@objc private func favoriteBarButtonItemPressed(_ sender: UIBarButtonItem) {
|
||||
guard let viewModel = viewModel else { return }
|
||||
|
||||
let favoriteViewModel = FavoriteViewModel(context: context, authContext: viewModel.authContext)
|
||||
let favoriteViewModel = FavoriteViewModel(context: context, authenticationBox: viewModel.authenticationBox)
|
||||
_ = coordinator.present(scene: .favorite(viewModel: favoriteViewModel), from: self, transition: .show)
|
||||
}
|
||||
|
||||
@objc private func bookmarkBarButtonItemPressed(_ sender: UIBarButtonItem) {
|
||||
guard let viewModel = viewModel else { return }
|
||||
|
||||
let bookmarkViewModel = BookmarkViewModel(context: context, authContext: viewModel.authContext)
|
||||
let bookmarkViewModel = BookmarkViewModel(context: context, authenticationBox: viewModel.authenticationBox)
|
||||
_ = coordinator.present(scene: .bookmark(viewModel: bookmarkViewModel), from: self, transition: .show)
|
||||
}
|
||||
|
||||
@ -620,7 +620,7 @@ extension ProfileViewController {
|
||||
UITextChecker.learnWord(mention)
|
||||
let composeViewModel = ComposeViewModel(
|
||||
context: context,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
composeContext: .composeStatus,
|
||||
destination: .topLevel,
|
||||
initialContent: mention
|
||||
@ -631,7 +631,7 @@ extension ProfileViewController {
|
||||
@objc private func followedTagsItemPressed(_ sender: UIBarButtonItem) {
|
||||
guard let viewModel = viewModel else { return }
|
||||
|
||||
let followedTagsViewModel = FollowedTagsViewModel(context: context, authContext: viewModel.authContext)
|
||||
let followedTagsViewModel = FollowedTagsViewModel(context: context, authenticationBox: viewModel.authenticationBox)
|
||||
_ = coordinator.present(scene: .followedTags(viewModel: followedTagsViewModel), from: self, transition: .show)
|
||||
}
|
||||
|
||||
@ -645,17 +645,17 @@ extension ProfileViewController {
|
||||
|
||||
let account = viewModel.account
|
||||
if let domain = account.domain,
|
||||
let updatedAccount = try? await context.apiService.fetchUser(username: account.acct, domain: domain, authenticationBox: viewModel.authContext.mastodonAuthenticationBox),
|
||||
let updatedRelationship = try? await context.apiService.relationship(forAccounts: [updatedAccount], authenticationBox: viewModel.authContext.mastodonAuthenticationBox).value.first
|
||||
let updatedAccount = try? await context.apiService.fetchUser(username: account.acct, domain: domain, authenticationBox: viewModel.authenticationBox),
|
||||
let updatedRelationship = try? await context.apiService.relationship(forAccounts: [updatedAccount], authenticationBox: viewModel.authenticationBox).value.first
|
||||
{
|
||||
viewModel.account = updatedAccount
|
||||
viewModel.relationship = updatedRelationship
|
||||
viewModel.profileAboutViewModel.fields = updatedAccount.mastodonFields
|
||||
}
|
||||
|
||||
if let updatedMe = try? await context.apiService.authenticatedUserInfo(authenticationBox: viewModel.authContext.mastodonAuthenticationBox).value {
|
||||
if let updatedMe = try? await context.apiService.authenticatedUserInfo(authenticationBox: viewModel.authenticationBox).value {
|
||||
viewModel.me = updatedMe
|
||||
FileManager.default.store(account: updatedMe, forUserID: viewModel.authContext.mastodonAuthenticationBox.authentication.userIdentifier())
|
||||
FileManager.default.store(account: updatedMe, forUserID: viewModel.authenticationBox.authentication.userIdentifier())
|
||||
}
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
@ -763,7 +763,7 @@ extension ProfileViewController: TabBarPagerDataSource {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension ProfileViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel!.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel!.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - ProfileHeaderViewControllerDelegate
|
||||
@ -916,7 +916,7 @@ extension ProfileViewController: ProfileHeaderViewControllerDelegate {
|
||||
Task {
|
||||
_ = try await DataSourceFacade.responseToDomainBlockAction(dependency: self, account: account)
|
||||
|
||||
guard let newRelationship = try await self.context.apiService.relationship(forAccounts: [account], authenticationBox: viewModel.authContext.mastodonAuthenticationBox).value.first else { return }
|
||||
guard let newRelationship = try await self.context.apiService.relationship(forAccounts: [account], authenticationBox: viewModel.authenticationBox).value.first else { return }
|
||||
|
||||
viewModel.isUpdating = false
|
||||
|
||||
@ -1044,7 +1044,7 @@ extension ProfileViewController: PagerTabStripNavigateable {
|
||||
|
||||
private extension ProfileViewController {
|
||||
var currentInstance: MastodonAuthentication.InstanceConfiguration? {
|
||||
authContext.mastodonAuthenticationBox.authentication.instanceConfiguration
|
||||
authenticationBox.authentication.instanceConfiguration
|
||||
}
|
||||
}
|
||||
|
||||
@ -1084,7 +1084,7 @@ extension ProfileViewController {
|
||||
Task {
|
||||
let account = viewModel.account
|
||||
if let domain = account.domain,
|
||||
let updatedAccount = try? await context.apiService.fetchUser(username: account.acct, domain: domain, authenticationBox: viewModel.authContext.mastodonAuthenticationBox) {
|
||||
let updatedAccount = try? await context.apiService.fetchUser(username: account.acct, domain: domain, authenticationBox: viewModel.authenticationBox) {
|
||||
viewModel.account = updatedAccount
|
||||
|
||||
viewModel.relationship = relationship
|
||||
@ -1097,10 +1097,10 @@ extension ProfileViewController {
|
||||
} else if viewModel.account == viewModel.me {
|
||||
// update my profile
|
||||
Task {
|
||||
if let updatedMe = try? await context.apiService.authenticatedUserInfo(authenticationBox: viewModel.authContext.mastodonAuthenticationBox).value {
|
||||
if let updatedMe = try? await context.apiService.authenticatedUserInfo(authenticationBox: viewModel.authenticationBox).value {
|
||||
viewModel.me = updatedMe
|
||||
viewModel.account = updatedMe
|
||||
FileManager.default.store(account: updatedMe, forUserID: viewModel.authContext.mastodonAuthenticationBox.authentication.userIdentifier())
|
||||
FileManager.default.store(account: updatedMe, forUserID: viewModel.authenticationBox.authentication.userIdentifier())
|
||||
}
|
||||
|
||||
viewModel.isUpdating = false
|
||||
|
@ -32,7 +32,7 @@ class ProfileViewModel: NSObject {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
|
||||
@Published var me: Mastodon.Entity.Account
|
||||
@Published var account: Mastodon.Entity.Account
|
||||
@ -55,28 +55,28 @@ class ProfileViewModel: NSObject {
|
||||
// let needsPagePinToTop = CurrentValueSubject<Bool, Never>(false)
|
||||
|
||||
@MainActor
|
||||
init(context: AppContext, authContext: AuthContext, account: Mastodon.Entity.Account, relationship: Mastodon.Entity.Relationship?, me: Mastodon.Entity.Account) {
|
||||
init(context: AppContext, authenticationBox: MastodonAuthenticationBox, account: Mastodon.Entity.Account, relationship: Mastodon.Entity.Relationship?, me: Mastodon.Entity.Account) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.account = account
|
||||
self.relationship = relationship
|
||||
self.me = me
|
||||
|
||||
self.postsUserTimelineViewModel = UserTimelineViewModel(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
title: L10n.Scene.Profile.SegmentedControl.posts,
|
||||
queryFilter: .init(excludeReplies: true)
|
||||
)
|
||||
self.repliesUserTimelineViewModel = UserTimelineViewModel(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
title: L10n.Scene.Profile.SegmentedControl.postsAndReplies,
|
||||
queryFilter: .init(excludeReplies: false)
|
||||
)
|
||||
self.mediaUserTimelineViewModel = UserTimelineViewModel(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
title: L10n.Scene.Profile.SegmentedControl.media,
|
||||
queryFilter: .init(onlyMedia: true)
|
||||
)
|
||||
@ -136,7 +136,7 @@ class ProfileViewModel: NSObject {
|
||||
do {
|
||||
let response = try await self.context.apiService.relationship(
|
||||
forAccounts: [account],
|
||||
authenticationBox: self.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: self.authenticationBox
|
||||
)
|
||||
|
||||
// there are seconds delay after request follow before requested -> following. Query again when needs
|
||||
@ -176,7 +176,7 @@ class ProfileViewModel: NSObject {
|
||||
return Fail(error: APIService.APIError.implicit(.authenticationMissing)).eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
let mastodonAuthentication = authContext.mastodonAuthenticationBox.authentication
|
||||
let mastodonAuthentication = authenticationBox.authentication
|
||||
let authorization = Mastodon.API.OAuth.Authorization(accessToken: mastodonAuthentication.userAccessToken)
|
||||
return context.apiService.accountVerifyCredentials(domain: domain, authorization: authorization)
|
||||
.tryMap { response in
|
||||
@ -191,7 +191,7 @@ extension ProfileViewModel {
|
||||
headerProfileInfo: ProfileHeaderViewModel.ProfileInfo,
|
||||
aboutProfileInfo: ProfileAboutViewModel.ProfileInfo
|
||||
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Account> {
|
||||
let authenticationBox = authContext.mastodonAuthenticationBox
|
||||
let authenticationBox = authenticationBox
|
||||
let domain = authenticationBox.domain
|
||||
let authorization = authenticationBox.userAuthorization
|
||||
|
||||
|
@ -76,7 +76,7 @@ extension UserTimelineViewController: CellFrameCacheContainer {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension UserTimelineViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
@ -19,7 +19,7 @@ extension UserTimelineViewModel {
|
||||
context: context,
|
||||
configuration: StatusSection.Configuration(
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
statusTableViewCellDelegate: statusTableViewCellDelegate,
|
||||
timelineMiddleLoaderTableViewCellDelegate: nil,
|
||||
filterContext: .none,
|
||||
|
@ -133,7 +133,7 @@ extension UserTimelineViewModel.State {
|
||||
excludeReplies: queryFilter.excludeReplies,
|
||||
excludeReblogs: queryFilter.excludeReblogs,
|
||||
onlyMedia: queryFilter.onlyMedia,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
authenticationBox: viewModel.authenticationBox
|
||||
)
|
||||
|
||||
var hasNewStatusesAppend = false
|
||||
|
@ -19,7 +19,7 @@ final class UserTimelineViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let title: String
|
||||
let dataController: StatusDataController
|
||||
@Published var userIdentifier: UserIdentifier?
|
||||
@ -51,12 +51,12 @@ final class UserTimelineViewModel {
|
||||
@MainActor
|
||||
init(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
title: String,
|
||||
queryFilter: QueryFilter
|
||||
) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.title = title
|
||||
self.dataController = StatusDataController()
|
||||
self.queryFilter = queryFilter
|
||||
|
@ -63,7 +63,7 @@ extension FavoritedByViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension FavoritedByViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
@ -70,7 +70,7 @@ extension RebloggedByViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension RebloggedByViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
@ -20,7 +20,7 @@ extension UserListViewModel {
|
||||
diffableDataSource = UserSection.diffableDataSource(
|
||||
tableView: tableView,
|
||||
context: context,
|
||||
authContext: authContext,
|
||||
authenticationBox: authenticationBox,
|
||||
userTableViewCellDelegate: userTableViewCellDelegate
|
||||
)
|
||||
|
||||
|
@ -121,7 +121,7 @@ extension UserListViewModel.State {
|
||||
guard let viewModel else { return }
|
||||
|
||||
let maxID = self.maxID
|
||||
let authenticationBox = viewModel.authContext.mastodonAuthenticationBox
|
||||
let authenticationBox = viewModel.authenticationBox
|
||||
|
||||
Task {
|
||||
do {
|
||||
@ -151,7 +151,7 @@ extension UserListViewModel.State {
|
||||
|
||||
var hasNewAppend = false
|
||||
|
||||
let newRelationships = try await viewModel.context.apiService.relationship(forAccounts: accountResponse.value, authenticationBox: viewModel.authContext.mastodonAuthenticationBox)
|
||||
let newRelationships = try await viewModel.context.apiService.relationship(forAccounts: accountResponse.value, authenticationBox: viewModel.authenticationBox)
|
||||
|
||||
var accounts = viewModel.accounts
|
||||
|
||||
|
@ -17,7 +17,7 @@ final class UserListViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let kind: Kind
|
||||
@Published var accounts: [Mastodon.Entity.Account]
|
||||
@Published var relationships: [Mastodon.Entity.Relationship]
|
||||
@ -38,11 +38,11 @@ final class UserListViewModel {
|
||||
|
||||
public init(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
kind: Kind
|
||||
) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.kind = kind
|
||||
self.accounts = []
|
||||
self.relationships = []
|
||||
|
@ -81,7 +81,7 @@ extension ReportViewController: ReportReasonViewControllerDelegate {
|
||||
case .dislike:
|
||||
let reportResultViewModel = ReportResultViewModel(
|
||||
context: context,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
account: viewModel.account,
|
||||
relationship: viewModel.relationship,
|
||||
isReported: false
|
||||
@ -158,7 +158,7 @@ extension ReportViewController: ReportSupplementaryViewControllerDelegate {
|
||||
|
||||
let reportResultViewModel = ReportResultViewModel(
|
||||
context: context,
|
||||
authContext: viewModel.authContext,
|
||||
authenticationBox: viewModel.authenticationBox,
|
||||
account: viewModel.account,
|
||||
relationship: viewModel.relationship,
|
||||
isReported: true
|
||||
|
@ -27,7 +27,7 @@ class ReportViewModel {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let account: Mastodon.Entity.Account
|
||||
let relationship: Mastodon.Entity.Relationship
|
||||
let status: MastodonStatus?
|
||||
@ -39,20 +39,20 @@ class ReportViewModel {
|
||||
@MainActor
|
||||
init(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
account: Mastodon.Entity.Account,
|
||||
relationship: Mastodon.Entity.Relationship,
|
||||
status: MastodonStatus?
|
||||
) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.account = account
|
||||
self.relationship = relationship
|
||||
self.status = status
|
||||
self.reportReasonViewModel = ReportReasonViewModel(context: context)
|
||||
self.reportServerRulesViewModel = ReportServerRulesViewModel(context: context)
|
||||
self.reportStatusViewModel = ReportStatusViewModel(context: context, authContext: authContext, account: account, status: status)
|
||||
self.reportSupplementaryViewModel = ReportSupplementaryViewModel(context: context, authContext: authContext, account: account)
|
||||
self.reportStatusViewModel = ReportStatusViewModel(context: context, authenticationBox: authenticationBox, account: account, status: status)
|
||||
self.reportSupplementaryViewModel = ReportSupplementaryViewModel(context: context, authenticationBox: authenticationBox, account: account)
|
||||
// end init
|
||||
|
||||
// setup reason viewModel
|
||||
@ -67,7 +67,7 @@ class ReportViewModel {
|
||||
// bind server rules
|
||||
Task { @MainActor in
|
||||
do {
|
||||
let response = try await context.apiService.instance(domain: authContext.mastodonAuthenticationBox.domain, authenticationBox: authContext.mastodonAuthenticationBox)
|
||||
let response = try await context.apiService.instance(domain: authenticationBox.domain, authenticationBox: authenticationBox)
|
||||
.timeout(3, scheduler: DispatchQueue.main)
|
||||
.singleOutput()
|
||||
let rules = response.value.rules ?? []
|
||||
@ -145,7 +145,7 @@ extension ReportViewModel {
|
||||
isReporting = true
|
||||
let _ = try await context.apiService.report(
|
||||
query: query,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
authenticationBox: authenticationBox
|
||||
)
|
||||
isReportSuccess = true
|
||||
} catch {
|
||||
|
@ -160,7 +160,7 @@ extension ReportResultViewController {
|
||||
|
||||
// MARK: - AuthContextProvider
|
||||
extension ReportResultViewController: AuthContextProvider {
|
||||
var authContext: AuthContext { viewModel.authContext }
|
||||
var authenticationBox: MastodonAuthenticationBox { viewModel.authenticationBox }
|
||||
}
|
||||
|
||||
// MARK: - PanPopableViewController
|
||||
|
@ -22,7 +22,7 @@ class ReportResultViewModel: ObservableObject {
|
||||
|
||||
// input
|
||||
let context: AppContext
|
||||
let authContext: AuthContext
|
||||
let authenticationBox: MastodonAuthenticationBox
|
||||
let account: Mastodon.Entity.Account
|
||||
var relationship: Mastodon.Entity.Relationship
|
||||
let isReported: Bool
|
||||
@ -47,13 +47,13 @@ class ReportResultViewModel: ObservableObject {
|
||||
|
||||
init(
|
||||
context: AppContext,
|
||||
authContext: AuthContext,
|
||||
authenticationBox: MastodonAuthenticationBox,
|
||||
account: Mastodon.Entity.Account,
|
||||
relationship: Mastodon.Entity.Relationship,
|
||||
isReported: Bool
|
||||
) {
|
||||
self.context = context
|
||||
self.authContext = authContext
|
||||
self.authenticationBox = authenticationBox
|
||||
self.account = account
|
||||
self.relationship = relationship
|
||||
self.isReported = isReported
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user