damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 06ba0f7387f4a9808ccce44b6ae3e22ed79f2242
parent 51c4fa1e32eaf39cbaa5068278d34751fa1473b3
Author: Ben Weeks <ben.weeks@outlook.com>
Date:   Mon, 29 May 2023 13:02:12 +0100

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

Diffstat:
Mdamus.xcodeproj/project.pbxproj | 4++++
Mdamus/Models/SearchHomeModel.swift | 3++-
Mdamus/Models/UserSettingsStore.swift | 3+++
Mdamus/Views/ConfigView.swift | 4++++
Adamus/Views/Settings/SearchSettingsView.swift | 32++++++++++++++++++++++++++++++++
5 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj @@ -303,6 +303,7 @@ E4AE2AD32A228CB400680283 /* Inter-SemiBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = E4AE2AD12A228CA000680283 /* Inter-SemiBold.otf */; }; E4AE2AD42A228CB900680283 /* Inter-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = E4AE2AD22A228CA700680283 /* Inter-Medium.otf */; }; E4AE2AD52A228CC000680283 /* Inter-Italic.otf in Resources */ = {isa = PBXBuildFile; fileRef = E4AE2ACF2A228C7500680283 /* Inter-Italic.otf */; }; + E4FA1C032A24BB7F00482697 /* SearchSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4FA1C022A24BB7F00482697 /* SearchSettingsView.swift */; }; E990020F2955F837003BBC5A /* EditMetadataView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E990020E2955F837003BBC5A /* EditMetadataView.swift */; }; E9E4ED0B295867B900DD7078 /* ThreadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9E4ED0A295867B900DD7078 /* ThreadView.swift */; }; F757933A29D7AECD007DEAC1 /* ImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F757933929D7AECD007DEAC1 /* ImagePicker.swift */; }; @@ -750,6 +751,7 @@ E4AE2ACF2A228C7500680283 /* Inter-Italic.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Inter-Italic.otf"; sourceTree = "<group>"; }; E4AE2AD12A228CA000680283 /* Inter-SemiBold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Inter-SemiBold.otf"; sourceTree = "<group>"; }; E4AE2AD22A228CA700680283 /* Inter-Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Inter-Medium.otf"; sourceTree = "<group>"; }; + E4FA1C022A24BB7F00482697 /* SearchSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchSettingsView.swift; sourceTree = "<group>"; }; E990020E2955F837003BBC5A /* EditMetadataView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditMetadataView.swift; sourceTree = "<group>"; }; E9E4ED0A295867B900DD7078 /* ThreadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadView.swift; sourceTree = "<group>"; }; F757933929D7AECD007DEAC1 /* ImagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePicker.swift; sourceTree = "<group>"; }; @@ -942,6 +944,7 @@ 4C1A9A2029DDD3E100516EAC /* KeySettingsView.swift */, 4C1A9A2429DDDF2600516EAC /* ZapSettingsView.swift */, 4C1A9A2629DDE31900516EAC /* TranslationSettingsView.swift */, + E4FA1C022A24BB7F00482697 /* SearchSettingsView.swift */, ); path = Settings; sourceTree = "<group>"; @@ -1916,6 +1919,7 @@ 4C75EFB528049D790006080F /* Relay.swift in Sources */, 4CEE2AF1280B216B00AB5EEF /* EventDetailView.swift in Sources */, 4CC7AAFA297F64AC00430951 /* EventMenu.swift in Sources */, + E4FA1C032A24BB7F00482697 /* SearchSettingsView.swift in Sources */, 4C75EFBB2804A34C0006080F /* ProofOfWork.swift in Sources */, 4C3AC7A52836987600E1F516 /* MainTabView.swift in Sources */, 4C1A9A1F29DDD24B00516EAC /* AppearanceSettingsView.swift in Sources */, diff --git a/damus/Models/SearchHomeModel.swift b/damus/Models/SearchHomeModel.swift @@ -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) diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift @@ -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 diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift @@ -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) } diff --git a/damus/Views/Settings/SearchSettingsView.swift b/damus/Views/Settings/SearchSettingsView.swift @@ -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()) + } +}