fix app crash if swiped block and editing block are different

pull/5557/head^2
llcc 2022-06-05 14:25:28 +08:00 committed by Tienson Qin
parent 328fda29a9
commit 13cc487592
2 changed files with 8 additions and 3 deletions

View File

@ -2467,7 +2467,7 @@
[:div.flex.flex-row.pr-2
{:class (if (and heading? (seq (:block/title block))) "items-baseline" "")
:on-touch-start block-handler/on-touch-start
:on-touch-start (fn [event uuid] (block-handler/on-touch-start event uuid))
:on-touch-move (fn [event]
(block-handler/on-touch-move event block uuid edit? *show-left-menu? *show-right-menu?))
:on-touch-end (fn [event]

View File

@ -1,6 +1,7 @@
(ns frontend.handler.block
(:require
[clojure.set :as set]
[clojure.string :as string]
[clojure.walk :as walk]
[frontend.db :as db]
[frontend.db.model :as db-model]
@ -149,8 +150,12 @@
(def *swipe (atom nil))
(defn on-touch-start
[event]
(let [input (state/get-input)]
[event uuid]
(let [input (state/get-input)
input-id (state/get-edit-input-id)]
(when-not (and input
(string/ends-with? input-id (str uuid)))
(state/clear-edit!))
(when (= (util/get-selection-start input)
(util/get-selection-end input))
(when-let [touches (.-targetTouches event)]