mirror of
https://github.com/unclebob/more-speech.git
synced 2024-09-30 10:30:56 +00:00
When a tap selects for an id, any event that has a 'p' tags with that id will be included.
This commit is contained in:
parent
672c5ce69a
commit
2094c656b3
@ -264,6 +264,15 @@
|
|||||||
filter-results (map #(boolean (should-add-event? filter %)) events)]
|
filter-results (map #(boolean (should-add-event? filter %)) events)]
|
||||||
(should= [true false true] filter-results)))
|
(should= [true false true] filter-results)))
|
||||||
|
|
||||||
|
(it "allows selected pubkeys when mentioned in p tags"
|
||||||
|
(let [events [{:id 1 :pubkey 10}
|
||||||
|
{:id 2 :pubkey 20 :tags [[:p (hexify 50)]]}
|
||||||
|
{:id 3 :pubkey 30}]
|
||||||
|
filter {:selected [50]
|
||||||
|
:blocked []}
|
||||||
|
filter-results (map #(boolean (should-add-event? filter %)) events)]
|
||||||
|
(should= [false true false] filter-results)))
|
||||||
|
|
||||||
(it "allows events that have a selected id at the root of a thread."
|
(it "allows events that have a selected id at the root of a thread."
|
||||||
(let [events [{:id 1 :tags [[:e "10" ""]]}
|
(let [events [{:id 1 :tags [[:e "10" ""]]}
|
||||||
{:id 2 :tags [[:e "11" ""]]}
|
{:id 2 :tags [[:e "11" ""]]}
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
[more-speech.ui.formatters :as formatters]
|
[more-speech.ui.formatters :as formatters]
|
||||||
[more-speech.config :as config]
|
[more-speech.config :as config]
|
||||||
[more-speech.ui.swing.article-panel :as article-panel]
|
[more-speech.ui.swing.article-panel :as article-panel]
|
||||||
[more-speech.ui.swing.ui-context :refer :all])
|
[more-speech.ui.swing.ui-context :refer :all]
|
||||||
|
[clojure.set :as set]
|
||||||
|
[more-speech.nostr.util :as util])
|
||||||
(:use [seesaw core font tree])
|
(:use [seesaw core font tree])
|
||||||
(:import (javax.swing.tree DefaultMutableTreeNode DefaultTreeModel TreePath)))
|
(:import (javax.swing.tree DefaultMutableTreeNode DefaultTreeModel TreePath)))
|
||||||
|
|
||||||
@ -72,16 +74,20 @@
|
|||||||
|
|
||||||
(declare add-references resolve-any-orphans)
|
(declare add-references resolve-any-orphans)
|
||||||
|
|
||||||
(defn should-add-event? [filter event]
|
(defn should-add-event? [filters event]
|
||||||
(let [selected (:selected filter)
|
(let [selected (:selected filters)
|
||||||
blocked (:blocked filter)
|
blocked (:blocked filters)
|
||||||
[root _mentions _referent] (events/get-references event)]
|
[root _mentions _referent] (events/get-references event)
|
||||||
|
tags (:tags event)
|
||||||
|
ptags (filter #(= :p (first %)) tags)
|
||||||
|
pubkey-citings (map #(util/hex-string->num (second %)) ptags)]
|
||||||
(and
|
(and
|
||||||
(or
|
(or
|
||||||
(empty? selected)
|
(empty? selected)
|
||||||
(some #(= % (:pubkey event)) selected)
|
(some #(= % (:pubkey event)) selected)
|
||||||
(some #(= % (:id event)) selected)
|
(some #(= % (:id event)) selected)
|
||||||
(some #(= % root) selected))
|
(some #(= % root) selected)
|
||||||
|
(not-empty (set/intersection (set pubkey-citings) (set selected))))
|
||||||
(not
|
(not
|
||||||
(or
|
(or
|
||||||
(some #(= % (:pubkey event)) blocked)
|
(some #(= % (:pubkey event)) blocked)
|
||||||
|
Loading…
Reference in New Issue
Block a user