diff --git a/CoreDataStack/Entity/Notification.swift b/CoreDataStack/Entity/Notification.swift index 144ad9c23..8a0595f6c 100644 --- a/CoreDataStack/Entity/Notification.swift +++ b/CoreDataStack/Entity/Notification.swift @@ -95,6 +95,6 @@ extension MastodonNotification { extension MastodonNotification: Managed { public static var defaultSortDescriptors: [NSSortDescriptor] { - return [NSSortDescriptor(keyPath: \MastodonNotification.updatedAt, ascending: false)] + return [NSSortDescriptor(keyPath: \MastodonNotification.createAt, ascending: false)] } } diff --git a/Mastodon/Diffiable/Section/NotificationSection.swift b/Mastodon/Diffiable/Section/NotificationSection.swift index de7f5d6c8..77e7ab5a5 100644 --- a/Mastodon/Diffiable/Section/NotificationSection.swift +++ b/Mastodon/Diffiable/Section/NotificationSection.swift @@ -70,9 +70,10 @@ extension NotificationSection { if let status = notification.status { let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: NotificationStatusTableViewCell.self), for: indexPath) as! NotificationStatusTableViewCell cell.delegate = delegate + let frame = CGRect(x: 0, y: 0, width: tableView.readableContentGuide.layoutFrame.width - NotificationStatusTableViewCell.statusPadding.left - NotificationStatusTableViewCell.statusPadding.right, height: tableView.readableContentGuide.layoutFrame.height) NotificationSection.configure(cell: cell, dependency: dependency, - readableLayoutFrame: nil, + readableLayoutFrame: frame, timestampUpdatePublisher: timestampUpdatePublisher, status: status, requestUserID: requestUserID, diff --git a/Mastodon/Scene/Notification/NotificationViewController.swift b/Mastodon/Scene/Notification/NotificationViewController.swift index d047a0a5d..0935c6e81 100644 --- a/Mastodon/Scene/Notification/NotificationViewController.swift +++ b/Mastodon/Scene/Notification/NotificationViewController.swift @@ -35,6 +35,7 @@ final class NotificationViewController: UIViewController, NeedsDependency { tableView.register(NotificationStatusTableViewCell.self, forCellReuseIdentifier: String(describing: NotificationStatusTableViewCell.self)) tableView.register(SearchBottomLoader.self, forCellReuseIdentifier: String(describing: SearchBottomLoader.self)) tableView.tableFooterView = UIView() + tableView.rowHeight = UITableView.automaticDimension return tableView }() @@ -135,9 +136,7 @@ extension NotificationViewController { // MARK: - UITableViewDelegate extension NotificationViewController: UITableViewDelegate { - func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { - return 68 - } + } // MARK: - ContentOffsetAdjustableTimelineViewControllerDelegate diff --git a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift index 1a0df283e..2b3b6972a 100644 --- a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift +++ b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift @@ -12,6 +12,7 @@ import UIKit final class NotificationStatusTableViewCell: UITableViewCell { static let actionImageBorderWidth: CGFloat = 2 + static let statusPadding: UIEdgeInsets = UIEdgeInsets(top: 50, left: 73, bottom: 24, right: 24) var disposeBag = Set() var delegate: NotificationTableViewCellDelegate? @@ -136,7 +137,7 @@ extension NotificationStatusTableViewCell { statusContainer.pin(top: 40, left: 63, bottom: 14, right: 14) contentView.addSubview(statusView) - statusView.pin(top: 40 + 12, left: 63 + 12, bottom: 14 + 12, right: 14 + 12) + statusView.pin(top: NotificationStatusTableViewCell.statusPadding.top, left: NotificationStatusTableViewCell.statusPadding.left, bottom: NotificationStatusTableViewCell.statusPadding.bottom, right: NotificationStatusTableViewCell.statusPadding.right) } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { diff --git a/Mastodon/Scene/Search/TableViewCell/SearchBottomLoader.swift b/Mastodon/Scene/Search/TableViewCell/SearchBottomLoader.swift index 7ab18bb0c..923a06301 100644 --- a/Mastodon/Scene/Search/TableViewCell/SearchBottomLoader.swift +++ b/Mastodon/Scene/Search/TableViewCell/SearchBottomLoader.swift @@ -43,5 +43,8 @@ final class SearchBottomLoader: UITableViewCell { backgroundColor = Asset.Colors.Background.systemGroupedBackground.color contentView.addSubview(activityIndicatorView) activityIndicatorView.constrainToCenter() + NSLayoutConstraint.activate([ + contentView.heightAnchor.constraint(equalToConstant: 44) + ]) } } diff --git a/Mastodon/Service/APIService/APIService+Notification.swift b/Mastodon/Service/APIService/APIService+Notification.swift index 84cb6d3c0..53595fa92 100644 --- a/Mastodon/Service/APIService/APIService+Notification.swift +++ b/Mastodon/Service/APIService/APIService+Notification.swift @@ -43,7 +43,7 @@ extension APIService { status = statusInCoreData } // use constrain to avoid repeated save - let notification = MastodonNotification.insert(into: self.backgroundManagedObjectContext, domain: domain, property: MastodonNotification.Property(id: notification.id, type: notification.type.rawValue, account: mastodonUser, status: status, createdAt: Date())) + let notification = MastodonNotification.insert(into: self.backgroundManagedObjectContext, domain: domain, property: MastodonNotification.Property(id: notification.id, type: notification.type.rawValue, account: mastodonUser, status: status, createdAt: notification.createdAt)) os_log(.info, log: log, "%{public}s[%{public}ld], %{public}s: fetch mastodon user [%s](%s)", (#file as NSString).lastPathComponent, #line, #function, notification.type, notification.account.username) }