2021-02-05 08:58:48 +01:00
|
|
|
//
|
2021-02-07 07:42:50 +01:00
|
|
|
// HomeTimelineViewController+DebugAction.swift
|
2021-02-05 08:58:48 +01:00
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-2-5.
|
|
|
|
//
|
|
|
|
|
2021-07-16 15:21:18 +02:00
|
|
|
|
|
|
|
#if DEBUG
|
2021-02-05 08:58:48 +01:00
|
|
|
import os.log
|
|
|
|
import UIKit
|
2021-03-02 08:51:16 +01:00
|
|
|
import CoreData
|
|
|
|
import CoreDataStack
|
2021-05-31 10:42:49 +02:00
|
|
|
import FLEX
|
2021-07-16 15:21:18 +02:00
|
|
|
import SwiftUI
|
|
|
|
import MastodonUI
|
2021-05-31 10:42:49 +02:00
|
|
|
|
2021-02-07 07:42:50 +01:00
|
|
|
extension HomeTimelineViewController {
|
2021-02-05 08:58:48 +01:00
|
|
|
var debugMenu: UIMenu {
|
|
|
|
let menu = UIMenu(
|
|
|
|
title: "Debug Tools",
|
|
|
|
image: nil,
|
|
|
|
identifier: nil,
|
|
|
|
options: .displayInline,
|
|
|
|
children: [
|
2021-09-13 13:14:26 +02:00
|
|
|
showMenu,
|
|
|
|
moveMenu,
|
|
|
|
dropMenu,
|
2021-09-16 10:30:21 +02:00
|
|
|
miscMenu,
|
2021-09-13 13:14:26 +02:00
|
|
|
UIAction(title: "Settings", image: UIImage(systemName: "gear"), attributes: []) { [weak self] action in
|
|
|
|
guard let self = self else { return }
|
|
|
|
self.showSettings(action)
|
|
|
|
},
|
|
|
|
UIAction(title: "Sign Out", image: UIImage(systemName: "escape"), attributes: .destructive) { [weak self] action in
|
|
|
|
guard let self = self else { return }
|
|
|
|
self.signOutAction(action)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
)
|
|
|
|
return menu
|
|
|
|
}
|
|
|
|
|
|
|
|
var showMenu: UIMenu {
|
|
|
|
return UIMenu(
|
|
|
|
title: "Show…",
|
|
|
|
image: UIImage(systemName: "plus.rectangle.on.rectangle"),
|
|
|
|
identifier: nil,
|
|
|
|
options: [],
|
|
|
|
children: [
|
|
|
|
UIAction(title: "FLEX", image: nil, attributes: [], handler: { [weak self] action in
|
2021-05-31 10:42:49 +02:00
|
|
|
guard let self = self else { return }
|
|
|
|
self.showFLEXAction(action)
|
|
|
|
}),
|
2021-09-13 13:14:26 +02:00
|
|
|
UIAction(title: "Welcome", image: UIImage(systemName: "figure.walk"), attributes: []) { [weak self] action in
|
2021-04-09 05:05:10 +02:00
|
|
|
guard let self = self else { return }
|
|
|
|
self.showWelcomeAction(action)
|
|
|
|
},
|
2021-09-13 13:14:26 +02:00
|
|
|
UIAction(title: "Confirm Email", image: UIImage(systemName: "envelope"), attributes: []) { [weak self] action in
|
2021-07-06 05:59:28 +02:00
|
|
|
guard let self = self else { return }
|
|
|
|
self.showConfirmEmail(action)
|
|
|
|
},
|
2021-09-13 13:14:26 +02:00
|
|
|
UIAction(title: "Account List", image: UIImage(systemName: "person"), attributes: []) { [weak self] action in
|
2021-04-22 09:52:10 +02:00
|
|
|
guard let self = self else { return }
|
2021-09-13 13:14:26 +02:00
|
|
|
self.showAccountList(action)
|
2021-04-22 09:52:10 +02:00
|
|
|
},
|
2021-09-13 13:14:26 +02:00
|
|
|
UIAction(title: "Public Timeline", image: UIImage(systemName: "list.dash"), attributes: []) { [weak self] action in
|
2021-02-24 11:07:11 +01:00
|
|
|
guard let self = self else { return }
|
|
|
|
self.showPublicTimelineAction(action)
|
|
|
|
},
|
2021-09-13 13:14:26 +02:00
|
|
|
UIAction(title: "Profile", image: UIImage(systemName: "person.crop.circle"), attributes: []) { [weak self] action in
|
2021-04-08 10:53:32 +02:00
|
|
|
guard let self = self else { return }
|
|
|
|
self.showProfileAction(action)
|
|
|
|
},
|
2021-09-13 13:14:26 +02:00
|
|
|
UIAction(title: "Thread", image: UIImage(systemName: "bubble.left.and.bubble.right"), attributes: []) { [weak self] action in
|
2021-04-13 13:46:42 +02:00
|
|
|
guard let self = self else { return }
|
|
|
|
self.showThreadAction(action)
|
|
|
|
},
|
2021-02-05 08:58:48 +01:00
|
|
|
]
|
|
|
|
)
|
|
|
|
}
|
2021-03-02 08:51:16 +01:00
|
|
|
|
2021-03-02 09:27:11 +01:00
|
|
|
var moveMenu: UIMenu {
|
|
|
|
return UIMenu(
|
|
|
|
title: "Move to…",
|
|
|
|
image: UIImage(systemName: "arrow.forward.circle"),
|
|
|
|
identifier: nil,
|
|
|
|
options: [],
|
|
|
|
children: [
|
|
|
|
UIAction(title: "First Gap", image: nil, attributes: [], handler: { [weak self] action in
|
|
|
|
guard let self = self else { return }
|
|
|
|
self.moveToTopGapAction(action)
|
|
|
|
}),
|
2021-03-16 04:48:14 +01:00
|
|
|
UIAction(title: "First Replied Status", image: nil, attributes: [], handler: { [weak self] action in
|
2021-03-10 06:36:01 +01:00
|
|
|
guard let self = self else { return }
|
2021-03-16 04:48:14 +01:00
|
|
|
self.moveToFirstRepliedStatus(action)
|
2021-03-10 06:36:01 +01:00
|
|
|
}),
|
2021-03-16 04:48:14 +01:00
|
|
|
UIAction(title: "First Reblog Status", image: nil, attributes: [], handler: { [weak self] action in
|
2021-03-02 09:27:11 +01:00
|
|
|
guard let self = self else { return }
|
2021-03-16 04:48:14 +01:00
|
|
|
self.moveToFirstReblogStatus(action)
|
2021-03-02 09:27:11 +01:00
|
|
|
}),
|
2021-03-16 04:48:14 +01:00
|
|
|
UIAction(title: "First Poll Status", image: nil, attributes: [], handler: { [weak self] action in
|
2021-03-10 06:36:01 +01:00
|
|
|
guard let self = self else { return }
|
2021-03-16 04:48:14 +01:00
|
|
|
self.moveToFirstPollStatus(action)
|
|
|
|
}),
|
|
|
|
UIAction(title: "First Audio Status", image: nil, attributes: [], handler: { [weak self] action in
|
|
|
|
guard let self = self else { return }
|
|
|
|
self.moveToFirstAudioStatus(action)
|
|
|
|
}),
|
|
|
|
UIAction(title: "First Video Status", image: nil, attributes: [], handler: { [weak self] action in
|
|
|
|
guard let self = self else { return }
|
|
|
|
self.moveToFirstVideoStatus(action)
|
|
|
|
}),
|
2021-04-01 08:39:15 +02:00
|
|
|
UIAction(title: "First GIF status", image: nil, attributes: [], handler: { [weak self] action in
|
2021-03-16 04:48:14 +01:00
|
|
|
guard let self = self else { return }
|
|
|
|
self.moveToFirstGIFStatus(action)
|
2021-03-10 06:36:01 +01:00
|
|
|
}),
|
2021-03-02 09:27:11 +01:00
|
|
|
]
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-03-02 08:51:16 +01:00
|
|
|
var dropMenu: UIMenu {
|
|
|
|
return UIMenu(
|
|
|
|
title: "Drop…",
|
|
|
|
image: UIImage(systemName: "minus.circle"),
|
|
|
|
identifier: nil,
|
|
|
|
options: [],
|
|
|
|
children: [50, 100, 150, 200, 250, 300].map { count in
|
2021-03-16 04:23:19 +01:00
|
|
|
UIAction(title: "Drop Recent \(count) Statuses", image: nil, attributes: [], handler: { [weak self] action in
|
2021-03-02 08:51:16 +01:00
|
|
|
guard let self = self else { return }
|
2021-03-16 04:23:19 +01:00
|
|
|
self.dropRecentStatusAction(action, count: count)
|
2021-03-02 08:51:16 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2021-09-16 10:30:21 +02:00
|
|
|
|
|
|
|
var miscMenu: UIMenu {
|
|
|
|
return UIMenu(
|
|
|
|
title: "Debug…",
|
|
|
|
image: UIImage(systemName: "switch.2"),
|
|
|
|
identifier: nil,
|
|
|
|
options: [],
|
|
|
|
children: [
|
|
|
|
UIAction(title: "Toggle EmptyView", image: UIImage(systemName: "clear"), attributes: []) { [weak self] action in
|
|
|
|
guard let self = self else { return }
|
|
|
|
if self.emptyView.superview != nil {
|
|
|
|
self.emptyView.removeFromSuperview()
|
|
|
|
} else {
|
|
|
|
self.showEmptyView()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
UIAction(
|
|
|
|
title: "notification badge +1",
|
|
|
|
image: UIImage(systemName: "1.circle.fill"),
|
|
|
|
identifier: nil,
|
|
|
|
attributes: [],
|
|
|
|
state: .off,
|
|
|
|
handler: { [weak self] _ in
|
|
|
|
guard let self = self else { return }
|
|
|
|
guard let accessToken = self.context.authenticationService.activeMastodonAuthentication.value?.userAccessToken else { return }
|
|
|
|
UserDefaults.shared.increaseNotificationCount(accessToken: accessToken)
|
|
|
|
self.context.notificationService.applicationIconBadgeNeedsUpdate.send()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-02-05 08:58:48 +01:00
|
|
|
}
|
|
|
|
|
2021-02-07 07:42:50 +01:00
|
|
|
extension HomeTimelineViewController {
|
2021-02-05 08:58:48 +01:00
|
|
|
|
2021-05-31 10:42:49 +02:00
|
|
|
@objc private func showFLEXAction(_ sender: UIAction) {
|
|
|
|
FLEXManager.shared.showExplorer()
|
|
|
|
}
|
|
|
|
|
2021-03-02 09:27:11 +01:00
|
|
|
@objc private func moveToTopGapAction(_ sender: UIAction) {
|
|
|
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
|
|
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
|
|
|
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
|
|
|
|
switch item {
|
|
|
|
case .homeMiddleLoader: return true
|
|
|
|
default: return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
|
|
|
|
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:48:14 +01:00
|
|
|
@objc private func moveToFirstReblogStatus(_ sender: UIAction) {
|
2021-03-10 06:36:01 +01:00
|
|
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
|
|
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
|
|
|
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
|
|
|
|
switch item {
|
|
|
|
case .homeTimelineIndex(let objectID, _):
|
|
|
|
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
|
2021-04-01 08:39:15 +02:00
|
|
|
return homeTimelineIndex.status.reblog != nil
|
2021-03-10 06:36:01 +01:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
|
|
|
|
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
|
|
|
tableView.blinkRow(at: IndexPath(row: index, section: 0))
|
|
|
|
} else {
|
2021-03-16 04:48:14 +01:00
|
|
|
print("Not found reblog status")
|
2021-03-10 06:36:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:48:14 +01:00
|
|
|
@objc private func moveToFirstPollStatus(_ sender: UIAction) {
|
2021-03-02 09:27:11 +01:00
|
|
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
|
|
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
|
|
|
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
|
|
|
|
switch item {
|
|
|
|
case .homeTimelineIndex(let objectID, _):
|
|
|
|
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
|
2021-04-01 08:39:15 +02:00
|
|
|
let post = homeTimelineIndex.status.reblog ?? homeTimelineIndex.status
|
2021-03-15 06:42:46 +01:00
|
|
|
return post.poll != nil
|
2021-03-02 09:27:11 +01:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
|
|
|
|
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
|
|
|
tableView.blinkRow(at: IndexPath(row: index, section: 0))
|
|
|
|
} else {
|
2021-03-16 04:48:14 +01:00
|
|
|
print("Not found poll status")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc private func moveToFirstRepliedStatus(_ sender: UIAction) {
|
|
|
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
|
|
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
|
|
|
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
|
|
|
|
switch item {
|
|
|
|
case .homeTimelineIndex(let objectID, _):
|
|
|
|
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
|
2021-04-01 08:39:15 +02:00
|
|
|
guard homeTimelineIndex.status.inReplyToID != nil else {
|
2021-03-16 04:48:14 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
|
|
|
|
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
|
|
|
tableView.blinkRow(at: IndexPath(row: index, section: 0))
|
|
|
|
} else {
|
|
|
|
print("Not found replied status")
|
2021-03-02 09:27:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:48:14 +01:00
|
|
|
@objc private func moveToFirstAudioStatus(_ sender: UIAction) {
|
2021-03-10 06:36:01 +01:00
|
|
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
|
|
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
|
|
|
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
|
|
|
|
switch item {
|
|
|
|
case .homeTimelineIndex(let objectID, _):
|
|
|
|
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
|
2021-04-01 08:39:15 +02:00
|
|
|
let status = homeTimelineIndex.status.reblog ?? homeTimelineIndex.status
|
|
|
|
return status.mediaAttachments?.contains(where: { $0.type == .audio }) ?? false
|
2021-03-10 06:36:01 +01:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
|
|
|
|
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
|
|
|
tableView.blinkRow(at: IndexPath(row: index, section: 0))
|
|
|
|
} else {
|
2021-04-01 08:39:15 +02:00
|
|
|
print("Not found audio status")
|
2021-03-10 06:36:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:48:14 +01:00
|
|
|
@objc private func moveToFirstVideoStatus(_ sender: UIAction) {
|
|
|
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
|
|
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
|
|
|
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
|
|
|
|
switch item {
|
|
|
|
case .homeTimelineIndex(let objectID, _):
|
|
|
|
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
|
2021-04-01 08:39:15 +02:00
|
|
|
let status = homeTimelineIndex.status.reblog ?? homeTimelineIndex.status
|
|
|
|
return status.mediaAttachments?.contains(where: { $0.type == .video }) ?? false
|
2021-03-16 04:48:14 +01:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
|
|
|
|
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
|
|
|
tableView.blinkRow(at: IndexPath(row: index, section: 0))
|
|
|
|
} else {
|
|
|
|
print("Not found video status")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc private func moveToFirstGIFStatus(_ sender: UIAction) {
|
|
|
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
|
|
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
|
|
|
let item = snapshotTransitioning.itemIdentifiers.first(where: { item in
|
|
|
|
switch item {
|
|
|
|
case .homeTimelineIndex(let objectID, _):
|
|
|
|
let homeTimelineIndex = viewModel.fetchedResultsController.managedObjectContext.object(with: objectID) as! HomeTimelineIndex
|
2021-04-01 08:39:15 +02:00
|
|
|
let status = homeTimelineIndex.status.reblog ?? homeTimelineIndex.status
|
|
|
|
return status.mediaAttachments?.contains(where: { $0.type == .gifv }) ?? false
|
2021-03-16 04:48:14 +01:00
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if let targetItem = item, let index = snapshotTransitioning.indexOfItem(targetItem) {
|
|
|
|
tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .middle, animated: true)
|
|
|
|
tableView.blinkRow(at: IndexPath(row: index, section: 0))
|
|
|
|
} else {
|
|
|
|
print("Not found GIF status")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:23:19 +01:00
|
|
|
@objc private func dropRecentStatusAction(_ sender: UIAction, count: Int) {
|
2021-03-02 08:51:16 +01:00
|
|
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
|
|
|
let snapshotTransitioning = diffableDataSource.snapshot()
|
|
|
|
|
|
|
|
let droppingObjectIDs = snapshotTransitioning.itemIdentifiers.prefix(count).compactMap { item -> NSManagedObjectID? in
|
|
|
|
switch item {
|
|
|
|
case .homeTimelineIndex(let objectID, _): return objectID
|
|
|
|
default: return nil
|
|
|
|
}
|
|
|
|
}
|
2021-04-01 08:39:15 +02:00
|
|
|
var droppingStatusObjectIDs: [NSManagedObjectID] = []
|
2021-03-02 08:51:16 +01:00
|
|
|
context.apiService.backgroundManagedObjectContext.performChanges { [weak self] in
|
|
|
|
guard let self = self else { return }
|
|
|
|
for objectID in droppingObjectIDs {
|
|
|
|
guard let homeTimelineIndex = try? self.context.apiService.backgroundManagedObjectContext.existingObject(with: objectID) as? HomeTimelineIndex else { continue }
|
2021-04-01 08:39:15 +02:00
|
|
|
droppingStatusObjectIDs.append(homeTimelineIndex.status.objectID)
|
2021-03-02 08:51:16 +01:00
|
|
|
self.context.apiService.backgroundManagedObjectContext.delete(homeTimelineIndex)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.sink { [weak self] result in
|
|
|
|
guard let self = self else { return }
|
|
|
|
switch result {
|
|
|
|
case .success:
|
|
|
|
self.context.apiService.backgroundManagedObjectContext.performChanges { [weak self] in
|
|
|
|
guard let self = self else { return }
|
2021-04-01 08:39:15 +02:00
|
|
|
for objectID in droppingStatusObjectIDs {
|
|
|
|
guard let post = try? self.context.apiService.backgroundManagedObjectContext.existingObject(with: objectID) as? Status else { continue }
|
2021-03-15 06:42:46 +01:00
|
|
|
self.context.apiService.backgroundManagedObjectContext.delete(post)
|
2021-03-02 08:51:16 +01:00
|
|
|
}
|
|
|
|
}
|
2021-03-02 12:10:45 +01:00
|
|
|
.sink { _ in
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
.store(in: &self.disposeBag)
|
2021-03-02 08:51:16 +01:00
|
|
|
case .failure(let error):
|
|
|
|
assertionFailure(error.localizedDescription)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.store(in: &disposeBag)
|
|
|
|
}
|
|
|
|
|
2021-04-09 05:05:10 +02:00
|
|
|
@objc private func showWelcomeAction(_ sender: UIAction) {
|
|
|
|
coordinator.present(scene: .welcome, from: self, transition: .modal(animated: true, completion: nil))
|
|
|
|
}
|
2021-07-06 05:59:28 +02:00
|
|
|
|
|
|
|
@objc private func showConfirmEmail(_ sender: UIAction) {
|
|
|
|
let mastodonConfirmEmailViewModel = MastodonConfirmEmailViewModel()
|
|
|
|
coordinator.present(scene: .mastodonConfirmEmail(viewModel: mastodonConfirmEmailViewModel), from: nil, transition: .modal(animated: true, completion: nil))
|
|
|
|
}
|
2021-09-13 13:14:26 +02:00
|
|
|
|
|
|
|
@objc private func showAccountList(_ sender: UIAction) {
|
|
|
|
coordinator.present(scene: .accountList, from: self, transition: .modal(animated: true, completion: nil))
|
|
|
|
}
|
2021-04-09 05:05:10 +02:00
|
|
|
|
2021-02-24 11:07:11 +01:00
|
|
|
@objc private func showPublicTimelineAction(_ sender: UIAction) {
|
|
|
|
coordinator.present(scene: .publicTimeline, from: self, transition: .show)
|
|
|
|
}
|
|
|
|
|
2021-04-08 10:53:32 +02:00
|
|
|
@objc private func showProfileAction(_ sender: UIAction) {
|
|
|
|
let alertController = UIAlertController(title: "Enter User ID", message: nil, preferredStyle: .alert)
|
|
|
|
alertController.addTextField()
|
|
|
|
let showAction = UIAlertAction(title: "Show", style: .default) { [weak self, weak alertController] _ in
|
|
|
|
guard let self = self else { return }
|
|
|
|
guard let textField = alertController?.textFields?.first else { return }
|
|
|
|
let profileViewModel = RemoteProfileViewModel(context: self.context, userID: textField.text ?? "")
|
|
|
|
self.coordinator.present(scene: .profile(viewModel: profileViewModel), from: self, transition: .show)
|
|
|
|
}
|
|
|
|
alertController.addAction(showAction)
|
|
|
|
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
|
|
|
|
alertController.addAction(cancelAction)
|
|
|
|
coordinator.present(scene: .alertController(alertController: alertController), from: self, transition: .alertController(animated: true, completion: nil))
|
|
|
|
}
|
|
|
|
|
2021-04-13 13:46:42 +02:00
|
|
|
@objc private func showThreadAction(_ sender: UIAction) {
|
|
|
|
let alertController = UIAlertController(title: "Enter Status ID", message: nil, preferredStyle: .alert)
|
|
|
|
alertController.addTextField()
|
|
|
|
let showAction = UIAlertAction(title: "Show", style: .default) { [weak self, weak alertController] _ in
|
|
|
|
guard let self = self else { return }
|
|
|
|
guard let textField = alertController?.textFields?.first else { return }
|
|
|
|
let threadViewModel = RemoteThreadViewModel(context: self.context, statusID: textField.text ?? "")
|
|
|
|
self.coordinator.present(scene: .thread(viewModel: threadViewModel), from: self, transition: .show)
|
|
|
|
}
|
|
|
|
alertController.addAction(showAction)
|
|
|
|
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
|
|
|
|
alertController.addAction(cancelAction)
|
|
|
|
coordinator.present(scene: .alertController(alertController: alertController), from: self, transition: .alertController(animated: true, completion: nil))
|
|
|
|
}
|
|
|
|
|
2021-04-17 08:15:55 +02:00
|
|
|
@objc private func showSettings(_ sender: UIAction) {
|
2021-04-26 10:57:50 +02:00
|
|
|
guard let currentSetting = context.settingService.currentSetting.value else { return }
|
|
|
|
let settingsViewModel = SettingsViewModel(context: context, setting: currentSetting)
|
2021-04-22 17:01:07 +02:00
|
|
|
coordinator.present(
|
2021-04-27 12:16:56 +02:00
|
|
|
scene: .settings(viewModel: settingsViewModel),
|
2021-04-22 17:01:07 +02:00
|
|
|
from: self,
|
|
|
|
transition: .modal(animated: true, completion: nil)
|
|
|
|
)
|
2021-04-17 08:15:55 +02:00
|
|
|
}
|
2021-07-16 15:21:18 +02:00
|
|
|
|
2021-02-05 08:58:48 +01:00
|
|
|
}
|
|
|
|
#endif
|