Compare commits
No commits in common. "cc0da2ec5400f99bf6845e27692d7adcb421f023" and "d3187ce2c4c608ab05c1ba1696b23e6c06980ec9" have entirely different histories.
cc0da2ec54
...
d3187ce2c4
|
@ -9,9 +9,6 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
import CrashReporter
|
import CrashReporter
|
||||||
import CoreData
|
import CoreData
|
||||||
import OSLog
|
|
||||||
|
|
||||||
let stateRestorationLogger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "StateRestoration")
|
|
||||||
|
|
||||||
@UIApplicationMain
|
@UIApplicationMain
|
||||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
@ -88,7 +85,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
switch type {
|
switch type {
|
||||||
case .mainScene:
|
case .mainScene:
|
||||||
return "main-scene"
|
return "main-scene"
|
||||||
|
|
||||||
case .showConversation,
|
case .showConversation,
|
||||||
.showTimeline,
|
.showTimeline,
|
||||||
.checkNotifications,
|
.checkNotifications,
|
||||||
|
@ -96,12 +93,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
.bookmarks,
|
.bookmarks,
|
||||||
.myProfile,
|
.myProfile,
|
||||||
.showProfile:
|
.showProfile:
|
||||||
if activity.displaysAuxiliaryScene {
|
return "auxiliary"
|
||||||
stateRestorationLogger.info("Using auxiliary scene for \(type.rawValue, privacy: .public)")
|
|
||||||
return "auxiliary"
|
|
||||||
} else {
|
|
||||||
return "main-scene"
|
|
||||||
}
|
|
||||||
|
|
||||||
case .newPost:
|
case .newPost:
|
||||||
return "compose"
|
return "compose"
|
||||||
|
|
|
@ -87,16 +87,6 @@ class MastodonCachePersistentStore: NSPersistentContainer {
|
||||||
self.statusSubject.send(status.id)
|
self.statusSubject.send(status.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
|
||||||
func addOrUpdateOnViewContext(status: Status) -> StatusMO {
|
|
||||||
let statusMO = self.upsert(status: status, context: viewContext)
|
|
||||||
if viewContext.hasChanges {
|
|
||||||
try! viewContext.save()
|
|
||||||
}
|
|
||||||
statusSubject.send(status.id)
|
|
||||||
return statusMO
|
|
||||||
}
|
|
||||||
|
|
||||||
func addAll(statuses: [Status], completion: (() -> Void)? = nil) {
|
func addAll(statuses: [Status], completion: (() -> Void)? = nil) {
|
||||||
backgroundContext.perform {
|
backgroundContext.perform {
|
||||||
|
@ -108,14 +98,6 @@ class MastodonCachePersistentStore: NSPersistentContainer {
|
||||||
completion?()
|
completion?()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addAll(statuses: [Status]) async {
|
|
||||||
return await withCheckedContinuation { continuation in
|
|
||||||
addAll(statuses: statuses) {
|
|
||||||
continuation.resume()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func account(for id: String, in context: NSManagedObjectContext? = nil) -> AccountMO? {
|
func account(for id: String, in context: NSManagedObjectContext? = nil) -> AccountMO? {
|
||||||
let context = context ?? viewContext
|
let context = context ?? viewContext
|
||||||
|
|
|
@ -28,7 +28,6 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
if let activity = connectionOptions.userActivities.first ?? session.stateRestorationActivity {
|
if let activity = connectionOptions.userActivities.first ?? session.stateRestorationActivity {
|
||||||
launchActivity = activity
|
launchActivity = activity
|
||||||
}
|
}
|
||||||
stateRestorationLogger.info("MainSceneDelegate.launchActivity = \(self.launchActivity?.activityType ?? "nil", privacy: .public)")
|
|
||||||
|
|
||||||
window = UIWindow(windowScene: windowScene)
|
window = UIWindow(windowScene: windowScene)
|
||||||
|
|
||||||
|
@ -70,8 +69,7 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
||||||
stateRestorationLogger.info("MainSceneDelegate.scene(_:continue:) called with \(userActivity.activityType, privacy: .public)")
|
_ = userActivity.handleResume()
|
||||||
_ = userActivity.handleResume(manager: UserActivityManager(scene: scene as! UIWindowScene))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
|
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
|
||||||
|
@ -171,11 +169,6 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
activateAccount(account, animated: false)
|
activateAccount(account, animated: false)
|
||||||
|
|
||||||
if let activity = launchActivity,
|
|
||||||
activity.activityType != UserActivityType.mainScene.rawValue {
|
|
||||||
_ = activity.handleResume(manager: UserActivityManager(scene: window!.windowScene!))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
window!.rootViewController = createOnboardingUI()
|
window!.rootViewController = createOnboardingUI()
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
let mainStatusID: String
|
let mainStatusID: String
|
||||||
let mainStatusState: StatusState
|
let mainStatusState: StatusState
|
||||||
var statusIDToScrollToOnLoad: String
|
|
||||||
private(set) var dataSource: UITableViewDiffableDataSource<Section, Item>!
|
private(set) var dataSource: UITableViewDiffableDataSource<Section, Item>!
|
||||||
|
|
||||||
var showStatusesAutomatically = false
|
var showStatusesAutomatically = false
|
||||||
|
@ -42,7 +41,6 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
init(for mainStatusID: String, state: StatusState = .unknown, mastodonController: MastodonController) {
|
init(for mainStatusID: String, state: StatusState = .unknown, mastodonController: MastodonController) {
|
||||||
self.mainStatusID = mainStatusID
|
self.mainStatusID = mainStatusID
|
||||||
self.mainStatusState = state
|
self.mainStatusState = state
|
||||||
self.statusIDToScrollToOnLoad = mainStatusID
|
|
||||||
self.mastodonController = mastodonController
|
self.mastodonController = mastodonController
|
||||||
|
|
||||||
super.init(style: .plain)
|
super.init(style: .plain)
|
||||||
|
@ -117,59 +115,52 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
return cell
|
return cell
|
||||||
|
|
||||||
case let .expandThread(childThreads: childThreads, inline: inline):
|
case let .expandThread(childThreads: childThreads):
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: "expandThreadCell", for: indexPath) as! ExpandThreadTableViewCell
|
let cell = tableView.dequeueReusableCell(withIdentifier: "expandThreadCell", for: indexPath) as! ExpandThreadTableViewCell
|
||||||
cell.updateUI(childThreads: childThreads, inline: inline)
|
cell.updateUI(childThreads: childThreads)
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if #available(iOS 15.0, *) {
|
let initialImage = showStatusesAutomatically ? ConversationTableViewController.hidePostsImage : ConversationTableViewController.showPostsImage
|
||||||
visibilityBarButtonItem = UIBarButtonItem(image: ConversationTableViewController.showPostsImage, style: .plain, target: self, action: #selector(toggleVisibilityButtonPressed))
|
visibilityBarButtonItem = UIBarButtonItem(image: initialImage, style: .plain, target: self, action: #selector(toggleVisibilityButtonPressed))
|
||||||
visibilityBarButtonItem.isSelected = showStatusesAutomatically
|
|
||||||
} else {
|
|
||||||
let initialImage = showStatusesAutomatically ? ConversationTableViewController.hidePostsImage : ConversationTableViewController.showPostsImage
|
|
||||||
visibilityBarButtonItem = UIBarButtonItem(image: initialImage, style: .plain, target: self, action: #selector(toggleVisibilityButtonPressed))
|
|
||||||
}
|
|
||||||
navigationItem.rightBarButtonItem = visibilityBarButtonItem
|
navigationItem.rightBarButtonItem = visibilityBarButtonItem
|
||||||
// disable transparent background when scroll to top because it looks weird when items earlier in the thread load in
|
|
||||||
// (it remains transparent slightly too long, resulting in a flash of the content under the transparent bar)
|
|
||||||
let appearance = UINavigationBarAppearance()
|
|
||||||
appearance.configureWithDefaultBackground()
|
|
||||||
navigationItem.scrollEdgeAppearance = appearance
|
|
||||||
|
|
||||||
Task {
|
loadMainStatus()
|
||||||
await loadMainStatus()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
private func loadMainStatus() {
|
||||||
private func loadMainStatus() async {
|
|
||||||
guard loadingState == .unloaded else { return }
|
guard loadingState == .unloaded else { return }
|
||||||
|
|
||||||
if let mainStatus = mastodonController.persistentContainer.status(for: mainStatusID) {
|
if let mainStatus = mastodonController.persistentContainer.status(for: mainStatusID) {
|
||||||
await mainStatusLoaded(mainStatus)
|
self.mainStatusLoaded(mainStatus)
|
||||||
} else {
|
} else {
|
||||||
loadingState = .loadingMain
|
loadingState = .loadingMain
|
||||||
let req = Client.getStatus(id: mainStatusID)
|
let request = Client.getStatus(id: mainStatusID)
|
||||||
do {
|
mastodonController.run(request) { (response) in
|
||||||
let (status, _) = try await mastodonController.run(req)
|
switch response {
|
||||||
let statusMO = mastodonController.persistentContainer.addOrUpdateOnViewContext(status: status)
|
case let .success(status, _):
|
||||||
await mainStatusLoaded(statusMO)
|
let viewContext = self.mastodonController.persistentContainer.viewContext
|
||||||
} catch {
|
self.mastodonController.persistentContainer.addOrUpdate(status: status, context: viewContext) { (statusMO) in
|
||||||
let error = error as! Client.Error
|
self.mainStatusLoaded(statusMO)
|
||||||
loadingState = .unloaded
|
}
|
||||||
let config = ToastConfiguration(from: error, with: "Error Loading Status", in: self) { [weak self] toast in
|
|
||||||
toast.dismissToast(animated: true)
|
case let .failure(error):
|
||||||
await self?.loadMainStatus()
|
DispatchQueue.main.async {
|
||||||
|
self.loadingState = .unloaded
|
||||||
|
|
||||||
|
let config = ToastConfiguration(from: error, with: "Error Loading Status", in: self) { [weak self] (toast) in
|
||||||
|
toast.dismissToast(animated: true)
|
||||||
|
self?.loadMainStatus()
|
||||||
|
}
|
||||||
|
self.showToast(configuration: config, animated: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
showToast(configuration: config, animated: true)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func mainStatusLoaded(_ mainStatus: StatusMO) async {
|
private func mainStatusLoaded(_ mainStatus: StatusMO) {
|
||||||
let mainStatusItem = Item.status(id: mainStatusID, state: mainStatusState)
|
let mainStatusItem = Item.status(id: mainStatusID, state: mainStatusState)
|
||||||
|
|
||||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||||
|
@ -179,11 +170,10 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
loadingState = .loadedMain
|
loadingState = .loadedMain
|
||||||
|
|
||||||
await loadContext(for: mainStatus)
|
loadContext(for: mainStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
private func loadContext(for mainStatus: StatusMO) {
|
||||||
private func loadContext(for mainStatus: StatusMO) async {
|
|
||||||
guard loadingState == .loadedMain else { return }
|
guard loadingState == .loadedMain else { return }
|
||||||
|
|
||||||
loadingState = .loadingContext
|
loadingState = .loadingContext
|
||||||
|
@ -193,24 +183,30 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
// todo: it would be nice to cache these contexts
|
// todo: it would be nice to cache these contexts
|
||||||
let request = Status.getContext(mainStatusID)
|
let request = Status.getContext(mainStatusID)
|
||||||
do {
|
mastodonController.run(request) { response in
|
||||||
let (context, _) = try await mastodonController.run(request)
|
switch response {
|
||||||
let parentIDs = self.getDirectParents(inReplyTo: mainStatusInReplyToID, from: context.ancestors)
|
case let .success(context, _):
|
||||||
let parentStatuses = context.ancestors.filter { parentIDs.contains($0.id) }
|
let parentIDs = self.getDirectParents(inReplyTo: mainStatusInReplyToID, from: context.ancestors)
|
||||||
|
let parentStatuses = context.ancestors.filter { parentIDs.contains($0.id) }
|
||||||
// todo: should this really be blindly adding all the descendants?
|
|
||||||
await mastodonController.persistentContainer.addAll(statuses: parentStatuses + context.descendants)
|
|
||||||
self.contextLoaded(mainStatus: mainStatus, context: context, parentIDs: parentIDs)
|
|
||||||
|
|
||||||
} catch {
|
|
||||||
let error = error as! Client.Error
|
|
||||||
self.loadingState = .loadedMain
|
|
||||||
|
|
||||||
let config = ToastConfiguration(from: error, with: "Error Loading Content", in: self) { [weak self] (toast) in
|
// todo: should this really be blindly adding all the descendants?
|
||||||
toast.dismissToast(animated: true)
|
self.mastodonController.persistentContainer.addAll(statuses: parentStatuses + context.descendants) {
|
||||||
await self?.loadContext(for: mainStatus)
|
DispatchQueue.main.async {
|
||||||
|
self.contextLoaded(mainStatus: mainStatus, context: context, parentIDs: parentIDs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case let .failure(error):
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.loadingState = .loadedMain
|
||||||
|
|
||||||
|
let config = ToastConfiguration(from: error, with: "Error Loading Content", in: self) { [weak self] (toast) in
|
||||||
|
toast.dismissToast(animated: true)
|
||||||
|
self?.loadContext(for: mainStatus)
|
||||||
|
}
|
||||||
|
self.showToast(configuration: config, animated: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.showToast(configuration: config, animated: true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,19 +230,10 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dataSource.apply(snapshot, animatingDifferences: false) {
|
self.dataSource.apply(snapshot, animatingDifferences: false) {
|
||||||
let item: Item
|
// ensure that the main status is on-screen after newly loaded statuses are added
|
||||||
let position: UITableView.ScrollPosition
|
|
||||||
if self.statusIDToScrollToOnLoad == self.mainStatusID {
|
|
||||||
item = mainStatusItem
|
|
||||||
position = .middle
|
|
||||||
} else {
|
|
||||||
item = Item.status(id: self.statusIDToScrollToOnLoad, state: .unknown)
|
|
||||||
position = .top
|
|
||||||
}
|
|
||||||
// ensure that the status is on-screen after newly loaded statuses are added
|
|
||||||
// todo: should this not happen if the user has already started scrolling (e.g. because the main status is very long)?
|
// todo: should this not happen if the user has already started scrolling (e.g. because the main status is very long)?
|
||||||
if let indexPath = self.dataSource.indexPath(for: item) {
|
if let indexPath = self.dataSource.indexPath(for: mainStatusItem) {
|
||||||
self.tableView.scrollToRow(at: indexPath, at: position, animated: false)
|
self.tableView.scrollToRow(at: indexPath, at: .middle, animated: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,10 +314,8 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
let sameAuthorStatuses = currentNode.children.filter({ $0.status.account.id == node.status.account.id })
|
let sameAuthorStatuses = currentNode.children.filter({ $0.status.account.id == node.status.account.id })
|
||||||
if sameAuthorStatuses.count == 1 {
|
if sameAuthorStatuses.count == 1 {
|
||||||
next = sameAuthorStatuses[0]
|
next = sameAuthorStatuses[0]
|
||||||
let nonSameAuthorChildren = currentNode.children.filter { $0.status.id != sameAuthorStatuses[0].status.id }
|
|
||||||
snapshot.appendItems([.expandThread(childThreads: nonSameAuthorChildren, inline: true)])
|
|
||||||
} else {
|
} else {
|
||||||
snapshot.appendItems([.expandThread(childThreads: currentNode.children, inline: false)])
|
snapshot.appendItems([.expandThread(childThreads: currentNode.children)])
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,11 +340,9 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
// MARK: - Table view delegate
|
// MARK: - Table view delegate
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
if case let .expandThread(childThreads: childThreads, inline: _) = dataSource.itemIdentifier(for: indexPath),
|
if case .expandThread = dataSource.itemIdentifier(for: indexPath),
|
||||||
case let .status(id: id, state: state) = dataSource.itemIdentifier(for: IndexPath(row: indexPath.row - 1, section: indexPath.section)) {
|
case let .status(id: id, state: state) = dataSource.itemIdentifier(for: IndexPath(row: indexPath.row - 1, section: indexPath.section)) {
|
||||||
let conv = ConversationTableViewController(for: id, state: state, mastodonController: mastodonController)
|
self.selected(status: id, state: state)
|
||||||
conv.statusIDToScrollToOnLoad = childThreads.first!.status.id
|
|
||||||
show(conv)
|
|
||||||
} else {
|
} else {
|
||||||
super.tableView(tableView, didSelectRowAt: indexPath)
|
super.tableView(tableView, didSelectRowAt: indexPath)
|
||||||
}
|
}
|
||||||
|
@ -416,14 +399,14 @@ extension ConversationTableViewController {
|
||||||
}
|
}
|
||||||
enum Item: Hashable {
|
enum Item: Hashable {
|
||||||
case status(id: String, state: StatusState)
|
case status(id: String, state: StatusState)
|
||||||
case expandThread(childThreads: [ConversationNode], inline: Bool)
|
case expandThread(childThreads: [ConversationNode])
|
||||||
|
|
||||||
static func == (lhs: Item, rhs: Item) -> Bool {
|
static func == (lhs: Item, rhs: Item) -> Bool {
|
||||||
switch (lhs, rhs) {
|
switch (lhs, rhs) {
|
||||||
case let (.status(id: a, state: _), .status(id: b, state: _)):
|
case let (.status(id: a, state: _), .status(id: b, state: _)):
|
||||||
return a == b
|
return a == b
|
||||||
case let (.expandThread(childThreads: a, inline: aInline), .expandThread(childThreads: b, inline: bInline)):
|
case let (.expandThread(childThreads: a), .expandThread(childThreads: b)):
|
||||||
return zip(a, b).allSatisfy { $0.status.id == $1.status.id } && aInline == bInline
|
return zip(a, b).allSatisfy { $0.status.id == $1.status.id }
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -434,10 +417,9 @@ extension ConversationTableViewController {
|
||||||
case let .status(id: id, state: _):
|
case let .status(id: id, state: _):
|
||||||
hasher.combine("status")
|
hasher.combine("status")
|
||||||
hasher.combine(id)
|
hasher.combine(id)
|
||||||
case let .expandThread(childThreads: children, inline: inline):
|
case let .expandThread(childThreads: children):
|
||||||
hasher.combine("expandThread")
|
hasher.combine("expandThread")
|
||||||
hasher.combine(children.map(\.status.id))
|
hasher.combine(children.map(\.status.id))
|
||||||
hasher.combine(inline)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,49 +10,34 @@ import UIKit
|
||||||
|
|
||||||
class ExpandThreadTableViewCell: UITableViewCell {
|
class ExpandThreadTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
@IBOutlet weak var stackViewLeadingConstraint: NSLayoutConstraint!
|
|
||||||
@IBOutlet weak var avatarContainerView: UIView!
|
@IBOutlet weak var avatarContainerView: UIView!
|
||||||
@IBOutlet weak var avatarContainerWidthConstraint: NSLayoutConstraint!
|
@IBOutlet weak var avatarContainerWidthConstraint: NSLayoutConstraint!
|
||||||
@IBOutlet weak var replyCountLabel: UILabel!
|
@IBOutlet weak var replyCountLabel: UILabel!
|
||||||
private var threadLinkView: UIView!
|
var avatarImageViews: [UIImageView] = []
|
||||||
private var threadLinkViewFullHeightConstraint: NSLayoutConstraint!
|
|
||||||
private var threadLinkViewShortHeightConstraint: NSLayoutConstraint!
|
|
||||||
private var avatarImageViews: [UIImageView] = []
|
|
||||||
|
|
||||||
private var avatarRequests: [ImageCache.Request] = []
|
private var avatarRequests: [ImageCache.Request] = []
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
|
|
||||||
threadLinkView = UIView()
|
let prevThreadLinkView = UIView()
|
||||||
threadLinkView.translatesAutoresizingMaskIntoConstraints = false
|
prevThreadLinkView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
threadLinkView.backgroundColor = tintColor.withAlphaComponent(0.5)
|
prevThreadLinkView.backgroundColor = tintColor.withAlphaComponent(0.5)
|
||||||
threadLinkView.layer.cornerRadius = 2.5
|
prevThreadLinkView.layer.cornerRadius = 2.5
|
||||||
addSubview(threadLinkView)
|
prevThreadLinkView.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
|
||||||
threadLinkViewFullHeightConstraint = threadLinkView.bottomAnchor.constraint(equalTo: bottomAnchor)
|
contentView.addSubview(prevThreadLinkView)
|
||||||
threadLinkViewShortHeightConstraint = threadLinkView.bottomAnchor.constraint(equalTo: avatarContainerView.topAnchor, constant: -2)
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
threadLinkView.widthAnchor.constraint(equalToConstant: 5),
|
prevThreadLinkView.widthAnchor.constraint(equalToConstant: 5),
|
||||||
threadLinkView.centerXAnchor.constraint(equalTo: leadingAnchor, constant: 25 + 16 /* system spacing */),
|
prevThreadLinkView.centerXAnchor.constraint(equalTo: leadingAnchor, constant: 16 + 25),
|
||||||
threadLinkView.topAnchor.constraint(equalTo: topAnchor),
|
prevThreadLinkView.topAnchor.constraint(equalTo: topAnchor),
|
||||||
threadLinkViewFullHeightConstraint,
|
prevThreadLinkView.bottomAnchor.constraint(equalTo: avatarContainerView.topAnchor, constant: -2),
|
||||||
])
|
])
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUI(childThreads: [ConversationNode], inline: Bool) {
|
func updateUI(childThreads: [ConversationNode]) {
|
||||||
stackViewLeadingConstraint.constant = inline ? 50 + 4 : 0
|
let format = NSLocalizedString("expand threads count", comment: "expand conversation threads button label")
|
||||||
threadLinkView.layer.maskedCorners = inline ? [] : [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
|
|
||||||
threadLinkViewFullHeightConstraint.isActive = inline
|
|
||||||
threadLinkViewShortHeightConstraint.isActive = !inline
|
|
||||||
|
|
||||||
let format: String
|
|
||||||
if inline {
|
|
||||||
format = NSLocalizedString("expand threads inline count", comment: "expnad converstaion threads inline button label")
|
|
||||||
} else {
|
|
||||||
format = NSLocalizedString("expand threads count", comment: "expand conversation threads button label")
|
|
||||||
}
|
|
||||||
replyCountLabel.text = String.localizedStringWithFormat(format, childThreads.count)
|
replyCountLabel.text = String.localizedStringWithFormat(format, childThreads.count)
|
||||||
|
|
||||||
let accounts = childThreads.map(\.status.account).uniques().prefix(3)
|
let accounts = childThreads.map(\.status.account).uniques().prefix(3)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="iOS"/>
|
<deployment identifier="iOS"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
|
||||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
@ -62,7 +62,6 @@
|
||||||
<outlet property="avatarContainerView" destination="eFB-F1-d3A" id="xGo-40-nn7"/>
|
<outlet property="avatarContainerView" destination="eFB-F1-d3A" id="xGo-40-nn7"/>
|
||||||
<outlet property="avatarContainerWidthConstraint" destination="tiI-Rj-gjh" id="34n-ev-EKi"/>
|
<outlet property="avatarContainerWidthConstraint" destination="tiI-Rj-gjh" id="34n-ev-EKi"/>
|
||||||
<outlet property="replyCountLabel" destination="Dcm-ll-GeE" id="E4m-xk-DiQ"/>
|
<outlet property="replyCountLabel" destination="Dcm-ll-GeE" id="E4m-xk-DiQ"/>
|
||||||
<outlet property="stackViewLeadingConstraint" destination="iD5-Av-ORS" id="Try-cG-8uA"/>
|
|
||||||
</connections>
|
</connections>
|
||||||
<point key="canvasLocation" x="132" y="132"/>
|
<point key="canvasLocation" x="132" y="132"/>
|
||||||
</tableViewCell>
|
</tableViewCell>
|
||||||
|
|
|
@ -123,7 +123,6 @@ extension DraftsTableViewController: UITableViewDragDelegate {
|
||||||
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||||
let draft = self.draft(for: indexPath)
|
let draft = self.draft(for: indexPath)
|
||||||
let activity = UserActivityManager.editDraftActivity(id: draft.id, accountID: account.id)
|
let activity = UserActivityManager.editDraftActivity(id: draft.id, accountID: account.id)
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
let provider = NSItemProvider(object: activity)
|
let provider = NSItemProvider(object: activity)
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -574,17 +574,13 @@ extension ExploreViewController: UICollectionViewDragDelegate {
|
||||||
let provider: NSItemProvider
|
let provider: NSItemProvider
|
||||||
switch item {
|
switch item {
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
let activity = UserActivityManager.bookmarksActivity()
|
provider = NSItemProvider(object: UserActivityManager.bookmarksActivity())
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider = NSItemProvider(object: activity)
|
|
||||||
case let .list(list):
|
case let .list(list):
|
||||||
guard let activity = UserActivityManager.showTimelineActivity(timeline: .list(id: list.id), accountID: accountID) else { return [] }
|
guard let activity = UserActivityManager.showTimelineActivity(timeline: .list(id: list.id), accountID: accountID) else { return [] }
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider = NSItemProvider(object: activity)
|
provider = NSItemProvider(object: activity)
|
||||||
case let .savedHashtag(hashtag):
|
case let .savedHashtag(hashtag):
|
||||||
provider = NSItemProvider(object: hashtag.url as NSURL)
|
provider = NSItemProvider(object: hashtag.url as NSURL)
|
||||||
if let activity = UserActivityManager.showTimelineActivity(timeline: .tag(hashtag: hashtag.name), accountID: accountID) {
|
if let activity = UserActivityManager.showTimelineActivity(timeline: .tag(hashtag: hashtag.name), accountID: accountID) {
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider.registerObject(activity, visibility: .all)
|
provider.registerObject(activity, visibility: .all)
|
||||||
}
|
}
|
||||||
case let .savedInstance(url):
|
case let .savedInstance(url):
|
||||||
|
|
|
@ -183,7 +183,6 @@ extension ProfileDirectoryViewController: UICollectionViewDragDelegate {
|
||||||
}
|
}
|
||||||
let provider = NSItemProvider(object: account.url as NSURL)
|
let provider = NSItemProvider(object: account.url as NSURL)
|
||||||
let activity = UserActivityManager.showProfileActivity(id: account.id, accountID: currentAccountID)
|
let activity = UserActivityManager.showProfileActivity(id: account.id, accountID: currentAccountID)
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider.registerObject(activity, visibility: .all)
|
provider.registerObject(activity, visibility: .all)
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,6 @@ class TrendingHashtagsViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
let provider = NSItemProvider(object: hashtag.url as NSURL)
|
let provider = NSItemProvider(object: hashtag.url as NSURL)
|
||||||
if let activity = UserActivityManager.showTimelineActivity(timeline: .tag(hashtag: hashtag.name), accountID: mastodonController.accountInfo!.id) {
|
if let activity = UserActivityManager.showTimelineActivity(timeline: .tag(hashtag: hashtag.name), accountID: mastodonController.accountInfo!.id) {
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider.registerObject(activity, visibility: .all)
|
provider.registerObject(activity, visibility: .all)
|
||||||
}
|
}
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
|
|
|
@ -19,11 +19,6 @@ class MainSidebarViewController: UIViewController {
|
||||||
private weak var mastodonController: MastodonController!
|
private weak var mastodonController: MastodonController!
|
||||||
|
|
||||||
weak var sidebarDelegate: MainSidebarViewControllerDelegate?
|
weak var sidebarDelegate: MainSidebarViewControllerDelegate?
|
||||||
var onViewDidLoad: (() -> Void)? = nil {
|
|
||||||
willSet {
|
|
||||||
precondition(onViewDidLoad == nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var collectionView: UICollectionView!
|
private var collectionView: UICollectionView!
|
||||||
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
||||||
|
@ -100,8 +95,6 @@ class MainSidebarViewController: UIViewController {
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(reloadSavedHashtags), name: .savedHashtagsChanged, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(reloadSavedHashtags), name: .savedHashtagsChanged, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(reloadSavedInstances), name: .savedInstancesChanged, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(reloadSavedInstances), name: .savedInstancesChanged, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
||||||
|
|
||||||
onViewDidLoad?()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func select(item: Item, animated: Bool) {
|
func select(item: Item, animated: Bool) {
|
||||||
|
@ -560,7 +553,6 @@ extension MainSidebarViewController: UICollectionViewDelegate {
|
||||||
collectionView.contextMenuInteraction?.menuAppearance == .rich {
|
collectionView.contextMenuInteraction?.menuAppearance == .rich {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { (_) in
|
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { (_) in
|
||||||
return UIMenu(children: [
|
return UIMenu(children: [
|
||||||
UIWindowScene.ActivationAction({ action in
|
UIWindowScene.ActivationAction({ action in
|
||||||
|
@ -581,7 +573,6 @@ extension MainSidebarViewController: UICollectionViewDragDelegate {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
let provider = NSItemProvider(object: activity)
|
let provider = NSItemProvider(object: activity)
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,15 +59,10 @@ class MainSplitViewController: UISplitViewController {
|
||||||
switcher.itemOrientation = .iconsLeading
|
switcher.itemOrientation = .iconsLeading
|
||||||
switcher.view.translatesAutoresizingMaskIntoConstraints = false
|
switcher.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
switcher.delegate = self
|
switcher.delegate = self
|
||||||
// accessing .view unconditionally loads the view, which we don't want to happen
|
sidebar.view.addGestureRecognizer(switcher.createSwitcherGesture())
|
||||||
// because the sidebar view not being loaded is how we know not to transfer nav state
|
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(sidebarTapped))
|
||||||
// in splitViewControllerDidCollapse on devices where the sidebar is never shown
|
tapRecognizer.cancelsTouchesInView = false
|
||||||
sidebar.onViewDidLoad = { [unowned self] in
|
sidebar.view.addGestureRecognizer(tapRecognizer)
|
||||||
self.sidebar.view.addGestureRecognizer(switcher.createSwitcherGesture())
|
|
||||||
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(sidebarTapped))
|
|
||||||
tapRecognizer.cancelsTouchesInView = false
|
|
||||||
self.sidebar.view.addGestureRecognizer(tapRecognizer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tabBarViewController = MainTabBarViewController(mastodonController: mastodonController)
|
tabBarViewController = MainTabBarViewController(mastodonController: mastodonController)
|
||||||
|
|
|
@ -42,8 +42,6 @@ class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
stateRestorationLogger.info("MainTabBarViewController: viewDidLoad, selectedIndex=\(self.selectedIndex, privacy: .public)")
|
|
||||||
|
|
||||||
self.delegate = self
|
self.delegate = self
|
||||||
|
|
||||||
|
@ -77,16 +75,6 @@ class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {
|
||||||
tabBar.isSpringLoaded = true
|
tabBar.isSpringLoaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
|
||||||
super.viewWillAppear(animated)
|
|
||||||
stateRestorationLogger.info("MainTabBarViewController: viewWillAppear, selectedIndex=\(self.selectedIndex, privacy: .public)")
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
|
||||||
super.viewDidAppear(animated)
|
|
||||||
stateRestorationLogger.info("MainTabBarViewController: viewDidAppear, selectedIndex=\(self.selectedIndex, privacy: .public)")
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewDidLayoutSubviews() {
|
override func viewDidLayoutSubviews() {
|
||||||
super.viewDidLayoutSubviews()
|
super.viewDidLayoutSubviews()
|
||||||
|
|
||||||
|
@ -252,7 +240,6 @@ extension MainTabBarViewController: TuskerRootViewController {
|
||||||
self.selectedIndex = tab.rawValue
|
self.selectedIndex = tab.rawValue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stateRestorationLogger.info("MainTabBarViewController: selecting \(String(describing: tab), privacy: .public)")
|
|
||||||
selectedIndex = tab.rawValue
|
selectedIndex = tab.rawValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,25 +10,13 @@ import Foundation
|
||||||
|
|
||||||
extension NSUserActivity {
|
extension NSUserActivity {
|
||||||
|
|
||||||
var displaysAuxiliaryScene: Bool {
|
|
||||||
get {
|
|
||||||
(userInfo?["displaysAuxiliaryScene"] as? Bool) ?? false
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
if userInfo == nil {
|
|
||||||
userInfo = [:]
|
|
||||||
}
|
|
||||||
userInfo!["displaysAuxiliaryScene"] = newValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
convenience init(type: UserActivityType) {
|
convenience init(type: UserActivityType) {
|
||||||
self.init(activityType: type.rawValue)
|
self.init(activityType: type.rawValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleResume(manager: UserActivityManager) -> Bool {
|
func handleResume() -> Bool {
|
||||||
guard let type = UserActivityType(rawValue: activityType) else { return false }
|
guard let type = UserActivityType(rawValue: activityType) else { return false }
|
||||||
type.handle(manager)(self)
|
type.handle(self)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,32 +9,25 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
import Intents
|
import Intents
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
import OSLog
|
|
||||||
|
|
||||||
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "UserActivityManager")
|
|
||||||
|
|
||||||
class UserActivityManager {
|
class UserActivityManager {
|
||||||
|
|
||||||
private let scene: UIWindowScene
|
|
||||||
|
|
||||||
init(scene: UIWindowScene) {
|
|
||||||
self.scene = scene
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Utils
|
// MARK: - Utils
|
||||||
private static let encoder = PropertyListEncoder()
|
private static let encoder = PropertyListEncoder()
|
||||||
private static let decoder = PropertyListDecoder()
|
private static let decoder = PropertyListDecoder()
|
||||||
|
|
||||||
private var mastodonController: MastodonController {
|
private static var mastodonController: MastodonController {
|
||||||
scene.session.mastodonController!
|
let scene = UIApplication.shared.activeOrBackgroundScene!
|
||||||
|
return scene.session.mastodonController!
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getMainViewController() -> TuskerRootViewController {
|
private static func getMainViewController() -> TuskerRootViewController {
|
||||||
let window = scene.windows.first { $0.isKeyWindow } ?? scene.windows.first!
|
let scene = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.first!
|
||||||
|
let window = scene.windows.first { $0.isKeyWindow }!
|
||||||
return window.rootViewController as! TuskerRootViewController
|
return window.rootViewController as! TuskerRootViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
private func present(_ vc: UIViewController, animated: Bool = true) {
|
private static func present(_ vc: UIViewController, animated: Bool = true) {
|
||||||
getMainViewController().present(vc, animated: animated)
|
getMainViewController().present(vc, animated: animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +66,7 @@ class UserActivityManager {
|
||||||
return activity
|
return activity
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleNewPost(activity: NSUserActivity) {
|
static func handleNewPost(activity: NSUserActivity) {
|
||||||
// TODO: check not currently showing compose screen
|
// TODO: check not currently showing compose screen
|
||||||
let mentioning = activity.userInfo?["mentioning"] as? String
|
let mentioning = activity.userInfo?["mentioning"] as? String
|
||||||
let draft = mastodonController.createDraft(mentioningAcct: mentioning)
|
let draft = mastodonController.createDraft(mentioningAcct: mentioning)
|
||||||
|
@ -118,14 +111,14 @@ class UserActivityManager {
|
||||||
return activity
|
return activity
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleCheckNotifications(activity: NSUserActivity) {
|
static func handleCheckNotifications(activity: NSUserActivity) {
|
||||||
let mainViewController = getMainViewController()
|
let mainViewController = getMainViewController()
|
||||||
mainViewController.select(tab: .notifications)
|
mainViewController.select(tab: .notifications)
|
||||||
if let navigationController = mainViewController.getTabController(tab: .notifications) as? UINavigationController,
|
if let navigationController = mainViewController.getTabController(tab: .notifications) as? UINavigationController,
|
||||||
let notificationsPageController = navigationController.viewControllers.first as? NotificationsPageViewController {
|
let notificationsPageController = navigationController.viewControllers.first as? NotificationsPageViewController {
|
||||||
navigationController.popToRootViewController(animated: false)
|
navigationController.popToRootViewController(animated: false)
|
||||||
notificationsPageController.loadViewIfNeeded()
|
notificationsPageController.loadViewIfNeeded()
|
||||||
notificationsPageController.selectMode(Self.getNotificationsMode(from: activity) ?? Preferences.shared.defaultNotificationsMode)
|
notificationsPageController.selectMode(getNotificationsMode(from: activity) ?? Preferences.shared.defaultNotificationsMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,11 +168,11 @@ class UserActivityManager {
|
||||||
let data = activity.userInfo?["timelineData"] as? Data else {
|
let data = activity.userInfo?["timelineData"] as? Data else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return try? UserActivityManager.decoder.decode(Timeline.self, from: data)
|
return try? decoder.decode(Timeline.self, from: data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleShowTimeline(activity: NSUserActivity) {
|
static func handleShowTimeline(activity: NSUserActivity) {
|
||||||
guard let timeline = Self.getTimeline(from: activity) else { return }
|
guard let timeline = getTimeline(from: activity) else { return }
|
||||||
|
|
||||||
let mainViewController = getMainViewController()
|
let mainViewController = getMainViewController()
|
||||||
mainViewController.select(tab: .timelines)
|
mainViewController.select(tab: .timelines)
|
||||||
|
@ -235,7 +228,7 @@ class UserActivityManager {
|
||||||
return activity
|
return activity
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleSearch(activity: NSUserActivity) {
|
static func handleSearch(activity: NSUserActivity) {
|
||||||
let mainViewController = getMainViewController()
|
let mainViewController = getMainViewController()
|
||||||
mainViewController.select(tab: .explore)
|
mainViewController.select(tab: .explore)
|
||||||
if let navigationController = mainViewController.getTabController(tab: .explore) as? UINavigationController,
|
if let navigationController = mainViewController.getTabController(tab: .explore) as? UINavigationController,
|
||||||
|
@ -254,7 +247,7 @@ class UserActivityManager {
|
||||||
return activity
|
return activity
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleBookmarks(activity: NSUserActivity) {
|
static func handleBookmarks(activity: NSUserActivity) {
|
||||||
let mainViewController = getMainViewController()
|
let mainViewController = getMainViewController()
|
||||||
mainViewController.select(tab: .explore)
|
mainViewController.select(tab: .explore)
|
||||||
if let navigationController = mainViewController.getTabController(tab: .explore) as? UINavigationController {
|
if let navigationController = mainViewController.getTabController(tab: .explore) as? UINavigationController {
|
||||||
|
@ -272,7 +265,7 @@ class UserActivityManager {
|
||||||
return activity
|
return activity
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMyProfile(activity: NSUserActivity) {
|
static func handleMyProfile(activity: NSUserActivity) {
|
||||||
let mainViewController = getMainViewController()
|
let mainViewController = getMainViewController()
|
||||||
mainViewController.select(tab: .myProfile)
|
mainViewController.select(tab: .myProfile)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ enum UserActivityType: String {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UserActivityType {
|
extension UserActivityType {
|
||||||
var handle: (UserActivityManager) -> (NSUserActivity) -> Void {
|
var handle: (NSUserActivity) -> Void {
|
||||||
switch self {
|
switch self {
|
||||||
case .mainScene:
|
case .mainScene:
|
||||||
fatalError("cannot handle main scene activity")
|
fatalError("cannot handle main scene activity")
|
||||||
|
|
|
@ -115,7 +115,6 @@ extension AccountTableViewCell: DraggableTableViewCell {
|
||||||
}
|
}
|
||||||
let provider = NSItemProvider(object: account.url as NSURL)
|
let provider = NSItemProvider(object: account.url as NSURL)
|
||||||
let activity = UserActivityManager.showProfileActivity(id: account.id, accountID: currentAccountID)
|
let activity = UserActivityManager.showProfileActivity(id: account.id, accountID: currentAccountID)
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider.registerObject(activity, visibility: .all)
|
provider.registerObject(activity, visibility: .all)
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,6 @@ extension FollowNotificationGroupTableViewCell: DraggableTableViewCell {
|
||||||
let notification = group.notifications[0]
|
let notification = group.notifications[0]
|
||||||
let provider = NSItemProvider(object: notification.account.url as NSURL)
|
let provider = NSItemProvider(object: notification.account.url as NSURL)
|
||||||
let activity = UserActivityManager.showProfileActivity(id: notification.account.id, accountID: mastodonController.accountInfo!.id)
|
let activity = UserActivityManager.showProfileActivity(id: notification.account.id, accountID: mastodonController.accountInfo!.id)
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider.registerObject(activity, visibility: .all)
|
provider.registerObject(activity, visibility: .all)
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,6 @@ extension FollowRequestNotificationTableViewCell: DraggableTableViewCell {
|
||||||
func dragItemsForBeginning(session: UIDragSession) -> [UIDragItem] {
|
func dragItemsForBeginning(session: UIDragSession) -> [UIDragItem] {
|
||||||
let provider = NSItemProvider(object: account.url as NSURL)
|
let provider = NSItemProvider(object: account.url as NSURL)
|
||||||
let activity = UserActivityManager.showProfileActivity(id: account.id, accountID: mastodonController.accountInfo!.id)
|
let activity = UserActivityManager.showProfileActivity(id: account.id, accountID: mastodonController.accountInfo!.id)
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider.registerObject(activity, visibility: .all)
|
provider.registerObject(activity, visibility: .all)
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ class StatusPollView: UIView {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
weak var mastodonController: MastodonController!
|
weak var mastodonController: MastodonController!
|
||||||
weak var toastableViewController: ToastableViewController?
|
|
||||||
|
|
||||||
private var statusID: String!
|
private var statusID: String!
|
||||||
private(set) var poll: Poll?
|
private(set) var poll: Poll?
|
||||||
|
@ -152,14 +151,7 @@ class StatusPollView: UIView {
|
||||||
mastodonController.run(request) { (response) in
|
mastodonController.run(request) { (response) in
|
||||||
switch response {
|
switch response {
|
||||||
case let .failure(error):
|
case let .failure(error):
|
||||||
DispatchQueue.main.async {
|
fatalError("error voting in poll: \(error)")
|
||||||
self.updateUI(status: self.mastodonController.persistentContainer.status(for: self.statusID)!, poll: self.poll)
|
|
||||||
|
|
||||||
if let toastable = self.toastableViewController {
|
|
||||||
let config = ToastConfiguration(from: error, with: "Error Voting", in: toastable, retryAction: nil)
|
|
||||||
toastable.showToast(configuration: config, animated: true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case let .success(poll, _):
|
case let .success(poll, _):
|
||||||
let container = self.mastodonController.persistentContainer
|
let container = self.mastodonController.persistentContainer
|
||||||
|
|
|
@ -211,7 +211,6 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
pollView.isHidden = status.poll == nil
|
pollView.isHidden = status.poll == nil
|
||||||
pollView.mastodonController = mastodonController
|
pollView.mastodonController = mastodonController
|
||||||
pollView.toastableViewController = delegate?.toastableViewController
|
|
||||||
pollView.updateUI(status: status, poll: status.poll)
|
pollView.updateUI(status: status, poll: status.poll)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +530,6 @@ extension BaseStatusTableViewCell: UIDragInteractionDelegate {
|
||||||
}
|
}
|
||||||
let provider = NSItemProvider(object: account.url as NSURL)
|
let provider = NSItemProvider(object: account.url as NSURL)
|
||||||
let activity = UserActivityManager.showProfileActivity(id: accountID, accountID: currentAccountID)
|
let activity = UserActivityManager.showProfileActivity(id: accountID, accountID: currentAccountID)
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider.registerObject(activity, visibility: .all)
|
provider.registerObject(activity, visibility: .all)
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,7 +356,6 @@ extension TimelineStatusTableViewCell: DraggableTableViewCell {
|
||||||
}
|
}
|
||||||
let provider = NSItemProvider(object: status.url! as NSURL)
|
let provider = NSItemProvider(object: status.url! as NSURL)
|
||||||
let activity = UserActivityManager.showConversationActivity(mainStatusID: status.id, accountID: accountID)
|
let activity = UserActivityManager.showConversationActivity(mainStatusID: status.id, accountID: accountID)
|
||||||
activity.displaysAuxiliaryScene = true
|
|
||||||
provider.registerObject(activity, visibility: .all)
|
provider.registerObject(activity, visibility: .all)
|
||||||
return [UIDragItem(itemProvider: provider)]
|
return [UIDragItem(itemProvider: provider)]
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,14 +57,6 @@ extension ToastConfiguration {
|
||||||
viewController.present(reporter, animated: true)
|
viewController.present(reporter, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init(from error: Client.Error, with title: String, in viewController: UIViewController, retryAction: @escaping @MainActor (ToastView) async -> Void) {
|
|
||||||
self.init(from: error, with: title, in: viewController) { toast in
|
|
||||||
Task {
|
|
||||||
await retryAction(toast)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate extension Client.Error {
|
fileprivate extension Client.Error {
|
||||||
|
|
|
@ -61,22 +61,6 @@
|
||||||
<string>%u replies</string>
|
<string>%u replies</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>expand threads inline count</key>
|
|
||||||
<dict>
|
|
||||||
<key>NSStringLocalizedFormatKey</key>
|
|
||||||
<string>%#@replies@</string>
|
|
||||||
<key>replies</key>
|
|
||||||
<dict>
|
|
||||||
<key>NSStringFormatSpecTypeKey</key>
|
|
||||||
<string>NSStringPluralRuleType</string>
|
|
||||||
<key>NSStringFormatValueTypeKey</key>
|
|
||||||
<string>u</string>
|
|
||||||
<key>one</key>
|
|
||||||
<string>1 more reply</string>
|
|
||||||
<key>other</key>
|
|
||||||
<string>%u more replies</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<key>favorites count</key>
|
<key>favorites count</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSStringLocalizedFormatKey</key>
|
<key>NSStringLocalizedFormatKey</key>
|
||||||
|
|
Loading…
Reference in New Issue