mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Correctly track follow and reblog status in the notification view.
This is a temporary fix, the datamodel will be changing with grouped notifications.
This commit is contained in:
parent
54861dcf6f
commit
999e74be47
@ -303,13 +303,13 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
|
||||
assertionFailure("only works for status data provider")
|
||||
return
|
||||
}
|
||||
guard let status = notification.status?.reblog ?? notification.status else {
|
||||
guard let status = await notification.entity.latestStatus ?? notification.status?.entity else {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
try await DataSourceFacade.responseToActionToolbar(
|
||||
provider: self,
|
||||
status: status,
|
||||
status: MastodonStatus.fromEntity(status),
|
||||
action: action,
|
||||
sender: button
|
||||
)
|
||||
|
@ -30,6 +30,7 @@ extension NotificationSection {
|
||||
let filterContext: Mastodon.Entity.FilterContext?
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static func diffableDataSource(
|
||||
tableView: UITableView,
|
||||
configuration: Configuration
|
||||
@ -80,7 +81,7 @@ extension NotificationSection {
|
||||
itemIdentifier: MastodonFeedItemIdentifier,
|
||||
configuration: Configuration
|
||||
) {
|
||||
guard let authBox = AuthenticationServiceProvider.shared.currentActiveUser.value else { assertionFailure(); return }
|
||||
guard AuthenticationServiceProvider.shared.currentActiveUser.value != nil else { assertionFailure(); return }
|
||||
StatusSection.setupStatusPollDataSource(
|
||||
authenticationBox: configuration.authenticationBox,
|
||||
statusView: cell.notificationView.statusView
|
||||
|
@ -64,9 +64,11 @@ extension NotificationTimelineViewController: DataSourceProvider {
|
||||
}
|
||||
|
||||
func update(status: MastodonStatus, intent: MastodonStatus.UpdateIntent) {
|
||||
Task {
|
||||
await viewModel.loadLatest()
|
||||
MastodonFeedItemCacheManager.shared.addToCache(status.entity)
|
||||
if let reblog = status.entity.reblog {
|
||||
MastodonFeedItemCacheManager.shared.addToCache(reblog)
|
||||
}
|
||||
viewModel.reloadData()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
@ -119,6 +119,11 @@ extension NotificationTimelineViewModel {
|
||||
|
||||
extension NotificationTimelineViewModel {
|
||||
|
||||
func reloadData() {
|
||||
guard let diffableDataSource else { return }
|
||||
diffableDataSource.applySnapshotUsingReloadData(diffableDataSource.snapshot())
|
||||
}
|
||||
|
||||
// load lastest
|
||||
func loadLatest() async {
|
||||
isLoadingLatest = true
|
||||
|
@ -33,7 +33,7 @@ extension NotificationView {
|
||||
public func configure(notificationItem: MastodonFeedItemIdentifier) {
|
||||
let item = MastodonFeedItemCacheManager.shared.cachedItem(notificationItem)
|
||||
if let notification = item as? Mastodon.Entity.Notification {
|
||||
configure(notificationType: notification.type, status: notification.status)
|
||||
configure(notificationType: notification.type, status: notification.latestStatus)
|
||||
configure(notification: notification)
|
||||
} else if let notificationGroup = item as? Mastodon.Entity.NotificationGroup {
|
||||
let status: Mastodon.Entity.Status?
|
||||
@ -91,12 +91,12 @@ extension NotificationView {
|
||||
case .followRequest:
|
||||
setFollowRequestAdaptiveMarginContainerViewDisplay(isHidden: false)
|
||||
case .mention, .status:
|
||||
if let status = notification.status {
|
||||
if let status = notification.latestStatus {
|
||||
statusView.configure(status: status, contentDisplayMode: contentDisplayMode(status))
|
||||
setStatusViewDisplay()
|
||||
}
|
||||
case .reblog, .favourite, .poll:
|
||||
if let status = notification.status {
|
||||
if let status = notification.latestStatus {
|
||||
quoteStatusView.configure(status: status, contentDisplayMode: contentDisplayMode(status))
|
||||
setQuoteStatusViewDisplay()
|
||||
}
|
||||
|
@ -313,3 +313,15 @@ public class MastodonFeedItemCacheManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Mastodon.Entity.Notification {
|
||||
|
||||
@MainActor
|
||||
public var latestStatus: Mastodon.Entity.Status? {
|
||||
var freshStatus: Mastodon.Entity.Status? = nil
|
||||
if let statusID = status?.id {
|
||||
freshStatus = MastodonFeedItemCacheManager.shared.cachedItem(.status(id: statusID)) as? Mastodon.Entity.Status
|
||||
}
|
||||
return freshStatus ?? status
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user