Compare commits
No commits in common. "1d169bec6745dd6218b303883195eb3fe057d854" and "59277ec64f85a584dc46da5ca566331f7a51ddff" have entirely different histories.
1d169bec67
...
59277ec64f
|
@ -12,7 +12,7 @@ import Intents
|
||||||
|
|
||||||
class ComposeViewController: UIViewController {
|
class ComposeViewController: UIViewController {
|
||||||
|
|
||||||
weak var mastodonController: MastodonController!
|
let mastodonController: MastodonController
|
||||||
|
|
||||||
var inReplyToID: String?
|
var inReplyToID: String?
|
||||||
var accountsToMention = [String]()
|
var accountsToMention = [String]()
|
||||||
|
@ -457,7 +457,7 @@ class ComposeViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func draftsButtonPressed() {
|
@objc func draftsButtonPressed() {
|
||||||
let draftsVC = DraftsTableViewController(account: mastodonController.accountInfo!)
|
let draftsVC = DraftsTableViewController()
|
||||||
draftsVC.delegate = self
|
draftsVC.delegate = self
|
||||||
present(UINavigationController(rootViewController: draftsVC), animated: true)
|
present(UINavigationController(rootViewController: draftsVC), animated: true)
|
||||||
}
|
}
|
||||||
|
@ -623,7 +623,46 @@ extension ComposeViewController: DraftsTableViewControllerDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldSelectDraft(_ draft: DraftsManager.Draft, completion: @escaping (Bool) -> Void) {
|
func shouldSelectDraft(_ draft: DraftsManager.Draft, completion: @escaping (Bool) -> Void) {
|
||||||
if draft.inReplyToID != self.inReplyToID {
|
if draft.accountID != mastodonController.accountInfo!.id {
|
||||||
|
let currentAccount = mastodonController.accountInfo!
|
||||||
|
let currentAcct = "\(currentAccount.username)@\(currentAccount.instanceURL.host!)"
|
||||||
|
let otherAccount = LocalData.shared.getAccount(id: draft.accountID)
|
||||||
|
let otherAcct: String!
|
||||||
|
if let otherAccount = otherAccount {
|
||||||
|
otherAcct = "\(otherAccount.username)@\(otherAccount.instanceURL.host!)"
|
||||||
|
} else {
|
||||||
|
otherAcct = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if draft.inReplyToID != nil {
|
||||||
|
let message: String
|
||||||
|
if otherAccount != nil {
|
||||||
|
message = "The selected draft is a reply from a different account, it cannot be loaded from this account. To use it, switch accounts to \(otherAcct!)"
|
||||||
|
} else {
|
||||||
|
message = "The selected draft is a reply from an account that has been logged-out of. It cannot be loaded."
|
||||||
|
}
|
||||||
|
let alertController = UIAlertController(title: "Reply from Different Account", message: message, preferredStyle: .alert)
|
||||||
|
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in
|
||||||
|
completion(false)
|
||||||
|
}))
|
||||||
|
presentedViewController!.present(alertController, animated: true)
|
||||||
|
} else {
|
||||||
|
let message: String
|
||||||
|
if otherAccount != nil {
|
||||||
|
message = "The selected draft is from a different account (\(otherAcct!)) than your currently active account (\(currentAcct)). Do you wish to load it anyway?"
|
||||||
|
} else {
|
||||||
|
message = "The selected draft from an account that has been logged-out of."
|
||||||
|
}
|
||||||
|
let alertController = UIAlertController(title: "Draft from Different Account", message: message, preferredStyle: .alert)
|
||||||
|
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (_) in
|
||||||
|
completion(false)
|
||||||
|
}))
|
||||||
|
alertController.addAction(UIAlertAction(title: "Load Draft", style: .default, handler: { (_) in
|
||||||
|
completion(true)
|
||||||
|
}))
|
||||||
|
presentedViewController!.present(alertController, animated: true)
|
||||||
|
}
|
||||||
|
} else if draft.inReplyToID != self.inReplyToID {
|
||||||
let alertController = UIAlertController(title: "Different Reply", message: "The selected draft is a reply to a different status, do you wish to use it?", preferredStyle: .alert)
|
let alertController = UIAlertController(title: "Different Reply", message: "The selected draft is a reply to a different status, do you wish to use it?", preferredStyle: .alert)
|
||||||
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (_) in
|
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (_) in
|
||||||
completion(false)
|
completion(false)
|
||||||
|
|
|
@ -17,14 +17,9 @@ protocol DraftsTableViewControllerDelegate: class {
|
||||||
|
|
||||||
class DraftsTableViewController: UITableViewController {
|
class DraftsTableViewController: UITableViewController {
|
||||||
|
|
||||||
let account: LocalData.UserAccountInfo
|
|
||||||
weak var delegate: DraftsTableViewControllerDelegate?
|
weak var delegate: DraftsTableViewControllerDelegate?
|
||||||
|
|
||||||
var drafts = [DraftsManager.Draft]()
|
init() {
|
||||||
|
|
||||||
init(account: LocalData.UserAccountInfo) {
|
|
||||||
self.account = account
|
|
||||||
|
|
||||||
super.init(nibName: "DraftsTableViewController", bundle: nil)
|
super.init(nibName: "DraftsTableViewController", bundle: nil)
|
||||||
|
|
||||||
title = "Drafts"
|
title = "Drafts"
|
||||||
|
@ -42,14 +37,10 @@ class DraftsTableViewController: UITableViewController {
|
||||||
tableView.estimatedRowHeight = 140
|
tableView.estimatedRowHeight = 140
|
||||||
|
|
||||||
tableView.register(UINib(nibName: "DraftTableViewCell", bundle: nil), forCellReuseIdentifier: "draftCell")
|
tableView.register(UINib(nibName: "DraftTableViewCell", bundle: nil), forCellReuseIdentifier: "draftCell")
|
||||||
|
|
||||||
drafts = DraftsManager.shared.sorted.filter { (draft) in
|
|
||||||
draft.accountID == account.id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func draft(for indexPath: IndexPath) -> DraftsManager.Draft {
|
func draft(for indexPath: IndexPath) -> DraftsManager.Draft {
|
||||||
return drafts[indexPath.row]
|
return DraftsManager.shared.sorted[indexPath.row]
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Table View Data Source
|
// MARK: - Table View Data Source
|
||||||
|
@ -59,7 +50,7 @@ class DraftsTableViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||||
return drafts.count
|
return DraftsManager.shared.drafts.count
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||||
|
|
|
@ -95,6 +95,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateTimestamp() {
|
func updateTimestamp() {
|
||||||
|
guard superview != nil else { return }
|
||||||
guard let status = mastodonController.cache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
|
guard let status = mastodonController.cache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
|
||||||
|
|
||||||
timestampLabel.text = status.createdAt.timeAgoString()
|
timestampLabel.text = status.createdAt.timeAgoString()
|
||||||
|
|
Loading…
Reference in New Issue