diff --git a/src/main/frontend/db.cljs b/src/main/frontend/db.cljs index 581645d649..4b17ffde9c 100644 --- a/src/main/frontend/db.cljs +++ b/src/main/frontend/db.cljs @@ -1892,7 +1892,7 @@ ) (let [job (get persistent-jobs repo)] (persist-if-idle! repo)))) - 5000)] + 3000)] (swap! persistent-jobs assoc repo job))) ;; only save when user's idle diff --git a/src/main/frontend/fs.cljs b/src/main/frontend/fs.cljs index 8361ea169d..6449b4e986 100644 --- a/src/main/frontend/fs.cljs +++ b/src/main/frontend/fs.cljs @@ -174,7 +174,10 @@ (defn stat [dir path] (let [append-path (if path - (str "/" (string/replace-first path "/" "")) + (str "/" + (if (= \/ (first path)) + (subs path 1) + path)) "")] (cond (local-db? dir) @@ -189,8 +192,8 @@ (p/rejected "File not exists")) :else - ;; FIXME: same format - (js/window.pfs.stat (str dir append-path))))) + (do + (js/window.pfs.stat (str dir append-path)))))) (defn mkdir-if-not-exists [dir] diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 8e036c8e1d..277040e2bd 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -1981,7 +1981,7 @@ (defn periodically-save! [] - (js/setInterval save-current-block-when-idle! 5000)) + (js/setInterval save-current-block-when-idle! 3000)) (defn get-current-input-value [] diff --git a/src/main/frontend/handler/git.cljs b/src/main/frontend/handler/git.cljs index 10c417605b..6594c41aea 100644 --- a/src/main/frontend/handler/git.cljs +++ b/src/main/frontend/handler/git.cljs @@ -1,5 +1,4 @@ (ns frontend.handler.git - (:refer-clojure :exclude [clone load-file]) (:require [frontend.util :as util :refer-macros [profile]] [promesa.core :as p] [frontend.state :as state] diff --git a/src/main/frontend/handler/route.cljs b/src/main/frontend/handler/route.cljs index db3d059639..7844ccfbce 100644 --- a/src/main/frontend/handler/route.cljs +++ b/src/main/frontend/handler/route.cljs @@ -79,7 +79,9 @@ (let [{:keys [data path-params]} route title (get-title (:name data) path-params)] (util/set-title! title) - (ui-handler/scroll-and-highlight! nil))) + (if-let [fragment (util/get-fragment)] + (ui-handler/highlight-element! fragment) + (util/scroll-to-top)))) (defn go-to-search! [] diff --git a/src/main/frontend/handler/ui.cljs b/src/main/frontend/handler/ui.cljs index 1a7966b125..7aca3d7b49 100644 --- a/src/main/frontend/handler/ui.cljs +++ b/src/main/frontend/handler/ui.cljs @@ -70,8 +70,7 @@ (defn scroll-and-highlight! [state] (if-let [fragment (util/get-fragment)] - (highlight-element! fragment) - (util/scroll-to-top)) + (highlight-element! fragment)) state) (defn add-style-if-exists! diff --git a/src/main/frontend/mixins.cljs b/src/main/frontend/mixins.cljs index 3e9999b676..5236c57b95 100644 --- a/src/main/frontend/mixins.cljs +++ b/src/main/frontend/mixins.cljs @@ -61,16 +61,16 @@ ;; If the click target is outside of current node (when-not (dom/contains dom-node (.. e -target)) (on-hide state e :click)))) - (when visibilitychange? - (listen state js/window "visibilitychange" - (fn [e] - (on-hide state e :visibilitychange)))) - (listen state dom-node "keydown" + (listen state js/window "keydown" (fn [e] (case (.-keyCode e) ;; Esc 27 (on-hide state e :esc) - nil))))) + nil))) + (when visibilitychange? + (listen state js/window "visibilitychange" + (fn [e] + (on-hide state e :visibilitychange)))))) (catch js/Error e ;; TODO: Unable to find node on an unmounted component. nil))) diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 1ec6b6145d..b712fb0463 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -909,7 +909,7 @@ (when repo (when-let [last-time (get-in @state [:db/last-transact-time repo])] (let [now (util/time-ms)] - (>= (- now last-time) 5000))))) + (>= (- now last-time) 3000))))) (defn input-idle? [repo] @@ -917,7 +917,7 @@ (or (when-let [last-time (get-in @state [:editor/last-input-time repo])] (let [now (util/time-ms)] - (>= (- now last-time) 5000))) + (>= (- now last-time) 3000))) ;; not in editing mode (not (get-edit-input-id)))))