Don't redraw frame unless new name/contact/zap/reaction data has arrived.

This commit is contained in:
Robert C. Martin 2023-05-26 07:59:37 -05:00
parent 5ee857b1fe
commit cd3455d723
6 changed files with 38 additions and 29 deletions

View File

@ -22,7 +22,7 @@
(def subscription-id-base "ms")
(def auto-thanks :dm) ;{:dm :note :off}
(def auto-thanks :off) ;{:dm :note :off}
(def auto-thanks-fortune :normal) ;{:off :normal :markov :insane}
(def test-run? (atom false))

View File

@ -27,6 +27,7 @@
[pubkey contacts]))
(defn process-contact-list [db event]
(set-mem :refresh-main-window true)
(let [[pubkey contacts] (unpack-contact-list-event event)]
(when (seq contacts)
(gateway/add-contacts db pubkey contacts))))

View File

@ -38,6 +38,7 @@
(recur pubkey (str name (inc (rand-int max))) (* 10 max))))))
(defn process-name-event [db {:keys [_id pubkey created-at _kind _tags content _sig] :as event}]
(set-mem :refresh-main-window true)
(try
(let [profile (json/read-str content)
name (get profile "name")
@ -111,6 +112,7 @@
target-id (unhexify (second last-e-tag))
reactor (:pubkey event)]
(when (gateway/event-exists? db target-id)
(set-mem :refresh-main-window true)
(gateway/add-reaction db target-id reactor content)))
(catch Exception _e))
)

View File

@ -353,6 +353,7 @@
(let [{:keys [id amount comment]} transaction
sats (/ amount 1000)]
(log-pr 2 'got-zap-receipt (util/hexify id) sats 'sats comment)
(set-mem :refresh-main-window true)
(gateway/add-zap-to-event (get-db)
id {:lnurl receipt-invoice
:created-at (util/get-now)

View File

@ -136,7 +136,8 @@
([event]
(format-header event :long))
([{:keys [pubkey created-at tags zaps] :as event} opt]
([{:keys [pubkey created-at content tags zaps] :as event} opt]
(try
(if (nil? event)
"nil"
(let [format-spec (if (= opt :long)
@ -156,7 +157,9 @@
content (if (empty? subject)
header-text
(abbreviate (str subject "|" header-text) 130))]
(format format-spec reply-mark reaction-mark name time zap-mark dm-mark content)))))
(format format-spec reply-mark reaction-mark name time zap-mark dm-mark content)))
(catch Exception e
(log-pr 1 'format-header 'Exception (.getMessage e))))))
(defn make-cc-list [event]
(let [p-tags (events/get-tag event :p)

View File

@ -13,8 +13,8 @@
[more-speech.ui.swing.relay-manager :as relay-manager]
[more-speech.ui.swing.stats-window :as stats-window]
[more-speech.ui.swing.tabs :as tabs]
[more-speech.ui.swing.users-window :as users-window]
[more-speech.ui.swing.tabs-window :as tabs-window])
[more-speech.ui.swing.tabs-window :as tabs-window]
[more-speech.ui.swing.users-window :as users-window])
(:use (seesaw [core]))
(:import (java.util Timer TimerTask)))
@ -81,8 +81,10 @@
(defn repaint-main-window []
(let [frame (get-mem :frame)]
(when (some? frame)
(invoke-later (repaint! frame)))
))
(when (get-mem :refresh-main-window)
(set-mem :refresh-main-window false)
(invoke-later (repaint! frame))
))))
(defn setup-main-timer []
(let [main-timer (Timer. "main timer")
@ -97,7 +99,7 @@
prune-tabs-task
(long prune-tabs-frequency)
(long prune-tabs-frequency))
(.schedule main-timer repaint-task 1000 1000)
(.schedule main-timer repaint-task 3000 3000)
(.schedule main-timer reload-article-task 1000 1000)))
(defn setup-main-window []