From 80dcf587bf07d70cc5b46dac1c6cc1c71deab9a3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 4 May 2020 09:38:41 +0200 Subject: [PATCH] :arrow_up: Update to the latest version of rumext. --- frontend/deps.edn | 2 +- .../src/uxbox/main/ui/components/defer.cljs | 47 ------------------- .../src/uxbox/main/ui/dashboard/grid.cljs | 3 +- frontend/src/uxbox/main/ui/shapes/frame.cljs | 5 +- .../main/ui/workspace/sidebar/layers.cljs | 7 ++- .../main/ui/workspace/sidebar/options.cljs | 3 +- .../src/uxbox/main/ui/workspace/viewport.cljs | 1 - 7 files changed, 8 insertions(+), 60 deletions(-) delete mode 100644 frontend/src/uxbox/main/ui/components/defer.cljs diff --git a/frontend/deps.edn b/frontend/deps.edn index 75ed4f72f..a31a8480d 100644 --- a/frontend/deps.edn +++ b/frontend/deps.edn @@ -17,7 +17,7 @@ funcool/okulary {:mvn/version "2020.04.14-0"} funcool/potok {:mvn/version "2.8.0-SNAPSHOT"} funcool/promesa {:mvn/version "5.1.0"} - funcool/rumext {:mvn/version "2020.04.14-1"} + funcool/rumext {:mvn/version "2020.05.04-0"} } :aliases {:dev diff --git a/frontend/src/uxbox/main/ui/components/defer.cljs b/frontend/src/uxbox/main/ui/components/defer.cljs deleted file mode 100644 index df75ebaca..000000000 --- a/frontend/src/uxbox/main/ui/components/defer.cljs +++ /dev/null @@ -1,47 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; This Source Code Form is "Incompatible With Secondary Licenses", as -;; defined by the Mozilla Public License, v. 2.0. -;; -;; Copyright (c) 2020 UXBOX Labs SL - -(ns uxbox.main.ui.components.defer - (:require - [rumext.alpha :as mf] - [uxbox.common.uuid :as uuid] - [uxbox.util.dom :as dom] - [uxbox.util.timers :as ts] - [goog.events :as events] - [goog.functions :as gf] - [goog.object :as gobj]) - (:import goog.events.EventType - goog.events.KeyCodes)) - -(defn deferred - ([component] (deferred component ts/raf)) - ([component schedule] - (mf/fnc deferred - {::mf/wrap-props false} - [props] - (let [[render? set-render!] (mf/useState false)] - (mf/use-effect - (fn [] (schedule #(set-render! true)))) - (when render? - (mf/create-element component props)))))) - -(defn throttle - [component ms] - (mf/fnc throttle - {::mf/wrap-props false} - [props] - (let [[state set-state] (mf/useState props) - set-state* (mf/use-memo #(gf/throttle set-state ms))] - - (mf/use-effect - nil - (fn [] - (set-state* props))) - - (mf/create-element component state)))) diff --git a/frontend/src/uxbox/main/ui/dashboard/grid.cljs b/frontend/src/uxbox/main/ui/dashboard/grid.cljs index 6d3a6dd2e..059ae22ec 100644 --- a/frontend/src/uxbox/main/ui/dashboard/grid.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/grid.cljs @@ -9,7 +9,6 @@ [uxbox.main.ui.modal :as modal] [uxbox.main.ui.keyboard :as kbd] [uxbox.main.ui.confirm :refer [confirm-dialog]] - [uxbox.main.ui.components.defer :refer [deferred]] [uxbox.main.ui.components.context-menu :refer [context-menu]] [uxbox.util.dom :as dom] [uxbox.util.i18n :as i18n :refer [t tr]] @@ -20,7 +19,7 @@ ;; --- Grid Item Thumbnail (mf/defc grid-item-thumbnail - {::mf/wrap [#(deferred % ts/schedule-on-idle)]} + {::mf/wrap [#(mf/deferred % ts/schedule-on-idle)]} [{:keys [file] :as props}] [:div.grid-item-th [:& exports/page-svg {:data (:data file) diff --git a/frontend/src/uxbox/main/ui/shapes/frame.cljs b/frontend/src/uxbox/main/ui/shapes/frame.cljs index 711e7c09e..7aa4fd8a4 100644 --- a/frontend/src/uxbox/main/ui/shapes/frame.cljs +++ b/frontend/src/uxbox/main/ui/shapes/frame.cljs @@ -17,7 +17,6 @@ [uxbox.util.geom.shapes :as geom] [uxbox.main.refs :as refs] [uxbox.main.store :as st] - [uxbox.main.ui.components.defer :refer [deferred]] [uxbox.main.ui.shapes.attrs :as attrs] [uxbox.main.ui.shapes.common :as common] [uxbox.util.dom :as dom] @@ -55,8 +54,8 @@ [shape-wrapper] (let [frame-shape (frame-shape shape-wrapper)] (mf/fnc frame-wrapper - {::mf/wrap [#(deferred % ts/schedule-on-idle) - #(mf/memo' % frame-wrapper-memo-equals?)] + {::mf/wrap [#(mf/memo' % frame-wrapper-memo-equals?) + #(mf/deferred % ts/schedule-on-idle)] ::mf/wrap-props false} [props] (let [shape (unchecked-get props "shape") diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs index 7510ae721..3cab83dac 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs @@ -19,7 +19,6 @@ [uxbox.main.data.workspace :as dw] [uxbox.main.refs :as refs] [uxbox.main.store :as st] - [uxbox.main.ui.components.defer :refer [throttle deferred]] [uxbox.main.ui.hooks :as hooks] [uxbox.main.ui.keyboard :as kbd] [uxbox.main.ui.shapes.icon :as icon] @@ -233,8 +232,8 @@ (mf/defc frame-wrapper {::mf/wrap-props false - ::mf/wrap [#(deferred % ts/idle-then-raf) - #(mf/memo' % frame-wrapper-memo-equals?)]} + ::mf/wrap [#(mf/memo' % frame-wrapper-memo-equals?) + #(mf/deferred % ts/idle-then-raf)]} [props] [:> layer-item props]) @@ -271,7 +270,7 @@ (mf/defc layers-tree-wrapper {::mf/wrap-props false - ::mf/wrap [#(throttle % 200) mf/memo]} + ::mf/wrap [mf/memo #(mf/throttle % 200)]} [props] (let [objects (obj/get props "objects") objects (strip-objects objects)] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options.cljs index 826a5f92c..40270cf79 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options.cljs @@ -15,7 +15,6 @@ [uxbox.main.data.workspace :as udw] [uxbox.main.store :as st] [uxbox.main.refs :as refs] - [uxbox.main.ui.components.defer :refer [throttle]] [uxbox.main.ui.workspace.sidebar.align :refer [align-options]] [uxbox.main.ui.workspace.sidebar.options.frame :as frame] [uxbox.main.ui.workspace.sidebar.options.group :as group] @@ -31,7 +30,7 @@ ;; --- Options (mf/defc shape-options - {::mf/wrap [#(throttle % 60)]} + {::mf/wrap [#(mf/throttle % 60)]} [{:keys [shape] :as props}] [:div (case (:type shape) diff --git a/frontend/src/uxbox/main/ui/workspace/viewport.cljs b/frontend/src/uxbox/main/ui/workspace/viewport.cljs index 4ca78dab8..c01bbe909 100644 --- a/frontend/src/uxbox/main/ui/workspace/viewport.cljs +++ b/frontend/src/uxbox/main/ui/workspace/viewport.cljs @@ -23,7 +23,6 @@ [uxbox.main.streams :as ms] [uxbox.main.ui.keyboard :as kbd] [uxbox.main.ui.hooks :as hooks] - [uxbox.main.ui.components.defer :refer [deferred]] [uxbox.main.ui.shapes :refer [shape-wrapper frame-wrapper]] [uxbox.main.ui.workspace.drawarea :refer [draw-area start-drawing]] [uxbox.main.ui.workspace.grid :refer [grid]]