Skip to content

Commit

Permalink
Initial display of grouped notifications
Browse files Browse the repository at this point in the history
Contributes to IOS-253
Contributes to IOS-355
  • Loading branch information
shannon committed Jan 14, 2025
1 parent 12d737c commit 6ec1d9a
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 156 deletions.
6 changes: 3 additions & 3 deletions Mastodon/Protocol/Provider/DataSourceFacade+Follow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ extension DataSourceFacade {
notification.transientFollowRequestState = .init(state: .isRejecting)
}

await notificationView.configure(notification: notification, authenticationBox: dependency.authenticationBox)
await notificationView.configure(notification: notification)

do {
let newRelationship = try await APIService.shared.followRequest(
Expand All @@ -118,11 +118,11 @@ extension DataSourceFacade {
UserInfoKey.relationship: newRelationship
])

await notificationView.configure(notification: notification, authenticationBox: dependency.authenticationBox)
await notificationView.configure(notification: notification)
} catch {
// reset state when failure
notification.transientFollowRequestState = .init(state: .none)
await notificationView.configure(notification: notification, authenticationBox: dependency.authenticationBox)
await notificationView.configure(notification: notification)

if let error = error as? Mastodon.API.Error {
switch error.httpResponseStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
completion: { (newRelationship: Mastodon.Entity.Relationship) in
notification.relationship = newRelationship
Task { @MainActor in
notificationView.configure(notification: notification, authenticationBox: self.authenticationBox)
notificationView.configure(notification: notification)
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@ extension NotificationTimelineViewController: DataSourceProvider {
case .notification, .notificationGroup:
let item: DataSourceItem? = {
// guard feed.kind == .notificationAll || feed.kind == .notificationMentions else { return nil }

if let notification = MastodonFeedItemCacheManager.shared.cachedItem(notificationItem) as? Mastodon.Entity.Notification {
let mastodonNotification = MastodonNotification.fromEntity(notification, relationship: nil)
return .notification(record: mastodonNotification)
} else {
return nil
if let cachedItem = MastodonFeedItemCacheManager.shared.cachedItem(notificationItem) {
if let notification = cachedItem as? Mastodon.Entity.Notification {
let mastodonNotification = MastodonNotification.fromEntity(notification, relationship: nil)
return .notification(record: mastodonNotification)
} else if let notificationGroup = cachedItem as? Mastodon.Entity.NotificationGroup {
if let statusID = notificationGroup.statusID, let statusEntity = MastodonFeedItemCacheManager.shared.cachedItem(.status(id: statusID)) as? Mastodon.Entity.Status {
let status = MastodonStatus.fromEntity(statusEntity)
return .status(record: status)
}/* else if notificationGroup.type == .follow {
return .followers
} */ else {
return nil
}
}
}
return nil
}()
return item
case .status:
Expand Down
Loading

0 comments on commit 6ec1d9a

Please sign in to comment.