commit 66e204eb91946ef67b1e93e00d33d35f69fb9fed
parent 704023560506dddeed81e828d3f0a0a3424f1188
Author: William Casarin <jb55@jb55.com>
Date: Sat, 29 Jul 2023 09:16:14 -0700
notifications: don't do expensive id calculation
Diffstat:
2 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/damus/Models/NotificationsModel.swift b/damus/Models/NotificationsModel.swift
@@ -35,22 +35,7 @@ enum NotificationItem {
return nil
}
}
-
- var id: String {
- switch self {
- case .repost(let evid, _):
- return "repost_" + evid
- case .reaction(let evid, _):
- return "reaction_" + evid
- case .profile_zap:
- return "profile_zap"
- case .event_zap(let evid, _):
- return "event_zap_" + evid
- case .reply(let ev):
- return "reply_" + ev.id
- }
- }
-
+
var last_event_at: UInt32 {
switch self {
case .reaction(_, let evgrp):
diff --git a/damus/Views/Notifications/NotificationsView.swift b/damus/Views/Notifications/NotificationsView.swift
@@ -166,8 +166,9 @@ struct NotificationsView: View {
Color.white.opacity(0)
.id("startblock")
.frame(height: 5)
- ForEach(filter.filter(contacts: state.contacts, items: notifications.notifications), id: \.id) { item in
- NotificationItemView(state: state, item: item)
+ let notifs = Array(zip(1..., filter.filter(contacts: state.contacts, items: notifications.notifications)))
+ ForEach(notifs, id: \.0) { zip in
+ NotificationItemView(state: state, item: zip.1)
}
}
.background(GeometryReader { proxy -> Color in