mirror of
https://github.com/unclebob/more-speech.git
synced 2024-09-30 02:21:02 +00:00
Reload article window every second to resolve references as they come in from the relays.
This commit is contained in:
parent
6eae2c0a8d
commit
3f30ead8c9
@ -284,10 +284,10 @@
|
||||
(it "returns a list of :text and :url and :namereference segments"
|
||||
(should= [[:text "Hey "] [:namereference "@bob"] [:text " Check this "] [:url "http://nostr.com"] [:text " It's cool"]]
|
||||
(segment-article "Hey @bob Check this http://nostr.com It's cool"))
|
||||
(should= [[:nostrnpubreference "nostr:npub1qq"] [:text " "] [:nostrprofilereference "nostr:nprofile1qq"]]
|
||||
(segment-article "nostr:npub1qq nostr:nprofile1qq"))
|
||||
(should= [[:nostrnotereference "nostr:note1qq"] [:text " "] [:nostreventreference "nostr:nevent1qq"]]
|
||||
(segment-article "nostr:note1qq nostr:nevent1qq")))
|
||||
(should= [[:nostrnpubreference "nostr:npub1qq"]]
|
||||
(segment-article "nostr:npub1qq"))
|
||||
(should= [[:nostrnotereference "nostr:note1qq"]]
|
||||
(segment-article "nostr:note1qq")))
|
||||
|
||||
(it "extracts text from segments"
|
||||
(should= "name" (extract-reference "@name"))
|
||||
@ -341,12 +341,12 @@
|
||||
(should= "<a href=\"ms-namereference://user1\">nostr:user1</a>"
|
||||
(reformat-article-into-html (str "nostr:" npub)))))
|
||||
|
||||
(it "should replace nostr:nprofile with namereference link using user's name "
|
||||
(let [user-id (rand-int 1000000000)
|
||||
npub (bech32/encode "nprofile" user-id)]
|
||||
(gateway/add-profile @db user-id {:name "user1"})
|
||||
(should= "<a href=\"ms-namereference://user1\">nostr:user1</a>"
|
||||
(reformat-article-into-html (str "nostr:" npub)))))
|
||||
;(it "should replace nostr:nprofile with namereference link using user's name "
|
||||
; (let [user-id (rand-int 1000000000)
|
||||
; npub (bech32/encode "nprofile" user-id)]
|
||||
; (gateway/add-profile @db user-id {:name "user1"})
|
||||
; (should= "<a href=\"ms-namereference://user1\">nostr:user1</a>"
|
||||
; (reformat-article-into-html (str "nostr:" npub)))))
|
||||
|
||||
(it "should replace nostr:npub with namereference link using npub if user does not exist "
|
||||
(let [user-id (rand-int 1000000000)
|
||||
@ -355,12 +355,12 @@
|
||||
npub "\">nostr:" npub "</a>")
|
||||
(reformat-article-into-html (str "nostr:" npub)))))
|
||||
|
||||
(it "should replace nostr:nevent with notereference link"
|
||||
(let [user-id (rand-int 1000000000)
|
||||
npub (bech32/encode "nevent" user-id)]
|
||||
(should= (str "<a href=\"ms-notereference://"
|
||||
npub "\">nostr:" npub "</a>")
|
||||
(reformat-article-into-html (str "nostr:" npub)))))
|
||||
;(it "should replace nostr:nevent with notereference link"
|
||||
; (let [user-id (rand-int 1000000000)
|
||||
; npub (bech32/encode "nevent" user-id)]
|
||||
; (should= (str "<a href=\"ms-notereference://"
|
||||
; npub "\">nostr:" npub "</a>")
|
||||
; (reformat-article-into-html (str "nostr:" npub)))))
|
||||
|
||||
(it "should replace nostr:note with notereference link"
|
||||
(let [user-id (rand-int 1000000000)
|
||||
|
@ -46,17 +46,17 @@
|
||||
(send-request request)))
|
||||
|
||||
(defn request-profiles-and-contacts-for [authors]
|
||||
(let [authors (if (coll? authors) authors [authors])
|
||||
hexified-authors (map util/hexify authors)
|
||||
trimmed-authors (if (<= (count hexified-authors) 100)
|
||||
hexified-authors
|
||||
(map #(subs % 0 10) (take 1000 (shuffle hexified-authors))))
|
||||
r (rand-int 1000000)
|
||||
request ["REQ" (str "ms-request-" r)
|
||||
{"kinds" [0 3]
|
||||
"authors" trimmed-authors}]]
|
||||
(send-request request)
|
||||
))
|
||||
(when (some? authors)
|
||||
(let [authors (if (coll? authors) authors [authors])
|
||||
hexified-authors (map util/hexify authors)
|
||||
trimmed-authors (if (<= (count hexified-authors) 100)
|
||||
hexified-authors
|
||||
(map #(subs % 0 10) (take 1000 (shuffle hexified-authors))))
|
||||
r (rand-int 1000000)
|
||||
request ["REQ" (str "ms-request-" r)
|
||||
{"kinds" [0 3]
|
||||
"authors" trimmed-authors}]]
|
||||
(send-request request))))
|
||||
|
||||
(defn request-batch [url id back-to filter]
|
||||
(let [relay (get-in @relays [url :connection])
|
||||
|
@ -225,9 +225,9 @@
|
||||
|
||||
([content segments]
|
||||
(let [patterns [[:nostrnotereference config/nostr-note-reference-pattern]
|
||||
[:nostreventreference config/nostr-event-reference-pattern]
|
||||
;[:nostreventreference config/nostr-event-reference-pattern]
|
||||
[:nostrnpubreference config/nostr-npub-reference-pattern]
|
||||
[:nostrprofilereference config/nostr-profile-reference-pattern]
|
||||
;[:nostrprofilereference config/nostr-profile-reference-pattern]
|
||||
[:nostrnamereference config/nostr-name-reference-pattern]
|
||||
[:idreference config/id-reference-pattern]
|
||||
[:namereference config/user-reference-pattern]
|
||||
@ -287,6 +287,11 @@
|
||||
(= seg-type :namereference)
|
||||
(str formatted-content (ms-linkify "ms-namereference" "@" (extract-reference seg)))
|
||||
|
||||
(and (= seg-type :nostrnamereference)
|
||||
(or (.startsWith seg ":nostr:nevent1")
|
||||
(.startsWith seg ":nostr:nprofile1")))
|
||||
seg
|
||||
|
||||
(= seg-type :nostrnamereference)
|
||||
(str formatted-content (ms-linkify "ms-namereference" "nostr:" (extract-reference seg)))
|
||||
|
||||
|
@ -129,6 +129,13 @@
|
||||
(defn dn-click [_e]
|
||||
(reaction-click "-"))
|
||||
|
||||
(declare load-article-info)
|
||||
|
||||
(defn reload-article []
|
||||
(let [id (get-mem :article-window-event-id)]
|
||||
(when (some? id)
|
||||
(load-article-info id))))
|
||||
|
||||
(defn make-article-info-panel []
|
||||
(let [author-name-label (label :id :author-name-label)
|
||||
label-font (uconfig/get-small-font)
|
||||
@ -269,7 +276,9 @@
|
||||
zap-items (map format-zap (:zaps event))
|
||||
event-id (select main-frame [:#id-label])
|
||||
author-name-label (select main-frame [:#author-name-label])]
|
||||
(protocol/request-profiles-and-contacts-for (:pubkey event))
|
||||
(when (not= (get-mem :article-window-event-id) selected-id)
|
||||
(protocol/request-profiles-and-contacts-for (:pubkey event)))
|
||||
(set-mem :article-window-event-id selected-id)
|
||||
(text! reactions-label (str reactions))
|
||||
(if reacted?
|
||||
(do
|
||||
|
@ -89,12 +89,15 @@
|
||||
(run [] (tabs/prune-tabs)))
|
||||
repaint-task (proxy [TimerTask] []
|
||||
(run [] (repaint-main-window)))
|
||||
reload-article-task (proxy [TimerTask] []
|
||||
(run [] (article-panel/reload-article)))
|
||||
prune-tabs-frequency (* config/prune-tabs-frequency-in-minutes 60 1000)]
|
||||
(.schedule main-timer
|
||||
prune-tabs-task
|
||||
(long prune-tabs-frequency)
|
||||
(long prune-tabs-frequency))
|
||||
(.schedule main-timer repaint-task 1000 1000)))
|
||||
(.schedule main-timer repaint-task 1000 1000)
|
||||
(.schedule main-timer reload-article-task 1000 1000)))
|
||||
|
||||
(defn setup-main-window []
|
||||
(setup-main-timer)
|
||||
|
@ -223,7 +223,7 @@
|
||||
selection-panel])
|
||||
user-window-timer (Timer. "User window timer")
|
||||
user-window-repaint-task (proxy [TimerTask] []
|
||||
(run [] repaint-user-window users-frame))]
|
||||
(run [] (repaint-user-window users-frame)))]
|
||||
(set-mem [:user-window :selection-group] :recent-user-items)
|
||||
(load-user-window-data)
|
||||
(config! trusted-users-listbox :model (get-mem [:user-window :trusted-user-items]))
|
||||
|
Loading…
Reference in New Issue
Block a user