Fix issue with loading view using the redacted modifier

Also tried to make some adjusmtents to the refresh subscribtion to see
if this fixes bugs people were having

Closes: #119

Changelog-Fixed: Fixed issues when refreshing global view
This commit is contained in:
Sam DuBois
2022-12-22 17:23:55 -07:00
committed by William Casarin
parent 514d9f4201
commit 549cbb9bce
6 changed files with 62 additions and 54 deletions

View File

@@ -40,25 +40,6 @@ struct InnerTimelineView: View {
}
}
struct InnerTimelineRedactedView: View {
let events: [NostrEvent]
let damus: DamusState
let show_friend_icon: Bool
var body: some View {
VStack {
ForEach(events, id: \.id) { event in
EventView(event: event, highlight: .none, has_action_bar: true, damus: damus, show_friend_icon: show_friend_icon)
.buttonStyle(PlainButtonStyle())
}
}
.shimmer()
.redacted(reason: .placeholder)
.padding(.horizontal)
.disabled(true)
}
}
struct TimelineView: View {
@Binding var events: [NostrEvent]
@@ -75,13 +56,10 @@ struct TimelineView: View {
var MainContent: some View {
ScrollViewReader { scroller in
ScrollView {
if loading {
InnerTimelineRedactedView(events: Constants.EXAMPLE_EVENTS, damus: damus, show_friend_icon: true)
ProgressView()
.progressViewStyle(.circular)
} else {
InnerTimelineView(events: $events, damus: damus, show_friend_icon: show_friend_icon, filter: filter)
}
InnerTimelineView(events: loading ? .constant(Constants.EXAMPLE_EVENTS) : $events, damus: damus, show_friend_icon: show_friend_icon, filter: loading ? { _ in true } : filter)
.redacted(reason: loading ? .placeholder : [])
.shimmer(loading)
.disabled(loading)
}
.onReceive(NotificationCenter.default.publisher(for: .scroll_to_top)) { _ in
guard let event = events.filter(self.filter).first else {