diff --git a/elpha-ios/AccountTableViewController.swift b/elpha-ios/AccountTableViewController.swift index c8a6c8a..a5ec613 100644 --- a/elpha-ios/AccountTableViewController.swift +++ b/elpha-ios/AccountTableViewController.swift @@ -176,15 +176,24 @@ class AccountTableViewController: AbstractStatusTableViewController { override func loadMoreTapped(status: StatusMO, direction: PaginationDirection) { if let markers = status.markers { - markers.forEach { marker in + var removeAt = -1 + + for (index, marker) in markers.enumerated() { if marker.context == self.currentPaginationContext && marker.item.direction == direction { fetchStatuses(withPagination: marker.item) { error in - if error != nil { + if error == nil { + removeAt = index + } else { AlertManager.shared.show(message: error!.localizedDescription, category: .error) } } } } + + if removeAt > -1 { + status.markers?.remove(at: removeAt) + CoreDataManager.shared.saveContext() + } } } diff --git a/elpha-ios/Base.lproj/Main.storyboard b/elpha-ios/Base.lproj/Main.storyboard index bd3b80f..8bae72d 100644 --- a/elpha-ios/Base.lproj/Main.storyboard +++ b/elpha-ios/Base.lproj/Main.storyboard @@ -1352,189 +1352,81 @@ - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + - + - - + + @@ -1542,42 +1434,194 @@ - + - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + - - @@ -1590,15 +1634,17 @@ + + - + diff --git a/elpha-ios/InstanceViewController.swift b/elpha-ios/InstanceViewController.swift index a8b7e49..1a077da 100644 --- a/elpha-ios/InstanceViewController.swift +++ b/elpha-ios/InstanceViewController.swift @@ -6,7 +6,6 @@ // Copyright © 2018 Elpha. All rights reserved. // -import AlamofireImage import Kingfisher import UIKit import SafariServices diff --git a/elpha-ios/MainStatusTableViewCell.swift b/elpha-ios/MainStatusTableViewCell.swift index edd05e5..0f8dc7b 100644 --- a/elpha-ios/MainStatusTableViewCell.swift +++ b/elpha-ios/MainStatusTableViewCell.swift @@ -23,4 +23,6 @@ class MainStatusTableViewCell: UITableViewCell { @IBOutlet var timestampTimeLabel: UILabel! @IBOutlet var attachmentsView: UIView! @IBOutlet var contentTextView: UITextViewFixed! + @IBOutlet var inReplyToView: UIView! + @IBOutlet var repliesView: UIView! } diff --git a/elpha-ios/StatusTableViewController.swift b/elpha-ios/StatusTableViewController.swift index 6771f57..7ab6497 100644 --- a/elpha-ios/StatusTableViewController.swift +++ b/elpha-ios/StatusTableViewController.swift @@ -175,6 +175,12 @@ class StatusTableViewController: AbstractStatusTableViewController, UIGestureRec cell.statusView.topLoadMoreView.isHidden = true cell.statusView.bottomLoadMoreView.isHidden = true cell.statusView.replyView.isHidden = true + + let statusCount = fetchedResultsController?.fetchedObjects?.count ?? 0 + + if indexPath.row == statusCount - 1 { + cell.statusView.bottomDividerView.isHidden = true + } } func updateMainCell(_ cell: MainStatusTableViewCell, withStatus status: StatusMO) { @@ -237,6 +243,17 @@ class StatusTableViewController: AbstractStatusTableViewController, UIGestureRec } else { cell.favoritesImageView.image = UIImage(named: "Star Regular") } + + cell.inReplyToView.isHidden = true + cell.repliesView.isHidden = true + + if let ancestors = status.ancestors, ancestors.count > 0 { + cell.inReplyToView.isHidden = false + } + + if let descendants = status.descendants, descendants.count > 0 { + cell.repliesView.isHidden = false + } } } @@ -341,7 +358,6 @@ extension StatusTableViewController { updateMainCell(cell, withStatus: status) cell.contentTextView.delegate = self - return cell } else { guard let cell = tableView.dequeueReusableCell(withIdentifier: "StatusTableViewCell", for: indexPath) as? StatusTableViewCell else { diff --git a/elpha-ios/StatusView.xib b/elpha-ios/StatusView.xib index 5b6f198..43d1476 100644 --- a/elpha-ios/StatusView.xib +++ b/elpha-ios/StatusView.xib @@ -53,7 +53,7 @@ - + @@ -494,7 +494,7 @@ - + @@ -584,6 +584,9 @@ + + + diff --git a/elpha-ios/TimelineTableViewController.swift b/elpha-ios/TimelineTableViewController.swift index 3e6ff96..f043a87 100644 --- a/elpha-ios/TimelineTableViewController.swift +++ b/elpha-ios/TimelineTableViewController.swift @@ -84,15 +84,24 @@ class TimelineTableViewController: AbstractStatusTableViewController { override func loadMoreTapped(status: StatusMO, direction: PaginationDirection) { if let markers = status.markers { - markers.forEach { marker in + var removeAt = -1 + + for (index, marker) in markers.enumerated() { if marker.context == self.currentPaginationContext && marker.item.direction == direction { fetchTimeline(withPagination: marker.item) { error in - if error != nil { + if error == nil { + removeAt = index + } else { AlertManager.shared.show(message: error!.localizedDescription, category: .error) } } } } + + if removeAt > -1 { + status.markers?.remove(at: removeAt) + CoreDataManager.shared.saveContext() + } } }