fix: somehow repeated content when pressing Enter too fast

experiment/tanstack-table
Tienson Qin 2024-06-21 21:22:44 +08:00
parent 9f9e5d21ce
commit 4921480e0f
2 changed files with 23 additions and 23 deletions

View File

@ -63,7 +63,7 @@
download-logs upload-logs misc-logs pending-local-ops pending-server-ops]} (rum/react *detail-info)] download-logs upload-logs misc-logs pending-local-ops pending-server-ops]} (rum/react *detail-info)]
[:div.rtc-info.flex.flex-col.gap-1.p-2.text-gray-11 [:div.rtc-info.flex.flex-col.gap-1.p-2.text-gray-11
[:div.font-medium.mb-2 (if online? "Online" "Offline")] [:div.font-medium.mb-2 (if online? "Online" "Offline")]
[:div [:span.font-medium.mr-1 pending-local-ops] "pending local changes"] [:div [:span.font-medium.mr-1 (or pending-local-ops 0)] "pending local changes"]
;; FIXME: pending-server-ops ;; FIXME: pending-server-ops
[:div [:span.font-medium.mr-1 (or pending-server-ops 0)] "pending server changes"] [:div [:span.font-medium.mr-1 (or pending-server-ops 0)] "pending server changes"]
;; FIXME: What's the type for downloaded log? ;; FIXME: What's the type for downloaded log?
@ -72,7 +72,7 @@
[:div.text-sm "Last synced time: " [:div.text-sm "Last synced time: "
(.toLocaleString time)])) (.toLocaleString time)]))
[:a.fade-link.text-sm {:on-click #(swap! *expand-debug? not)} [:a.fade-link.text-sm {:on-click #(swap! *expand-debug? not)}
"More debug info"] "More debug info"]
(when @*expand-debug? (when @*expand-debug?
[:div.rtc-info-debug [:div.rtc-info-debug
[:pre.select-text [:pre.select-text

View File

@ -372,7 +372,7 @@
(state/set-edit-content! edit-input-id new-content))) (state/set-edit-content! edit-input-id new-content)))
(let [sibling? (not= (:db/id left-or-parent) (:db/id (:block/parent block))) (let [sibling? (not= (:db/id left-or-parent) (:db/id (:block/parent block)))
result (outliner-insert-block! config left-or-parent prev-block {:sibling? sibling? result (outliner-insert-block! config left-or-parent prev-block {:sibling? sibling?
:keep-uuid? true})] :keep-uuid? true})]
[result sibling? prev-block]))) [result sibling? prev-block])))
(defn insert-new-block-aux! (defn insert-new-block-aux!
@ -392,11 +392,10 @@
next-block (-> (merge (select-keys block [:block/parent :block/format :block/page]) next-block (-> (merge (select-keys block [:block/parent :block/format :block/page])
new-m) new-m)
(wrap-parse-block)) (wrap-parse-block))
sibling? (or (:block/collapsed? (:block/link block)) (when block-self? false))] sibling? (or (:block/collapsed? (:block/link block)) (when block-self? false))
(util/set-change-value input fst-block-text) result (outliner-insert-block! config current-block next-block {:sibling? sibling?
(let [result (outliner-insert-block! config current-block next-block {:sibling? sibling?
:keep-uuid? true})] :keep-uuid? true})]
[result sibling? (assoc next-block :block/content snd-block-text)]))) [result sibling? next-block]))
(defn clear-when-saved! (defn clear-when-saved!
[] []
@ -1855,24 +1854,25 @@
(defonce *auto-save-timeout (atom nil)) (defonce *auto-save-timeout (atom nil))
(defn edit-box-on-change! (defn edit-box-on-change!
[e _block id] [e block id]
(let [value (util/evalue e) (when (= (:db/id block) (:db/id (state/get-edit-block)))
repo (state/get-current-repo)] (let [value (util/evalue e)
(state/set-edit-content! id value false) repo (state/get-current-repo)]
(when @*auto-save-timeout (state/set-edit-content! id value false)
(js/clearTimeout @*auto-save-timeout)) (when @*auto-save-timeout
(block-handler/mark-last-input-time! repo) (js/clearTimeout @*auto-save-timeout))
(reset! *auto-save-timeout (block-handler/mark-last-input-time! repo)
(js/setTimeout (reset! *auto-save-timeout
(fn [] (js/setTimeout
(when (and (state/input-idle? repo :diff 450) (fn []
(when (and (state/input-idle? repo :diff 450)
;; don't auto-save block if it has tags ;; don't auto-save block if it has tags
(not (and (not (and
(config/db-based-graph? repo) (config/db-based-graph? repo)
(re-find #"#\S+" value)))) (re-find #"#\S+" value))))
; don't auto-save for page's properties block ; don't auto-save for page's properties block
(save-current-block! {:skip-properties? true}))) (save-current-block! {:skip-properties? true})))
450)))) 450)))))
(defn- start-of-new-word? (defn- start-of-new-word?
[input pos] [input pos]