From aad8f9e8d46e57236bea2917dc036323bc2546c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Mon, 17 Feb 2025 17:22:02 -0800 Subject: [PATCH 1/4] Reduce swipe sensitivity on thread chat view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Value determined experimentally. Closes: https://github.com/damus-io/damus/issues/2743 Changelog-Fixed: Fixed overly sensitive horizontal swipe on thread chat view Signed-off-by: Daniel D’Aquino --- damus/Views/Chat/ChatEventView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/damus/Views/Chat/ChatEventView.swift b/damus/Views/Chat/ChatEventView.swift index 5884b409..386c4eb2 100644 --- a/damus/Views/Chat/ChatEventView.swift +++ b/damus/Views/Chat/ChatEventView.swift @@ -298,7 +298,7 @@ struct ChatEventView: View { } .swipeSpacing(-20) .swipeActionsStyle(.mask) - .swipeMinimumDistance(20) + .swipeMinimumDistance(40) .swipeDragGesturePriority(.normal) } } From 15af686a58721d8e3a7e93610de7a1fcc189fcd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Wed, 19 Feb 2025 15:21:35 -0800 Subject: [PATCH 2/4] Fix issue where a NWC connection would not work unless restarting the app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changelog-Fixed: Fixed issue where app would need a restart for new NWC wallets to work Closes: https://github.com/damus-io/damus/issues/2859 Closes: https://github.com/damus-io/damus/issues/1135 Signed-off-by: Daniel D’Aquino --- damus/ContentView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/damus/ContentView.swift b/damus/ContentView.swift index 0e835392..7a09796e 100644 --- a/damus/ContentView.swift +++ b/damus/ContentView.swift @@ -370,6 +370,8 @@ struct ContentView: View { self.confirm_mute = true } .onReceive(handle_notify(.attached_wallet)) { nwc in + try? damus_state.pool.add_relay(.nwc(url: nwc.relay)) + // update the lightning address on our profile when we attach a // wallet with an associated guard let ds = self.damus_state, From 7684f53281319be821c36a0117da885805a719e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Wed, 19 Feb 2025 16:18:16 -0800 Subject: [PATCH 3/4] Implement developer feature to avoid distractions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit implements an optional developer feature to scramble text and blur images to prevent distractions during development and testing. It is not perfect (It breaks some mentions and rich text objects, and does not scramble non-alphanumeric languages such as Japanese), but good enough to avoid distractions while working on most features. No changelog entry is needed because this is not meant for the final user. Changelog-None Signed-off-by: Daniel D’Aquino --- damus.xcodeproj/project.pbxproj | 8 +++++ damus/Models/UserSettingsStore.swift | 4 +++ damus/Util/Undistractor.swift | 30 +++++++++++++++++++ damus/Views/EventView.swift | 4 +++ damus/Views/NoteContentView.swift | 3 ++ .../Settings/DeveloperSettingsView.swift | 1 + 6 files changed, 50 insertions(+) create mode 100644 damus/Util/Undistractor.swift diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj index dea79398..54f4b5d9 100644 --- a/damus.xcodeproj/project.pbxproj +++ b/damus.xcodeproj/project.pbxproj @@ -1617,6 +1617,9 @@ D7DB1FEE2D5AC51B00CF06DA /* NIP44v2EncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7DB1FED2D5AC50F00CF06DA /* NIP44v2EncryptionTests.swift */; }; D7DB1FF12D5AC5D700CF06DA /* nip44.vectors.json in Resources */ = {isa = PBXBuildFile; fileRef = D7DB1FF02D5AC5D700CF06DA /* nip44.vectors.json */; }; D7DB1FF32D5AC5EA00CF06DA /* LICENSES in Resources */ = {isa = PBXBuildFile; fileRef = D7DB1FF22D5AC5E400CF06DA /* LICENSES */; }; + D7DB93052D66A44100DA1EE5 /* Undistractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7DB93042D66A43B00DA1EE5 /* Undistractor.swift */; }; + D7DB93062D66A44100DA1EE5 /* Undistractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7DB93042D66A43B00DA1EE5 /* Undistractor.swift */; }; + D7DB93072D66A44100DA1EE5 /* Undistractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7DB93042D66A43B00DA1EE5 /* Undistractor.swift */; }; D7DBD41F2B02F15E002A6197 /* NostrKind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFD32819DE8F00B3DE84 /* NostrKind.swift */; }; D7DEEF2F2A8C021E00E0C99F /* NostrEventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7DEEF2E2A8C021E00E0C99F /* NostrEventTests.swift */; }; D7EB00B02CD59C8D00660C07 /* PresentFullScreenItemNotify.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7EB00AF2CD59C8300660C07 /* PresentFullScreenItemNotify.swift */; }; @@ -2495,6 +2498,7 @@ D7DB1FED2D5AC50F00CF06DA /* NIP44v2EncryptionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NIP44v2EncryptionTests.swift; sourceTree = ""; }; D7DB1FF02D5AC5D700CF06DA /* nip44.vectors.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = nip44.vectors.json; sourceTree = ""; }; D7DB1FF22D5AC5E400CF06DA /* LICENSES */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSES; sourceTree = ""; }; + D7DB93042D66A43B00DA1EE5 /* Undistractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Undistractor.swift; sourceTree = ""; }; D7DEEF2E2A8C021E00E0C99F /* NostrEventTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NostrEventTests.swift; sourceTree = ""; }; D7EB00AF2CD59C8300660C07 /* PresentFullScreenItemNotify.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentFullScreenItemNotify.swift; sourceTree = ""; }; D7EDED1B2B1178FE0018B19C /* NoteContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteContent.swift; sourceTree = ""; }; @@ -3235,6 +3239,7 @@ 4C7FF7D628233637009601DB /* Util */ = { isa = PBXGroup; children = ( + D7DB93042D66A43B00DA1EE5 /* Undistractor.swift */, D73E5F7E2C6AA066007EB227 /* DamusAliases.swift */, E04A37C52B544F090029650D /* URIParsing.swift */, 4C1D4FB02A7958E60024F453 /* VersionInfo.swift */, @@ -4543,6 +4548,7 @@ 4CE8794829941DA700F758CC /* RelayFilters.swift in Sources */, 4CEE2B02280B39E800AB5EEF /* EventActionBar.swift in Sources */, 4C3BEFE0281DE1ED00B3DE84 /* DamusState.swift in Sources */, + D7DB93062D66A44100DA1EE5 /* Undistractor.swift in Sources */, D72E12782BEED22500F4F781 /* Array.swift in Sources */, 4C198DF529F88D2E004C165C /* ImageMetadata.swift in Sources */, 4CCEB7AE29B53D260078AA28 /* SearchingEventView.swift in Sources */, @@ -5012,6 +5018,7 @@ 82D6FB082CD99F7900C925F4 /* UserStatusSheet.swift in Sources */, 82D6FB092CD99F7900C925F4 /* SearchHeaderView.swift in Sources */, 82D6FB0A2CD99F7900C925F4 /* DamusGradient.swift in Sources */, + D7DB93052D66A44100DA1EE5 /* Undistractor.swift in Sources */, 82D6FB0B2CD99F7900C925F4 /* AlbyGradient.swift in Sources */, 82D6FB0C2CD99F7900C925F4 /* GoldSupportGradient.swift in Sources */, 82D6FB0D2CD99F7900C925F4 /* PinkGradient.swift in Sources */, @@ -5430,6 +5437,7 @@ D73E5E412C6A97F4007EB227 /* GoldSupportGradient.swift in Sources */, D73E5E422C6A97F4007EB227 /* PinkGradient.swift in Sources */, D73E5E432C6A97F4007EB227 /* GrayGradient.swift in Sources */, + D7DB93072D66A44100DA1EE5 /* Undistractor.swift in Sources */, D73E5E442C6A97F4007EB227 /* DamusLogoGradient.swift in Sources */, D73E5E452C6A97F4007EB227 /* DamusBackground.swift in Sources */, D73E5E462C6A97F4007EB227 /* DamusLightGradient.swift in Sources */, diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift index 59401faf..518d8dce 100644 --- a/damus/Models/UserSettingsStore.swift +++ b/damus/Models/UserSettingsStore.swift @@ -201,6 +201,10 @@ class UserSettingsStore: ObservableObject { @Setting(key: "developer_mode", default_value: false) var developer_mode: Bool + /// Makes all post content gibberish and blurhashes images, to avoid distractions when developers are working. + @Setting(key: "undistract_mode", default_value: false) + var undistractMode: Bool + @Setting(key: "always_show_onboarding_suggestions", default_value: false) var always_show_onboarding_suggestions: Bool diff --git a/damus/Util/Undistractor.swift b/damus/Util/Undistractor.swift new file mode 100644 index 00000000..8f678b62 --- /dev/null +++ b/damus/Util/Undistractor.swift @@ -0,0 +1,30 @@ +// +// Undistractor.swift +// damus +// +// Created by Daniel D’Aquino on 2025-02-19. +// + +/// Keeping the minds of developers safe from the occupational hazard of social media distractions when testing Damus since 2025 +struct Undistractor { + static func makeGibberish(text: String) -> String { + let lowercaseLetters = "abcdefghijklmnopqrstuvwxyz" + let uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + var transformedText = "" + + for char in text { + if lowercaseLetters.contains(char) { + if let randomLetter = lowercaseLetters.randomElement() { + transformedText.append(randomLetter) + } + } else if uppercaseLetters.contains(char) { + if let randomLetter = uppercaseLetters.randomElement() { + transformedText.append(randomLetter) + } + } else { + transformedText.append(char) + } + } + return transformedText + } +} diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift index 85de8d90..cb4d8727 100644 --- a/damus/Views/EventView.swift +++ b/damus/Views/EventView.swift @@ -57,6 +57,10 @@ struct EventView: View { // blame the porn bots for this code func should_blur_images(settings: UserSettingsStore, contacts: Contacts, ev: NostrEvent, our_pubkey: Pubkey, booster_pubkey: Pubkey? = nil) -> Bool { + if settings.undistractMode { + return true + } + if !settings.blur_images { return false } diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift index 343d23fb..b13fa704 100644 --- a/damus/Views/NoteContentView.swift +++ b/damus/Views/NoteContentView.swift @@ -40,6 +40,9 @@ struct NoteContentView: View { @ObservedObject var settings: UserSettingsStore var note_artifacts: NoteArtifacts { + if damus_state.settings.undistractMode { + return .separated(.just_content(Undistractor.makeGibberish(text: event.get_content(damus_state.keypair)))) + } return self.artifacts_model.state.artifacts ?? .separated(.just_content(event.get_content(damus_state.keypair))) } diff --git a/damus/Views/Settings/DeveloperSettingsView.swift b/damus/Views/Settings/DeveloperSettingsView.swift index c3fdd982..cd646cc6 100644 --- a/damus/Views/Settings/DeveloperSettingsView.swift +++ b/damus/Views/Settings/DeveloperSettingsView.swift @@ -17,6 +17,7 @@ struct DeveloperSettingsView: View { Toggle(NSLocalizedString("Developer Mode", comment: "Setting to enable developer mode"), isOn: $settings.developer_mode) .toggleStyle(.switch) if settings.developer_mode { + Toggle(NSLocalizedString("Undistract mode", comment: "Developer mode setting to scramble text and images to avoid distractions during development."), isOn: $settings.undistractMode) Toggle(NSLocalizedString("Always show onboarding", comment: "Developer mode setting to always show onboarding suggestions."), isOn: $settings.always_show_onboarding_suggestions) Picker(NSLocalizedString("Push notification environment", comment: "Prompt selection of the Push notification environment (Developer feature to switch between real/production mode to test modes)."), selection: Binding( From 981821a6bcdbe5f1cb660acd0deec182fd045684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Wed, 19 Feb 2025 20:21:49 -0800 Subject: [PATCH 4/4] Fix issue where note persisted after note publication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no changelog entry needed because drafts are still an unreleased feature. Changelog-None Signed-off-by: Daniel D’Aquino Closes: https://github.com/damus-io/damus/issues/2836 --- damus/Views/PostView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/damus/Views/PostView.swift b/damus/Views/PostView.swift index 54cecbc5..84c6ed25 100644 --- a/damus/Views/PostView.swift +++ b/damus/Views/PostView.swift @@ -230,6 +230,7 @@ struct PostView: View { damus_state.drafts.post = nil } + damus_state.drafts.save(damus_state: damus_state) } func load_draft() -> Bool {