damus

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

commit 0ab1494b1e77ac9c3f1b0444bcd5e922e88c0e0a
parent cf7cba09bd8c5092b06d664d4fe2fb44e7751667
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  9 May 2022 08:24:26 -0700

initial hashtag query

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus.xcodeproj/project.pbxproj | 4----
Mdamus/ContentView.swift | 1+
Mdamus/Nostr/NostrFilter.swift | 6++++++
Mdamus/Nostr/NostrLink.swift | 4++++
4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj @@ -33,7 +33,6 @@ 4C3BEFD6281D995700B3DE84 /* ActionBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFD5281D995700B3DE84 /* ActionBarModel.swift */; }; 4C3BEFDA281DCA1400B3DE84 /* LikeCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFD9281DCA1400B3DE84 /* LikeCounter.swift */; }; 4C3BEFDC281DCE6100B3DE84 /* Liked.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFDB281DCE6100B3DE84 /* Liked.swift */; }; - 4C3BEFDE281DD59C00B3DE84 /* ParsedRefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFDD281DD59C00B3DE84 /* ParsedRefs.swift */; }; 4C3BEFE0281DE1ED00B3DE84 /* DamusState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFDF281DE1ED00B3DE84 /* DamusState.swift */; }; 4C75EFA427FA577B0006080F /* PostView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFA327FA577B0006080F /* PostView.swift */; }; 4C75EFA627FF87A20006080F /* Nostr.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFA527FF87A20006080F /* Nostr.swift */; }; @@ -114,7 +113,6 @@ 4C3BEFD5281D995700B3DE84 /* ActionBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBarModel.swift; sourceTree = "<group>"; }; 4C3BEFD9281DCA1400B3DE84 /* LikeCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LikeCounter.swift; sourceTree = "<group>"; }; 4C3BEFDB281DCE6100B3DE84 /* Liked.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Liked.swift; sourceTree = "<group>"; }; - 4C3BEFDD281DD59C00B3DE84 /* ParsedRefs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParsedRefs.swift; sourceTree = "<group>"; }; 4C3BEFDF281DE1ED00B3DE84 /* DamusState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DamusState.swift; sourceTree = "<group>"; }; 4C75EFA327FA577B0006080F /* PostView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostView.swift; sourceTree = "<group>"; }; 4C75EFA527FF87A20006080F /* Nostr.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Nostr.swift; sourceTree = "<group>"; }; @@ -190,7 +188,6 @@ 4C3BEFD5281D995700B3DE84 /* ActionBarModel.swift */, 4C3BEFD9281DCA1400B3DE84 /* LikeCounter.swift */, 4C3BEFDB281DCE6100B3DE84 /* Liked.swift */, - 4C3BEFDD281DD59C00B3DE84 /* ParsedRefs.swift */, 4C3BEFDF281DE1ED00B3DE84 /* DamusState.swift */, 4C7FF7D42823313F009601DB /* Mentions.swift */, 4C363A912825FCF2006E126D /* ProfileUpdate.swift */, @@ -491,7 +488,6 @@ 4C3BEFDC281DCE6100B3DE84 /* Liked.swift in Sources */, 4C75EFB128049D510006080F /* NostrResponse.swift in Sources */, 4CEE2AF7280B2DEA00AB5EEF /* ProfileName.swift in Sources */, - 4C3BEFDE281DD59C00B3DE84 /* ParsedRefs.swift in Sources */, 4CEE2B02280B39E800AB5EEF /* EventActionBar.swift in Sources */, 4C3BEFE0281DE1ED00B3DE84 /* DamusState.swift in Sources */, 4C0A3F8F280F640A000448DE /* ThreadModel.swift in Sources */, diff --git a/damus/ContentView.swift b/damus/ContentView.swift @@ -248,6 +248,7 @@ struct ContentView: View { thread_open = true } case .filter: + break // TODO: handle filter searches? } diff --git a/damus/Nostr/NostrFilter.swift b/damus/Nostr/NostrFilter.swift @@ -15,16 +15,22 @@ struct NostrFilter: Codable { var since: Int64? var until: Int64? var authors: [String]? + var hashtag: [String]? = nil private enum CodingKeys : String, CodingKey { case ids case kinds case referenced_ids = "#e" case pubkeys = "#p" + case hashtag = "#hashtag" case since case until case authors } + + public static func filter_hashtag(_ htags: [String]) -> NostrFilter { + return NostrFilter(ids: nil, kinds: nil, referenced_ids: nil, pubkeys: nil, since: nil, until: nil, authors: nil, hashtag: htags) + } public static var filter_text: NostrFilter { return filter_kinds([1]) diff --git a/damus/Nostr/NostrLink.swift b/damus/Nostr/NostrLink.swift @@ -92,5 +92,9 @@ func decode_nostr_uri(_ s: String) -> NostrLink? { return } + if parts.count >= 3 && parts[1] == "hashtag" { + return .filter(NostrFilter.filter_hashtag([parts[2]])) + } + return tag_to_refid(parts).map { .ref($0) } }