Add ability to show multiple posts per user in Universe

ChangeLog-Added: Add ability to show multiple posts per user in Universe
Closes: #1198
Fixes: #1189
This commit is contained in:
Ben Weeks
2023-05-29 13:02:12 +01:00
committed by William Casarin
parent 51c4fa1e32
commit 06ba0f7387
5 changed files with 45 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ class SearchHomeModel: ObservableObject {
let base_subid = UUID().description
let profiles_subid = UUID().description
let limit: UInt32 = 250
//let multiple_events_per_pubkey: Bool = false
init(damus_state: DamusState) {
self.damus_state = damus_state
@@ -60,7 +61,7 @@ class SearchHomeModel: ObservableObject {
return
}
if ev.is_textlike && should_show_event(contacts: damus_state.contacts, ev: ev) && !ev.is_reply(nil) {
if seen_pubkey.contains(ev.pubkey) {
if !damus_state.settings.multiple_events_per_pubkey && seen_pubkey.contains(ev.pubkey) {
return
}
seen_pubkey.insert(ev.pubkey)

View File

@@ -137,6 +137,9 @@ class UserSettingsStore: ObservableObject {
@Setting(key: "show_only_preferred_languages", default_value: false)
var show_only_preferred_languages: Bool
@Setting(key: "multiple_events_per_pubkey", default_value: false)
var multiple_events_per_pubkey: Bool
@Setting(key: "onlyzaps_mode", default_value: false)
var onlyzaps_mode: Bool

View File

@@ -44,6 +44,10 @@ struct ConfigView: View {
IconLabel(NSLocalizedString("Appearance", comment: "Section header for text and appearance settings"), img_name: "eye", color: .red)
}
NavigationLink(destination: SearchSettingsView(settings: settings)) {
IconLabel(NSLocalizedString("Search/Universe", comment: "Section header for search/universe settings"), img_name: "magnifyingglass", color: .red)
}
NavigationLink(destination: NotificationSettingsView(settings: settings)) {
IconLabel(NSLocalizedString("Notifications", comment: "Section header for Damus notifications"), img_name: "notification-bell-on", color: .blue)
}

View File

@@ -0,0 +1,32 @@
//
// SearchSettingsView.swift
// damus
//
// Created by Ben Weeks on 29/05/2023.
//
import SwiftUI
struct SearchSettingsView: View {
@ObservedObject var settings: UserSettingsStore
@Environment(\.dismiss) var dismiss
var body: some View {
Form {
Section(header: Text(NSLocalizedString("Spam", comment: "Section header for Universe/Search spam"))) {
Toggle(NSLocalizedString("View multiple events per user", comment: "Setting to only see 1 event per user (npub) in the search/universe"), isOn: $settings.multiple_events_per_pubkey)
.toggleStyle(.switch)
}
}
.navigationTitle(NSLocalizedString("Search/Universe", comment: "Navigation title for universe/search settings."))
.onReceive(handle_notify(.switched_timeline)) { _ in
dismiss()
}
}
}
struct SearchSettingsView_Previews: PreviewProvider {
static var previews: some View {
SearchSettingsView(settings: UserSettingsStore())
}
}