diff --git a/frontend/src/uxbox/main/state/colors.cljs b/frontend/src/uxbox/builtins/colors.cljs similarity index 98% rename from frontend/src/uxbox/main/state/colors.cljs rename to frontend/src/uxbox/builtins/colors.cljs index de0542457..aec2b73e7 100644 --- a/frontend/src/uxbox/main/state/colors.cljs +++ b/frontend/src/uxbox/builtins/colors.cljs @@ -4,7 +4,7 @@ ;; ;; Copyright (c) 2015-2016 Andrey Antukh -(ns uxbox.main.state.colors +(ns uxbox.builtins.colors (:require [uxbox.util.uuid :as uuid] [uxbox.util.data :refer (index-by)])) diff --git a/frontend/src/uxbox/main.cljs b/frontend/src/uxbox/main.cljs index e9ae8d537..96a044d35 100644 --- a/frontend/src/uxbox/main.cljs +++ b/frontend/src/uxbox/main.cljs @@ -3,17 +3,17 @@ ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2015-2016 Andrey Antukh -;; Copyright (c) 2015-2016 Juan de la Cruz (ns uxbox.main - (:require [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + (:require [uxbox.store :as st] [uxbox.main.locales :as lc] - [uxbox.main.ui :as ui])) + [uxbox.main.ui :as ui] + [uxbox.main.state :refer [initial-state]] + [uxbox.util.storage :refer [storage]])) (defn ^:export init [] (lc/init) - (st/init) + (st/init initial-state) (ui/init-routes) (ui/init)) diff --git a/frontend/src/uxbox/main/data/auth.cljs b/frontend/src/uxbox/main/data/auth.cljs index a6bd9a482..b3cce4e0b 100644 --- a/frontend/src/uxbox/main/data/auth.cljs +++ b/frontend/src/uxbox/main/data/auth.cljs @@ -3,21 +3,21 @@ ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; ;; Copyright (c) 2015-2016 Andrey Antukh -;; Copyright (c) 2015-2016 Juan de la Cruz (ns uxbox.main.data.auth (:require [cljs.spec :as s] [beicon.core :as rx] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.repo :as rp] - [uxbox.util.rstore :as rs] - [uxbox.util.router :as rt] - [uxbox.util.spec :as us] - [uxbox.util.i18n :refer (tr)] - [uxbox.main.state :as st] + [uxbox.main.state :refer [initial-state]] [uxbox.main.data.projects :as udp] [uxbox.main.data.users :as udu] [uxbox.main.data.messages :as udm] - [uxbox.util.storage :refer (storage)])) + [uxbox.util.router :as rt] + [uxbox.util.spec :as us] + [uxbox.util.i18n :refer (tr)] + [uxbox.util.storage :refer [storage]])) (s/def ::username string?) (s/def ::password string?) @@ -28,12 +28,12 @@ ;; --- Logged In (defrecord LoggedIn [data] - rs/UpdateEvent - (-apply-update [this state] + ptk/UpdateEvent + (update [this state] (assoc state :auth data)) - rs/WatchEvent - (-apply-watch [this state s] + ptk/WatchEvent + (watch [this state s] (swap! storage assoc :auth data) (rx/of (udu/fetch-profile) (rt/navigate :dashboard/projects)))) @@ -49,12 +49,12 @@ ;; --- Login (defrecord Login [username password] - rs/UpdateEvent - (-apply-update [_ state] - (merge state (dissoc (st/initial-state) :route))) + ptk/UpdateEvent + (update [_ state] + (merge state (dissoc (initial-state) :route))) - rs/WatchEvent - (-apply-watch [this state s] + ptk/WatchEvent + (watch [this state s] (let [params {:username username :password password :scope "webapp"} @@ -75,13 +75,13 @@ ;; --- Logout (defrecord Logout [] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (swap! storage dissoc :auth) - (merge state (dissoc (st/initial-state) :route))) + (merge state (dissoc (initial-state) :route))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (rt/navigate :auth/login)))) (defn logout @@ -93,8 +93,8 @@ ;; TODO: clean form on success (defrecord Register [data on-error] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (letfn [(handle-error [{payload :payload}] (on-error payload) (rx/empty))] @@ -121,8 +121,8 @@ ;; --- Recovery Request (defrecord RecoveryRequest [data] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (letfn [(on-error [{payload :payload}] (println "on-error" payload) (rx/empty))] @@ -146,8 +146,8 @@ ;; --- Check Recovery Token (defrecord ValidateRecoveryToken [token] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (letfn [(on-error [{payload :payload}] (rx/of (rt/navigate :auth/login) @@ -164,8 +164,8 @@ ;; --- Recovery (Password) (defrecord Recovery [token password] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (letfn [(on-error [{payload :payload}] (udm/error (tr "errors.auth.invalid-recovery-token"))) (on-success [{payload :payload}] diff --git a/frontend/src/uxbox/main/data/colors.cljs b/frontend/src/uxbox/main/data/colors.cljs index 4c6a451ea..9a5efbbf5 100644 --- a/frontend/src/uxbox/main/data/colors.cljs +++ b/frontend/src/uxbox/main/data/colors.cljs @@ -9,10 +9,10 @@ [beicon.core :as rx] [uxbox.util.datetime :as dt] [uxbox.util.uuid :as uuid] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as r] [uxbox.util.color :as color] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.repo :as rp])) ;; --- Initialize @@ -22,8 +22,8 @@ (declare collections-fetched?) (defrecord Initialize [type id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [type (or type :own) data {:type type :id id @@ -32,8 +32,8 @@ (assoc-in [:dashboard :colors] data) (assoc-in [:dashboard :section] :dashboard/colors)))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (fetch-collections)))) (defn initialize @@ -43,8 +43,8 @@ ;; --- Select a Collection (defrecord SelectCollection [type id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (r/navigate :dashboard/colors {:type type :id id})))) @@ -58,8 +58,8 @@ ;; --- Collections Fetched (defrecord CollectionsFetched [data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [{:keys [version value]} data] (-> state (update :colors-collections merge value) @@ -77,8 +77,8 @@ ;; --- Fetch Collections (defrecord FetchCollections [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rp/req :fetch/kvstore "color-collections") (rx/map :payload) (rx/map collections-fetched)))) @@ -90,8 +90,8 @@ ;; --- Create Collection (defrecord CreateCollection [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [item {:name "Unnamed collection" :id id :created-at (dt/now) @@ -99,8 +99,8 @@ :colors #{}}] (assoc-in state [:colors-collections id] item))) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (persist-collections) (select-collection :own id)))) @@ -112,8 +112,8 @@ ;; --- Persist Collections (defrecord PersistCollections [] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [builtin? #(= :builtin (:type %)) xform (remove (comp builtin? second)) version (or (get state ::version) -1) @@ -133,12 +133,12 @@ ;; --- Rename Collection (defrecord RenameCollection [id name] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:colors-collections id :name] name)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (persist-collections)))) (defn rename-collection @@ -148,12 +148,12 @@ ;; --- Delete Collection (defrecord DeleteCollection [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update state :colors-collections dissoc id)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [type (get-in state [:dashboard :colors :type])] (rx/of (persist-collections) (select-collection type))))) @@ -165,13 +165,13 @@ ;; --- Replace Color (defrecord ReplaceColor [id from to] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [replacer #(-> (disj % from) (conj to))] (update-in state [:colors-collections id :colors] (fnil replacer #{})))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (persist-collections)))) (defn replace-color @@ -182,13 +182,13 @@ ;; --- Remove Color (defrecord RemoveColors [id colors] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:colors-collections id :colors] #(set/difference % colors))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (persist-collections)))) (defn remove-colors @@ -199,18 +199,18 @@ ;; --- Select color (defrecord SelectColor [color] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :colors :selected] conj color))) (defrecord DeselectColor [color] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :colors :selected] disj color))) (defrecord ToggleColorSelection [color] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :colors :selected])] (rx/of (if (selected color) @@ -225,13 +225,13 @@ ;; --- Copy Selected Icon (defrecord CopySelected [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [selected (get-in state [:dashboard :colors :selected])] (update-in state [:colors-collections id :colors] set/union selected))) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (persist-collections)))) (defn copy-selected @@ -242,15 +242,15 @@ ;; --- Move Selected Icon (defrecord MoveSelected [from to] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [selected (get-in state [:dashboard :colors :selected])] (-> state (update-in [:colors-collections from :colors] set/difference selected) (update-in [:colors-collections to :colors] set/union selected)))) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (persist-collections)))) (defn move-selected @@ -262,8 +262,8 @@ ;; --- Delete Selected Colors (defrecord DeleteSelectedColors [] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [{:keys [id selected]} (get-in state [:dashboard :colors])] (rx/of (remove-colors id selected) #(assoc-in % [:dashboard :colors :selected] #{}))))) diff --git a/frontend/src/uxbox/main/data/core.cljs b/frontend/src/uxbox/main/data/core.cljs index 61dcc5f34..353aa5caf 100644 --- a/frontend/src/uxbox/main/data/core.cljs +++ b/frontend/src/uxbox/main/data/core.cljs @@ -7,7 +7,7 @@ (ns uxbox.main.data.core "Worker related api and initialization events." (:require [beicon.core :as rx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.workers :as uw] [uxbox.main.constants :as c])) diff --git a/frontend/src/uxbox/main/data/dashboard.cljs b/frontend/src/uxbox/main/data/dashboard.cljs index c60f68f17..aeae18179 100644 --- a/frontend/src/uxbox/main/data/dashboard.cljs +++ b/frontend/src/uxbox/main/data/dashboard.cljs @@ -8,9 +8,9 @@ (ns uxbox.main.data.dashboard (:require [beicon.core :as rx] [uxbox.util.uuid :as uuid] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as r] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.util.forms :as sc] [uxbox.main.repo :as rp] [uxbox.main.data.projects :as dp] @@ -21,8 +21,8 @@ ;; --- Events (defrecord InitializeDashboard [section] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update state :dashboard assoc :section section :collection-type :builtin @@ -41,8 +41,8 @@ (let [colls (sort-by :id (vals (:colors-by-id state)))] (assoc-in state [:dashboard :collection-id] (:id (first colls))))))] (reify - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (as-> state $ (assoc-in $ [:dashboard :collection-type] type) (select-first $)))))) @@ -50,6 +50,6 @@ (defn set-collection [id] (reify - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:dashboard :collection-id] id)))) diff --git a/frontend/src/uxbox/main/data/history.cljs b/frontend/src/uxbox/main/data/history.cljs index 015f2fd19..8f60697f4 100644 --- a/frontend/src/uxbox/main/data/history.cljs +++ b/frontend/src/uxbox/main/data/history.cljs @@ -8,13 +8,13 @@ (:require [cuerdas.core :as str] [beicon.core :as rx] [lentes.core :as l] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as r] [uxbox.main.repo :as rp] [uxbox.util.i18n :refer (tr)] [uxbox.util.forms :as sc] [uxbox.main.data.pages :as udp] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.util.datetime :as dt] [uxbox.util.data :refer (without-keys replace-by-id @@ -32,9 +32,9 @@ persists the state of the page in an undo stack." [] (letfn [(on-value [id] - (rs/emit! (fetch-page-history id) + (st/emit! (fetch-page-history id) (fetch-pinned-page-history id)))] - (as-> rs/stream $ + (as-> st/store $ (rx/filter udp/page-persisted? $) (rx/debounce 500 $) (rx/map (comp :id :data) $) @@ -45,8 +45,8 @@ (declare update-history-index) (defrecord PinnedPageHistoryFetched [history] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (-> state (assoc-in [:workspace :history :pinned-items] (mapv :version history)) (update-history-index history true)))) @@ -54,8 +54,8 @@ ;; --- Fetch Pinned Page History (defrecord FetchPinnedPageHistory [id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (letfn [(on-success [{history :payload}] (->PinnedPageHistoryFetched (into [] history)))] (let [params {:page id :pinned true}] @@ -69,8 +69,8 @@ ;; --- Page History Fetched (defrecord PageHistoryFetched [history append?] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (letfn [(update-counters [state items] (-> (assoc state :min-version (apply min items)) (assoc :max-version (apply max items)))) @@ -91,8 +91,8 @@ ;; --- Fetch Page History (defrecord FetchPageHistory [id since max] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (letfn [(on-success [{history :payload}] (let [history (into [] history)] (->PageHistoryFetched history (not (nil? since)))))] @@ -111,8 +111,8 @@ ;; --- Select Page History (defrecord SelectPageHistory [version] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [item (get-in state [:workspace :history :by-version version]) page (get-in state [:pages (:page item)]) page (assoc page @@ -129,14 +129,14 @@ ;; --- Apply selected history (defrecord ApplySelectedHistory [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (-> state (update-in [:pages id] dissoc :history) (assoc-in [:workspace :history :selected] nil))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (udp/persist-page id)))) (defn apply-selected-history @@ -146,15 +146,15 @@ ;; --- Deselect Page History (defrecord DeselectPageHistory [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [packed (get-in state [:packed-pages id])] (-> (udp/assoc-page state packed) (assoc-in [:workspace :history :deselecting] true) (assoc-in [:workspace :history :selected] nil)))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rx/of #(assoc-in % [:workspace :history :deselecting] false)) (rx/delay 500)))) @@ -165,8 +165,8 @@ ;; --- History Item Updated (defrecord HistoryItemUpdated [item] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (-> state (update-in [:workspace :history :items] replace-by-id item) (update-in [:workspace :history :pinned-items] replace-by-id item)))) @@ -182,8 +182,8 @@ ;; --- Refresh Page History (defrecord RefreshPageHistory [id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [history (get-in state [:workspace :history]) maxitems (count (:items history))] (rx/of (fetch-page-history id {:max maxitems}) @@ -196,8 +196,8 @@ ;; --- Update History Item (defrecord UpdateHistoryItem [item] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (letfn [(on-success [{item :payload}] (->HistoryItemUpdated item))] (rx/merge @@ -214,8 +214,8 @@ ;; --- Forward to Next Version (defrecord ForwardToNextVersion [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [workspace (:workspace state) history (:history workspace) version (:selected history)] @@ -239,8 +239,8 @@ ;; --- Backwards to Previous Version (defrecord BackwardsToPreviousVersion [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [workspace (:workspace state) history (:history workspace) version (:selected history)] diff --git a/frontend/src/uxbox/main/data/icons.cljs b/frontend/src/uxbox/main/data/icons.cljs index 1a580c026..8b2d70e49 100644 --- a/frontend/src/uxbox/main/data/icons.cljs +++ b/frontend/src/uxbox/main/data/icons.cljs @@ -9,11 +9,11 @@ [beicon.core :as rx] [uxbox.util.data :refer (jscoll->vec)] [uxbox.util.uuid :as uuid] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as r] [uxbox.util.dom :as dom] [uxbox.util.files :as files] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.repo :as rp])) ;; --- Initialize @@ -23,16 +23,16 @@ (declare collections-fetched?) (defrecord Initialize [type id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [type (or type :own) data {:type type :id id :selected #{}}] (-> state (assoc-in [:dashboard :icons] data) (assoc-in [:dashboard :section] :dashboard/icons)))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/merge (rx/of (fetch-collections)) (rx/of (fetch-icons id))))) @@ -43,8 +43,8 @@ ;; --- Select a Collection (defrecord SelectCollection [type id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (r/navigate :dashboard/icons {:type type :id id})))) @@ -58,8 +58,8 @@ ;; --- Collections Fetched (defrecord CollectionsFetched [items] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (reduce (fn [state {:keys [id user] :as item}] (let [type (if (uuid/zero? (:user item)) :builtin :own) item (assoc item :type type)] @@ -74,8 +74,8 @@ ;; --- Fetch Collections (defrecord FetchCollections [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rp/req :fetch/icon-collections) (rx/map :payload) (rx/map collections-fetched)))) @@ -87,13 +87,13 @@ ;; --- Collection Created (defrecord CollectionCreated [item] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [{:keys [id] :as item} (assoc item :type :own)] (update state :icons-collections assoc id item))) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (select-collection :own (:id item))))) (defn collection-created @@ -103,8 +103,8 @@ ;; --- Create Collection (defrecord CreateCollection [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [name (str "Unnamed Collection (" (gensym "c") ")") coll {:name name}] (->> (rp/req :create/icon-collection coll) @@ -122,8 +122,8 @@ ;; --- Collection Updated (defrecord CollectionUpdated [item] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:icons-collections (:id item)] merge item))) (defn collection-updated @@ -133,8 +133,8 @@ ;; --- Update Collection (defrecord UpdateCollection [id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [item (get-in state [:icons-collections id])] (->> (rp/req :update/icon-collection item) (rx/map :payload) @@ -147,12 +147,12 @@ ;; --- Rename Collection (defrecord RenameCollection [id name] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:icons-collections id :name] name)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (update-collection id)))) (defn rename-collection @@ -162,12 +162,12 @@ ;; --- Delete Collection (defrecord DeleteCollection [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update state :icons-collections dissoc id)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [type (get-in state [:dashboard :icons :type])] (->> (rp/req :delete/icon-collection id) (rx/map #(select-collection type)))))) @@ -179,8 +179,8 @@ ;; --- Icon Created (defrecord IconCreated [item] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [{:keys [id] :as item} (assoc item :type :icon)] (update state :icons assoc id item)))) @@ -220,8 +220,8 @@ [(dom/get-outer-html g) props]))))) (defrecord CreateIcons [id files] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (letfn [(parse [file] (->> (files/read-as-text file) (rx/map parse-svg))) @@ -248,8 +248,8 @@ ;; --- Icon Persisted (defrecord IconPersisted [id data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:icons id] data))) (defn icon-persisted @@ -260,8 +260,8 @@ ;; --- Persist Icon (defrecord PersistIcon [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [icon (get-in state [:icons id])] (->> (rp/req :update/icon icon) (rx/map :payload) @@ -275,8 +275,8 @@ ;; --- Icons Fetched (defrecord IconsFetched [items] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (reduce (fn [state {:keys [id] :as icon}] (let [icon (assoc icon :type :icon)] (assoc-in state [:icons id] icon))) @@ -290,8 +290,8 @@ ;; --- Load Icons (defrecord FetchIcons [id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [params {:coll id}] (->> (rp/req :fetch/icons params) (rx/map :payload) @@ -305,14 +305,14 @@ ;; --- Delete Icons (defrecord DeleteIcon [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (-> state (update :icons dissoc id) (update-in [:dashboard :icons :selected] disj id))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rp/req :delete/icon id) (rx/ignore)))) @@ -324,12 +324,12 @@ ;; --- Rename Icon (defrecord RenameIcon [id name] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:icons id :name] name)) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (persist-icon id)))) (defn rename-icon @@ -340,18 +340,18 @@ ;; --- Select icon (defrecord SelectIcon [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :icons :selected] conj id))) (defrecord DeselectIcon [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :icons :selected] disj id))) (defrecord ToggleIconSelection [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :icons :selected])] (rx/of (if (selected id) @@ -370,8 +370,8 @@ ;; --- Copy Selected Icon (defrecord CopySelected [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :icons :selected])] (rx/merge (->> (rx/from-coll selected) @@ -392,16 +392,16 @@ ;; --- Move Selected Icon (defrecord MoveSelected [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [selected (get-in state [:dashboard :icons :selected])] (reduce (fn [state icon] (assoc-in state [:icons icon :collection] id)) state selected))) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :icons :selected])] (rx/merge (->> (rx/from-coll selected) @@ -417,8 +417,8 @@ ;; --- Delete Selected (defrecord DeleteSelected [] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :icons :selected])] (->> (rx/from-coll selected) (rx/map delete-icon))))) @@ -430,8 +430,8 @@ ;; --- Update Opts (Filtering & Ordering) (defrecord UpdateOpts [order filter edition] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :icons] merge {:edition edition} (when order {:order order}) diff --git a/frontend/src/uxbox/main/data/images.cljs b/frontend/src/uxbox/main/data/images.cljs index b37e36bd9..83f1f08f2 100644 --- a/frontend/src/uxbox/main/data/images.cljs +++ b/frontend/src/uxbox/main/data/images.cljs @@ -9,10 +9,10 @@ [beicon.core :as rx] [uxbox.util.data :refer (jscoll->vec)] [uxbox.util.uuid :as uuid] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as r] [uxbox.util.files :as files] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.repo :as rp])) ;; --- Initialize @@ -22,16 +22,16 @@ (declare collections-fetched?) (defrecord Initialize [type id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [type (or type :own) data {:type type :id id :selected #{}}] (-> state (assoc-in [:dashboard :images] data) (assoc-in [:dashboard :section] :dashboard/images)))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/merge (rx/of (fetch-collections)) (rx/of (fetch-images id))))) @@ -42,8 +42,8 @@ ;; --- Select a Collection (defrecord SelectCollection [type id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (r/navigate :dashboard/images {:type type :id id})))) @@ -57,8 +57,8 @@ ;; --- Color Collections Fetched (defrecord CollectionsFetched [items] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (reduce (fn [state {:keys [id user] :as item}] (let [type (if (uuid/zero? (:user item)) :builtin :own) item (assoc item :type type)] @@ -73,8 +73,8 @@ ;; --- Fetch Color Collections (defrecord FetchCollections [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rp/req :fetch/image-collections) (rx/map :payload) (rx/map collections-fetched)))) @@ -86,13 +86,13 @@ ;; --- Collection Created (defrecord CollectionCreated [item] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [{:keys [id] :as item} (assoc item :type :own)] (update state :images-collections assoc id item))) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (select-collection :own (:id item))))) (defn collection-created @@ -102,8 +102,8 @@ ;; --- Create Collection (defrecord CreateCollection [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [coll {:name "Unnamed collection" :id (uuid/random)}] (->> (rp/req :create/image-collection coll) @@ -121,8 +121,8 @@ ;; --- Collection Updated (defrecord CollectionUpdated [item] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:images-collections (:id item)] merge item))) (defn collection-updated @@ -132,8 +132,8 @@ ;; --- Update Collection (defrecord UpdateCollection [id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [item (get-in state [:images-collections id])] (->> (rp/req :update/image-collection item) (rx/map :payload) @@ -146,12 +146,12 @@ ;; --- Rename Collection (defrecord RenameCollection [id name] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:images-collections id :name] name)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (update-collection id)))) (defn rename-collection @@ -161,12 +161,12 @@ ;; --- Delete Collection (defrecord DeleteCollection [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update state :images-collections dissoc id)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [type (get-in state [:dashboard :images :type])] (->> (rp/req :delete/image-collection id) (rx/map #(select-collection type)))))) @@ -178,8 +178,8 @@ ;; --- Image Created (defrecord ImageCreated [item] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update state :images assoc (:id item) item))) (defn image-created @@ -191,12 +191,12 @@ (def allowed-file-types #{"image/jpeg" "image/png"}) (defrecord CreateImages [id files on-uploaded] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:dashboard :images :uploading] true)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (letfn [(image-size [file] (->> (files/get-image-size file) (rx/map (partial vector file)))) @@ -218,7 +218,7 @@ (rx/mapcat #(rp/req :create/image %)) (rx/map :payload) (rx/reduce conj []) - (rx/do #(rs/emit! finalize-upload)) + (rx/do #(st/emit! finalize-upload)) (rx/do on-uploaded) (rx/mapcat identity) (rx/map image-created))))) @@ -234,8 +234,8 @@ ;; --- Image Updated (defrecord ImagePersisted [id data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:images id] data))) (defn image-persisted @@ -246,8 +246,8 @@ ;; --- Update Image (defrecord PersistImage [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [image (get-in state [:images id])] (->> (rp/req :update/image image) (rx/map :payload) @@ -261,8 +261,8 @@ ;; --- Images Fetched (defrecord ImagesFetched [items] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (reduce (fn [state {:keys [id] :as image}] (assoc-in state [:images id] image)) state @@ -275,8 +275,8 @@ ;; --- Fetch Images (defrecord FetchImages [id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [params {:coll id}] (->> (rp/req :fetch/images params) (rx/map :payload) @@ -293,8 +293,8 @@ (declare image-fetched) (defrecord FetchImage [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [existing (get-in state [:images id])] (if existing (rx/empty) @@ -312,8 +312,8 @@ ;; --- Image Fetched (defrecord ImageFetched [image] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [id (:id image)] (update state :images assoc id image)))) @@ -325,14 +325,14 @@ ;; --- Delete Images (defrecord DeleteImage [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (-> state (update :images dissoc id) (update-in [:dashboard :images :selected] disj id))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rp/req :delete/image id) (rx/ignore)))) @@ -344,12 +344,12 @@ ;; --- Rename Image (defrecord RenameImage [id name] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:images id :name] name)) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (persist-image id)))) (defn rename-image @@ -360,18 +360,18 @@ ;; --- Select image (defrecord SelectImage [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :images :selected] conj id))) (defrecord DeselectImage [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :images :selected] disj id))) (defrecord ToggleImageSelection [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :images :selected])] (rx/of (if (selected id) @@ -390,8 +390,8 @@ ;; --- Copy Selected Image (defrecord CopySelected [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :images :selected])] (rx/merge (->> (rx/from-coll selected) @@ -409,16 +409,16 @@ ;; --- Move Selected Image (defrecord MoveSelected [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [selected (get-in state [:dashboard :images :selected])] (reduce (fn [state image] (assoc-in state [:images image :collection] id)) state selected))) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :images :selected])] (rx/merge (->> (rx/from-coll selected) @@ -434,8 +434,8 @@ ;; --- Delete Selected (defrecord DeleteSelected [] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [selected (get-in state [:dashboard :images :selected])] (->> (rx/from-coll selected) (rx/map delete-image))))) @@ -447,8 +447,8 @@ ;; --- Update Opts (Filtering & Ordering) (defrecord UpdateOpts [order filter edition] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :images] merge {:edition edition} (when order {:order order}) diff --git a/frontend/src/uxbox/main/data/lightbox.cljs b/frontend/src/uxbox/main/data/lightbox.cljs index c17b2439c..32da7aaba 100644 --- a/frontend/src/uxbox/main/data/lightbox.cljs +++ b/frontend/src/uxbox/main/data/lightbox.cljs @@ -7,13 +7,14 @@ (ns uxbox.main.data.lightbox (:require [beicon.core :as rx] [lentes.core :as l] - [uxbox.util.rstore :as rs])) + [potok.core :as ptk] + [uxbox.store :as st])) ;; --- Show Lightbox (defrecord ShowLightbox [name params] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [data (merge {:name name} params)] (assoc state :lightbox data)))) @@ -26,8 +27,8 @@ ;; --- Hide Lightbox (defrecord HideLightbox [] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (dissoc state :lightbox))) (defn hide-lightbox @@ -38,8 +39,8 @@ (defn open! [& args] - (rs/emit! (apply show-lightbox args))) + (st/emit! (apply show-lightbox args))) (defn close! [& args] - (rs/emit! (apply hide-lightbox args))) + (st/emit! (apply hide-lightbox args))) diff --git a/frontend/src/uxbox/main/data/messages.cljs b/frontend/src/uxbox/main/data/messages.cljs index fdf7bc6fc..485e4e8c7 100644 --- a/frontend/src/uxbox/main/data/messages.cljs +++ b/frontend/src/uxbox/main/data/messages.cljs @@ -8,8 +8,9 @@ (:require [cuerdas.core :as str] [beicon.core :as rx] [lentes.core :as l] - [uxbox.util.timers :as ts] - [uxbox.util.rstore :as rs])) + [potok.core :as ptk] + [uxbox.store :as st] + [uxbox.util.timers :as ts])) ;; --- Constants @@ -21,13 +22,13 @@ (declare show-message?) (defrecord ShowMessage [data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [message (assoc data :state :visible)] (assoc state :message message))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [stoper (->> (rx/filter show-message? s) (rx/take 1))] (->> (rx/of (hide-message)) @@ -65,16 +66,16 @@ ;; --- Hide Message (defrecord HideMessage [^:mutable canceled?] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update state :message (fn [v] (if (nil? v) (do (set! canceled? true) nil) (assoc v :state :hide))))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (if canceled? (rx/empty) (->> (rx/of #(dissoc state :message)) @@ -88,19 +89,19 @@ (defn error! [& args] - (ts/schedule 0 #(rs/emit! (apply show-error args)))) + (ts/schedule 0 #(st/emit! (apply show-error args)))) (defn info! [& args] - (ts/schedule 0 #(rs/emit! (apply show-info args)))) + (ts/schedule 0 #(st/emit! (apply show-info args)))) (defn dialog! [& args] - (ts/schedule 0 #(rs/emit! (apply show-dialog args)))) + (ts/schedule 0 #(st/emit! (apply show-dialog args)))) (defn close! [] - (rs/emit! (hide-message))) + (st/emit! (hide-message))) (defn error [& args] diff --git a/frontend/src/uxbox/main/data/pages.cljs b/frontend/src/uxbox/main/data/pages.cljs index bf4da546e..47584eb5f 100644 --- a/frontend/src/uxbox/main/data/pages.cljs +++ b/frontend/src/uxbox/main/data/pages.cljs @@ -10,9 +10,9 @@ [beicon.core :as rx] [lentes.core :as l] [uxbox.main.repo :as rp] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.util.spec :as us] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as r] [uxbox.util.i18n :refer (tr)] [uxbox.util.forms :as sc] @@ -99,8 +99,8 @@ ;; --- Pages Fetched (defrecord PagesFetched [pages] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (as-> state $ (reduce assoc-page $ pages) (reduce assoc-packed-page $ pages)))) @@ -112,8 +112,8 @@ ;; --- Fetch Pages (by project id) (defrecord FetchPages [projectid] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rp/req :fetch/pages-by-project {:project projectid}) (rx/map (comp ->PagesFetched :payload))))) @@ -124,8 +124,8 @@ ;; --- Page Created (defrecord PageCreated [data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (-> state (assoc-page data) (assoc-packed-page data)))) @@ -141,8 +141,8 @@ ;; --- Create Page (defrecord CreatePage [name project width height layout] - rs/WatchEvent - (-apply-watch [this state s] + ptk/WatchEvent + (watch [this state s] (let [params {:name name :project project :data {} @@ -164,8 +164,8 @@ ;; --- Page Persisted (defrecord PagePersisted [data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-page state data))) (defn- page-persisted? @@ -182,8 +182,8 @@ ;; --- Persist Page (defrecord PersistPage [id] - rs/WatchEvent - (-apply-watch [this state s] + ptk/WatchEvent + (watch [this state s] (let [page (get-in state [:pages id])] (if (:history page) (rx/empty) @@ -210,16 +210,16 @@ events with 1sec of delay allowing batch updates on fastly performed events." [id] - (as-> rs/stream $ + (as-> st/store $ (rx/filter #(satisfies? IPageUpdate %) $) (rx/debounce 1000 $) - (rx/on-next $ #(rs/emit! (persist-page id))))) + (rx/on-next $ #(st/emit! (persist-page id))))) ;; --- Page Metadata Persisted (defrecord MetadataPersisted [id data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] ;; TODO: page-data update (assoc-in state [:pages id :version] (:version data)))) @@ -238,8 +238,8 @@ ;; and only serves for update other page data. (defrecord PersistMetadata [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [page (get-in state [:pages id])] (->> (rp/req :update/page-metadata page) (rx/map :payload) @@ -253,12 +253,12 @@ ;; --- Update Page Options (defrecord UpdateMetadata [id metadata] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:pages id :metadata] metadata)) - rs/WatchEvent - (-apply-watch [this state s] + ptk/WatchEvent + (watch [this state s] (rx/of (persist-metadata id)))) (defn update-metadata @@ -269,8 +269,8 @@ ;; --- Update Page (defrecord UpdatePage [id name width height layout] - rs/UpdateEvent - (-apply-update [this state] + ptk/UpdateEvent + (update [this state] (println "update-page" this) (-> state (assoc-in [:pages id :name] name) @@ -278,8 +278,8 @@ (assoc-in [:pages id :metadata :height] height) (assoc-in [:pages id :metadata :layout] layout))) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (persist-metadata id)))) (s/def ::update-page-event @@ -293,8 +293,8 @@ ;; --- Delete Page (by id) (defrecord DeletePage [id callback] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (letfn [(on-success [_] #(purge-page % id))] (->> (rp/req :delete/page id) diff --git a/frontend/src/uxbox/main/data/projects.cljs b/frontend/src/uxbox/main/data/projects.cljs index 509a9ce2a..5568565cf 100644 --- a/frontend/src/uxbox/main/data/projects.cljs +++ b/frontend/src/uxbox/main/data/projects.cljs @@ -8,10 +8,10 @@ (ns uxbox.main.data.projects (:require [cuerdas.core :as str] [beicon.core :as rx] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.repo :as rp] [uxbox.main.data.pages :as udp] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as rt] [uxbox.util.i18n :refer (tr)] [uxbox.util.forms :as sc] @@ -54,12 +54,12 @@ (declare projects-fetched?) (defrecord Initialize [] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:dashboard :section] :dashboard/projects)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (fetch-projects)))) (defn initialize @@ -69,8 +69,8 @@ ;; --- Projects Fetched (defrecord ProjectsFetched [projects] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (as-> state $ (reduce assoc-project-page $ projects) (reduce assoc-project $ projects)))) @@ -86,8 +86,8 @@ ;; --- Fetch Projects (defrecord FetchProjects [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rp/req :fetch/projects) (rx/map :payload) (rx/map projects-fetched)))) @@ -99,8 +99,8 @@ ;; --- Project Persisted (defrecord ProjectPersisted [data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-project state data))) (defn project-persisted @@ -111,8 +111,8 @@ ;; --- Persist Project (defrecord PersistProject [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [project (get-in state [:projects id])] (->> (rp/req :update/project project) (rx/map :payload) @@ -126,12 +126,12 @@ ;; --- Rename Project (defrecord RenameProject [id name] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:projects id :name] name)) - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (rx/of (persist-project id)))) (defn rename-project @@ -142,8 +142,8 @@ ;; --- Delete Project (by id) (defrecord DeleteProject [id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (letfn [(on-success [_] #(dissoc-project % id))] (->> (rp/req :delete/project id) @@ -158,8 +158,8 @@ ;; --- Create Project (defrecord CreateProject [name width height layout] - rs/WatchEvent - (-apply-watch [this state s] + ptk/WatchEvent + (watch [this state s] (letfn [(on-success [{project :payload}] (rx/of (project-persisted project) @@ -185,8 +185,8 @@ ;; --- Go To & Go To Page (defrecord GoTo [project-id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [page-id (get-in state [:projects project-id :page-id]) params {:project project-id :page page-id}] @@ -194,8 +194,8 @@ (rt/navigate :workspace/page params))))) (defrecord GoToPage [project-id page-id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [params {:project project-id :page page-id}] (rx/of (rt/navigate :workspace/page params))))) @@ -214,8 +214,8 @@ ;; --- Update Opts (Filtering & Ordering) (defrecord UpdateOpts [order filter] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:dashboard :projects] merge (when order {:order order}) (when filter {:filter filter})))) diff --git a/frontend/src/uxbox/main/data/shapes.cljs b/frontend/src/uxbox/main/data/shapes.cljs index 3c59d2668..a164f3ea8 100644 --- a/frontend/src/uxbox/main/data/shapes.cljs +++ b/frontend/src/uxbox/main/data/shapes.cljs @@ -8,13 +8,13 @@ (ns uxbox.main.data.shapes (:require [beicon.core :as rx] [uxbox.util.uuid :as uuid] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as r] [uxbox.util.forms :as sc] [uxbox.util.workers :as uw] [uxbox.main.constants :as c] [uxbox.main.geom :as geom] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.core :refer (worker)] [uxbox.main.data.shapes-impl :as impl] [uxbox.main.data.pages :as udp] @@ -28,8 +28,8 @@ [shape] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [page (get-in state [:workspace :page]) shape (geom/setup-proportions shape)] (impl/assoc-shape-to-page state shape page))))) @@ -39,8 +39,8 @@ [id] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [shape (get-in state [:shapes id])] (impl/dissoc-shape state shape))))) @@ -49,8 +49,8 @@ [{:keys [id] :as shape}] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes id] merge shape)))) ;; --- Shape Transformations @@ -60,8 +60,8 @@ [sid delta] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [shape (get-in state [:shapes sid])] (update-in state [:shapes sid] geom/move delta))))) @@ -74,8 +74,8 @@ (defn initial-align-shape [id] (reify - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes id]) shape (geom/outer-rect state shape) point (gpt/point (:x shape) (:y shape)) @@ -88,8 +88,8 @@ [sid {:keys [x1 y1 x2 y2] :as opts}] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [shape (get-in state [:shapes sid]) props (select-keys opts [:x1 :y1 :x2 :y2]) props' (select-keys shape [:x1 :y1 :x2 :y2])] @@ -103,8 +103,8 @@ (>= 360 rotation)]} (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes sid] geom/rotate rotation)))) @@ -116,23 +116,23 @@ {:pre [(uuid? sid)]} (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes sid] geom/resize-dim opts)))) (defn update-vertex-position [id {:keys [vid delta]}] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes id] geom/move-vertex vid delta)))) (defn initial-vertext-align [id vid] (reify - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes id]) point (geom/get-vertex-point shape vid) point (gpt/add point canvas-coords)] @@ -144,8 +144,8 @@ "Update the start position coordenate of the shape." [sid {:keys [x y] :as opts}] (reify - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes sid] geom/absolute-move opts)))) (defn update-text @@ -153,16 +153,16 @@ {:pre [(string? content)]} (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:shapes sid :content] content)))) (defn update-fill-attrs [sid {:keys [color opacity] :as opts}] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes sid] merge (when color {:fill color}) @@ -173,8 +173,8 @@ letter-spacing line-height] :as opts}] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes sid :font] merge (when line-height {:line-height line-height}) @@ -189,8 +189,8 @@ [sid {:keys [color opacity type width] :as opts}] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes sid] merge (when type {:stroke-type type}) @@ -202,8 +202,8 @@ [sid {:keys [rx ry] :as opts}] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes sid] merge (when rx {:rx rx}) @@ -219,8 +219,8 @@ {:pre [(uuid? sid)]} (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [[width height] (-> (get-in state [:shapes sid]) (geom/size) (keep [:width :height])) @@ -234,8 +234,8 @@ {:pre [(uuid? sid)]} (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes sid] assoc :proportion-lock false)))) @@ -246,8 +246,8 @@ {:pre [(uuid? id)]} (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes id] assoc :collapsed true)))) (defn uncollapse-shape @@ -255,8 +255,8 @@ {:pre [(uuid? id)]} (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes id] assoc :collapsed false)))) ;; --- Shape Visibility @@ -265,12 +265,12 @@ [sid] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:shapes sid :hidden] true)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes sid])] (if-not (= (:type shape) :group) (rx/empty) @@ -281,12 +281,12 @@ [sid] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:shapes sid :hidden] false)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes sid])] (if-not (= (:type shape) :group) (rx/empty) @@ -297,12 +297,12 @@ [sid] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:shapes sid :blocked] true)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes sid])] (if-not (= (:type shape) :group) (rx/empty) @@ -313,12 +313,12 @@ [sid] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:shapes sid :blocked] false)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes sid])] (if-not (= (:type shape) :group) (rx/empty) @@ -329,12 +329,12 @@ [sid] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:shapes sid :locked] true)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes sid])] (if-not (= (:type shape) :group) (rx/empty) @@ -345,12 +345,12 @@ [sid] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:shapes sid :locked] false)) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes sid])] (if-not (= (:type shape) :group) (rx/empty) @@ -365,16 +365,16 @@ (not (nil? sid))]} (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (impl/drop-shape state sid tid loc)))) (defn select-first-shape "Mark a shape selected for drawing in the canvas." [] (reify - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [page (get-in state [:workspace :page]) id (first (get-in state [:pages page :shapes]))] (assoc-in state [:workspace :selected] #{id}))))) @@ -383,8 +383,8 @@ "Mark a shape selected for drawing in the canvas." [id] (reify - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [selected (get-in state [:workspace :selected]) state (if (contains? selected id) (update-in state [:workspace :selected] disj id) @@ -394,8 +394,8 @@ ;; --- Select Shapes (defrecord SelectShapes [selrect] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [page (get-in state [:workspace :page]) shapes (impl/match-by-selrect state page selrect)] (assoc-in state [:workspace :selected] shapes)))) @@ -409,8 +409,8 @@ (defrecord UpdateInteraction [shape interaction] udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [id (or (:id interaction) (uuid/random)) data (assoc interaction :id id)] @@ -424,8 +424,8 @@ (defrecord DeleteInteracton [shape id] udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes shape :interactions] dissoc id))) (defn delete-interaction @@ -436,8 +436,8 @@ ;; --- Path Modifications (defrecord UpdatePath [id index delta] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:shapes id :points index] gpt/add delta))) (defn update-path @@ -447,8 +447,8 @@ (UpdatePath. id index delta)) (defrecord InitialPathPointAlign [id index] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [shape (get-in state [:shapes id]) point (get-in shape [:points index]) point (gpt/add point canvas-coords)] @@ -468,12 +468,12 @@ ;; --- Start shape "edition mode" (defrecord StartEditionMode [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:workspace :edition] id)) - rs/EffectEvent - (-apply-effect [_ state] + ptk/EffectEvent + (effect [_ state stream] (rlocks/acquire! :shape/edition))) (defn start-edition-mode @@ -484,15 +484,15 @@ ;; --- Events (implicit) (for selected) (defrecord DeselectAll [] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (-> state (assoc-in [:workspace :selected] #{}) (assoc-in [:workspace :edition] nil) (assoc-in [:workspace :drawing] nil))) - rs/EffectEvent - (-apply-effect [_ state] + ptk/EffectEvent + (effect [_ state stream] (rlocks/release! :shape/edition))) (defn deselect-all @@ -505,8 +505,8 @@ [] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [pid (get-in state [:workspace :page]) selected (get-in state [:workspace :selected])] (impl/group-shapes state selected pid))))) @@ -515,8 +515,8 @@ [] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [pid (get-in state [:workspace :page]) selected (get-in state [:workspace :selected])] (impl/degroup-shapes state selected pid))))) @@ -526,8 +526,8 @@ [] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [selected (get-in state [:workspace :selected])] (impl/duplicate-shapes state selected))))) @@ -535,8 +535,8 @@ "Deselect all and remove all selected shapes." [] (reify - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [selected (get-in state [:workspace :selected])] (rx/from-coll (into [(deselect-all)] (map #(delete-shape %) selected))))))) @@ -547,8 +547,8 @@ ([dir n] {:pre [(contains? #{:up :down :right :left} dir)]} (reify - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [selected (get-in state [:workspace :selected]) delta (case dir :up (gpt/point 0 (- n)) @@ -563,8 +563,8 @@ selected shapes." [opts] (reify - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/from-coll (->> (get-in state [:workspace :selected]) (map #(update-fill-attrs % opts))))))) @@ -575,8 +575,8 @@ selected shapes." [opts] (reify - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/from-coll (->> (get-in state [:workspace :selected]) (map #(update-stroke-attrs % opts))))))) @@ -585,8 +585,8 @@ [loc] (reify udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [selected (get-in state [:workspace :selected])] (impl/move-layer state selected loc))))) diff --git a/frontend/src/uxbox/main/data/undo.cljs b/frontend/src/uxbox/main/data/undo.cljs index d102297ac..1b87c5c42 100644 --- a/frontend/src/uxbox/main/data/undo.cljs +++ b/frontend/src/uxbox/main/data/undo.cljs @@ -7,9 +7,9 @@ (ns uxbox.main.data.undo (:require #_[cljs.pprint :as pp] [beicon.core :as rx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.main.data.pages :as udp] - [uxbox.main.state :as st])) + [uxbox.store :as st])) ;; --- Watch Page Changes @@ -25,26 +25,26 @@ reacts on them emiting an other event that just persists the state of the page in an undo stack." [id] - (rs/emit! (initialize-undo-for-page id)) - (as-> rs/stream $ + (st/emit! (initialize-undo-for-page id)) + (as-> st/store $ (rx/filter #(satisfies? udp/IPageUpdate %) $) (rx/filter #(not (undo? %)) $) (rx/filter #(not (redo? %)) $) (rx/debounce 500 $) - (rx/on-next $ #(rs/emit! (save-undo-entry id))))) + (rx/on-next $ #(st/emit! (save-undo-entry id))))) ;; -- Save Undo Entry (defrecord SaveUndoEntry [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [page (udp/pack-page state id)] (-> state (update-in [:undo id :stack] #(cons (:data page) %)) (assoc-in [:undo id :selected] 0))))) - ;; rs/EffectEvent - ;; (-apply-effect [_ state] + ;; ptk/EffectEvent + ;; (effect [_ state] ;; (let [undo (get-in state [:undo id])] ;; (println (pr-str undo))))) @@ -59,8 +59,8 @@ ;; --- Initialize Undo (For page) (defrecord InitializeUndoForPage [id] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [initialized? (get-in state [:undo id]) page-loaded? (get-in state [:pages id])] (cond @@ -84,8 +84,8 @@ (defrecord Undo [] udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [page-id (get-in state [:workspace :page]) undo (get-in state [:undo page-id]) stack (:stack undo) @@ -117,8 +117,8 @@ (defrecord Redo [] udp/IPageUpdate - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [page-id (get-in state [:workspace :page]) undo (get-in state [:undo page-id]) stack (:stack undo) diff --git a/frontend/src/uxbox/main/data/users.cljs b/frontend/src/uxbox/main/data/users.cljs index c925b6838..518e20236 100644 --- a/frontend/src/uxbox/main/data/users.cljs +++ b/frontend/src/uxbox/main/data/users.cljs @@ -7,10 +7,9 @@ (ns uxbox.main.data.users (:require [cljs.spec :as s] [beicon.core :as rx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.spec :as us] [uxbox.util.i18n :refer (tr)] - [uxbox.main.state :as st] [uxbox.main.repo :as rp] [uxbox.main.data.messages :as udm])) @@ -22,8 +21,8 @@ ;; --- Profile Fetched (defrecord ProfileFetched [data] - rs/UpdateEvent - (-apply-update [this state] + ptk/UpdateEvent + (update [this state] (assoc state :profile data))) (defn profile-fetched @@ -33,8 +32,8 @@ ;; --- Fetch Profile (defrecord FetchProfile [] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (->> (rp/req :fetch/profile) (rx/map :payload) (rx/map profile-fetched)))) @@ -46,12 +45,12 @@ ;; --- Profile Updated (defrecord ProfileUpdated [data] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (profile-fetched data))) - rs/EffectEvent - (-apply-effect [_ state] + ptk/EffectEvent + (effect [_ state stream] (udm/info! (tr "settings.profile-saved")))) (defn profile-updated @@ -61,8 +60,8 @@ ;; --- Update Profile (defrecord UpdateProfile [data on-success on-error] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (letfn [(handle-error [{payload :payload}] (on-error payload) (rx/empty))] @@ -85,8 +84,8 @@ ;; --- Password Updated (defrecord PasswordUpdated [] - rs/EffectEvent - (-apply-effect [_ state] + ptk/EffectEvent + (effect [_ state stream] (udm/info! (tr "settings.password-saved")))) (defn password-updated @@ -96,8 +95,8 @@ ;; --- Update Password (Form) (defrecord UpdatePassword [data] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [params {:old-password (:old-password data) :password (:password-1 data)}] (->> (rp/req :update/profile-password params) @@ -118,8 +117,8 @@ ;; --- Update Photo (defrecord UpdatePhoto [file done] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (->> (rp/req :update/profile-photo {:file file}) (rx/do done) (rx/map fetch-profile)))) diff --git a/frontend/src/uxbox/main/data/workspace.cljs b/frontend/src/uxbox/main/data/workspace.cljs index af9d7b85c..7004835d3 100644 --- a/frontend/src/uxbox/main/data/workspace.cljs +++ b/frontend/src/uxbox/main/data/workspace.cljs @@ -9,12 +9,12 @@ [beicon.core :as rx] [uxbox.util.uuid :as uuid] [uxbox.main.constants :as c] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.spec :as us] [uxbox.util.forms :as sc] [uxbox.util.geom.point :as gpt] [uxbox.util.workers :as uw] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.core :refer (worker)] [uxbox.main.data.projects :as dp] [uxbox.main.data.pages :as udp] @@ -40,8 +40,8 @@ (declare initialize-alignment-index) (defrecord InitializeWorkspace [project page] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (if (:workspace state) (update state :workspace merge {:project project @@ -56,8 +56,8 @@ :selected #{} :drawing nil}))) - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [page-id page page (get-in state [:pages page-id])] @@ -79,11 +79,11 @@ (udh/fetch-page-history page-id) (udh/fetch-pinned-page-history page-id))))) - rs/EffectEvent - (-apply-effect [_ state] + ptk/EffectEvent + (effect [_ state stream] ;; Optimistic prefetch of projects if them are not already fetched (when-not (seq (:projects state)) - (rs/emit! (dp/fetch-projects))))) + (st/emit! (dp/fetch-projects))))) (defn initialize "Initialize the workspace state." @@ -96,8 +96,8 @@ "Toggle the enabled flag of the specified tool." [key] (reify - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [flags (get-in state [:workspace :flags])] (if (contains? flags key) (assoc-in state [:workspace :flags] (disj flags key)) @@ -107,8 +107,8 @@ "Mark a shape selected for drawing in the canvas." [shape] (reify - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [current (get-in state [:workspace :drawing])] (if (or (nil? shape) (= shape current)) @@ -118,8 +118,8 @@ ;; --- Activate Workspace Flag (defrecord ActivateFlag [flag] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (update-in state [:workspace :flags] conj flag))) (defn activate-flag @@ -129,8 +129,8 @@ ;; --- Copy to Clipboard (defrecord CopyToClipboard [] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [selected (get-in state [:workspace :selected]) item {:id (uuid/random) :created-at (dt/now) @@ -150,8 +150,8 @@ ;; --- Paste from Clipboard (defrecord PasteFromClipboard [id] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [page (get-in state [:workspace :page]) selected (if (nil? id) (first (:clipboard state)) @@ -168,8 +168,8 @@ ;; --- Increase Zoom (defrecord IncreaseZoom [] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [increase #(nth zoom-levels (+ (index-of zoom-levels %) 1) (last zoom-levels))] @@ -182,8 +182,8 @@ ;; --- Decrease Zoom (defrecord DecreaseZoom [] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [decrease #(nth zoom-levels (- (index-of zoom-levels %) 1) (first zoom-levels))] @@ -196,8 +196,8 @@ ;; --- Reset Zoom (defrecord ResetZoom [] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:workspace :zoom] 1))) (defn reset-zoom @@ -207,8 +207,8 @@ ;; --- Initialize Alignment Index (defrecord InitializeAlignmentIndex [id] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (let [page (get-in state [:pages id]) opts (:options page) message {:cmd :grid-init @@ -231,8 +231,8 @@ ;; Is a workspace aware wrapper over uxbox.data.pages/UpdateMetadata event. (defrecord UpdateMetadata [id metadata] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (udp/update-metadata id metadata) (initialize-alignment-index id)))) diff --git a/frontend/src/uxbox/main/exports.cljs b/frontend/src/uxbox/main/exports.cljs index 4cf774fde..a1789a7fc 100644 --- a/frontend/src/uxbox/main/exports.cljs +++ b/frontend/src/uxbox/main/exports.cljs @@ -6,7 +6,7 @@ (ns uxbox.main.exports "The main logic for SVG export functionality." - (:require [uxbox.main.state :as st] + (:require [uxbox.store :as st] [uxbox.main.ui.shapes.rect :refer (rect-shape)] [uxbox.main.ui.shapes.icon :refer (icon-shape)] [uxbox.main.ui.shapes.text :refer (text-shape)] diff --git a/frontend/src/uxbox/main/geom.cljs b/frontend/src/uxbox/main/geom.cljs index 618649f1c..39962143a 100644 --- a/frontend/src/uxbox/main/geom.cljs +++ b/frontend/src/uxbox/main/geom.cljs @@ -8,7 +8,7 @@ (:require [uxbox.util.geom.matrix :as gmt] [uxbox.util.geom.point :as gpt] [uxbox.util.math :as mth] - [uxbox.main.state :as st])) + [uxbox.store :as st])) ;; --- Relative Movement diff --git a/frontend/src/uxbox/main/state.cljs b/frontend/src/uxbox/main/state.cljs index a1d1c1c63..5e3cc7dac 100644 --- a/frontend/src/uxbox/main/state.cljs +++ b/frontend/src/uxbox/main/state.cljs @@ -5,21 +5,8 @@ ;; Copyright (c) 2015-2016 Andrey Antukh (ns uxbox.main.state - (:require [beicon.core :as rx] - [lentes.core :as l] - [uxbox.main.state.colors :as colors] - [uxbox.util.rstore :as rs] - [uxbox.util.i18n :refer (tr)] - [uxbox.util.storage :refer (storage)])) - -(enable-console-print!) - -(defonce state (atom {})) -(defonce loader (atom false)) - -(def auth-ref - (-> (l/key :auth) - (l/derive state))) + (:require [uxbox.builtins.colors :as colors] + [uxbox.util.storage :refer [storage]])) (defn initial-state [] @@ -41,11 +28,3 @@ :shapes nil :projects nil :pages nil}) - -(defn init - "Initialize the state materialization." - ([] (init initial-state)) - ([& callbacks] - (-> (reduce #(merge %1 (%2)) nil callbacks) - (rs/init) - (rx/to-atom state)))) diff --git a/frontend/src/uxbox/main/ui.cljs b/frontend/src/uxbox/main/ui.cljs index c38f57790..a7c281fe5 100644 --- a/frontend/src/uxbox/main/ui.cljs +++ b/frontend/src/uxbox/main/ui.cljs @@ -10,7 +10,7 @@ [lentes.core :as l] [cuerdas.core :as str] [bide.core :as bc] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.projects :as dp] [uxbox.main.data.users :as udu] [uxbox.main.data.auth :refer [logout]] @@ -24,7 +24,7 @@ [uxbox.main.ui.workspace :refer (workspace)] [uxbox.util.timers :as ts] [uxbox.util.router :as rt] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.i18n :refer (tr)] [uxbox.util.data :refer (parse-int uuid-str?)] [uxbox.util.dom :as dom] @@ -52,12 +52,13 @@ "A default error handler." [{:keys [status] :as error}] (js/console.log "on-error:" (pr-str error)) + (reset! st/loader false) (cond ;; Unauthorized or Auth timeout (and (:status error) (or (= (:status error) 403) (= (:status error) 419))) - (rs/emit! (logout)) + (st/emit! (logout)) ;; Conflict (= status 412) @@ -75,14 +76,14 @@ (dmsg/error! (tr "errors.generic")) (js/console.error "Stack:" (.-stack error))))) -(rs/add-error-watcher :ui on-error) +(set! st/*on-error* on-error) ;; --- Main App (Component) (defn app-will-mount [own] (when @st/auth-ref - (rs/emit! (udu/fetch-profile))) + (st/emit! (udu/fetch-profile))) own) (mx/defc app diff --git a/frontend/src/uxbox/main/ui/auth/login.cljs b/frontend/src/uxbox/main/ui/auth/login.cljs index 65a32864e..98e57505a 100644 --- a/frontend/src/uxbox/main/ui/auth/login.cljs +++ b/frontend/src/uxbox/main/ui/auth/login.cljs @@ -9,10 +9,10 @@ [cuerdas.core :as str] [uxbox.util.router :as rt] [uxbox.util.dom :as dom] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.forms :as forms] [uxbox.util.mixins :as mx :include-macros true] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.auth :as da] [uxbox.main.data.messages :as udm] [uxbox.main.ui.icons :as i] @@ -42,7 +42,7 @@ (set-value! field value))) (on-submit [event] (dom/prevent-default event) - (rs/emit! (da/login {:username (:email data) + (st/emit! (da/login {:username (:email data) :password (:password data)})))] [:form {:on-submit on-submit} [:div.login-content diff --git a/frontend/src/uxbox/main/ui/auth/recovery.cljs b/frontend/src/uxbox/main/ui/auth/recovery.cljs index 1ec34c8df..19092e63d 100644 --- a/frontend/src/uxbox/main/ui/auth/recovery.cljs +++ b/frontend/src/uxbox/main/ui/auth/recovery.cljs @@ -8,8 +8,8 @@ (:require [lentes.core :as l] [cuerdas.core :as str] [uxbox.util.router :as rt] - [uxbox.main.state :as st] - [uxbox.util.rstore :as rs] + [uxbox.store :as st] + [potok.core :as ptk] [uxbox.util.forms :as forms] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.dom :as dom] @@ -38,7 +38,7 @@ (set-value! field value))) (on-submit [event] (dom/prevent-default event) - (rs/emit! (uda/recovery data) + (st/emit! (uda/recovery data) (forms/clear :recovery)))] [:form {:on-submit on-submit} [:div.login-content @@ -62,7 +62,7 @@ (defn- recovery-page-will-mount [own] (let [[token] (:rum/args own)] - (rs/emit! (uda/validate-recovery-token token)) + (st/emit! (uda/validate-recovery-token token)) own)) (mx/defc recovery-page diff --git a/frontend/src/uxbox/main/ui/auth/recovery_request.cljs b/frontend/src/uxbox/main/ui/auth/recovery_request.cljs index b186d850f..60e402363 100644 --- a/frontend/src/uxbox/main/ui/auth/recovery_request.cljs +++ b/frontend/src/uxbox/main/ui/auth/recovery_request.cljs @@ -8,11 +8,11 @@ (:require [lentes.core :as l] [cuerdas.core :as str] [uxbox.util.router :as rt] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.forms :as forms] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.dom :as dom] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.auth :as uda] [uxbox.main.data.messages :as udm] [uxbox.main.ui.icons :as i] @@ -35,7 +35,7 @@ (set-value! field value))) (on-submit [event] (dom/prevent-default event) - (rs/emit! (uda/recovery-request data) + (st/emit! (uda/recovery-request data) (forms/clear :recovery-request)))] [:form {:on-submit on-submit} [:div.login-content diff --git a/frontend/src/uxbox/main/ui/auth/register.cljs b/frontend/src/uxbox/main/ui/auth/register.cljs index 2fd37592f..e49ce49f5 100644 --- a/frontend/src/uxbox/main/ui/auth/register.cljs +++ b/frontend/src/uxbox/main/ui/auth/register.cljs @@ -8,11 +8,11 @@ (:require [lentes.core :as l] [cuerdas.core :as str] [uxbox.util.router :as rt] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.forms :as forms] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.dom :as dom] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.auth :as uda] [uxbox.main.data.messages :as udm] [uxbox.main.ui.icons :as i] @@ -49,7 +49,7 @@ (set-error! :username "Username already exists"))) (on-submit [event] (dom/prevent-default event) - (rs/emit! (uda/register data on-error)))] + (st/emit! (uda/register data on-error)))] [:form {:on-submit on-submit} [:div.login-content [:input.input-text diff --git a/frontend/src/uxbox/main/ui/dashboard/colors.cljs b/frontend/src/uxbox/main/ui/dashboard/colors.cljs index b0268838e..68e59afe5 100644 --- a/frontend/src/uxbox/main/ui/dashboard/colors.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/colors.cljs @@ -11,7 +11,7 @@ [uxbox.main.data.colors :as dc] [uxbox.main.data.dashboard :as dd] [uxbox.main.data.lightbox :as udl] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.ui.messages :as uum] [uxbox.main.ui.colorpicker :refer (colorpicker)] [uxbox.main.ui.dashboard.header :refer (header)] @@ -23,7 +23,7 @@ [uxbox.util.i18n :as t :refer (tr)] [uxbox.util.lens :as ul] [uxbox.util.mixins :as mx :include-macros true] - [uxbox.util.rstore :as rs])) + [potok.core :as ptk])) ;; --- Refs @@ -47,7 +47,7 @@ (letfn [(save [] (let [dom (mx/ref-node own "input") name (dom/get-inner-text dom)] - (rs/emit! (dc/rename-collection id (str/trim name))) + (st/emit! (dc/rename-collection id (str/trim name))) (swap! local assoc :edit false))) (cancel [] (swap! local assoc :edit false)) @@ -62,7 +62,7 @@ (dom/stop-propagation e) (save)))) (delete [] - (rs/emit! (dc/delete-collection id))) + (st/emit! (dc/delete-collection id))) (on-delete [] (udl/open! :confirm {:on-accept delete}))] [:div.dashboard-title @@ -95,7 +95,7 @@ [{:keys [id type name] :as coll} selected?] (letfn [(on-click [event] (let [type (or type :own)] - (rs/emit! (dc/select-collection type id))))] + (st/emit! (dc/select-collection type id))))] (let [colors (count (:colors coll))] [:li {:on-click on-click :class-name (when selected? "current")} @@ -113,7 +113,7 @@ {:mixins [mx/static mx/reactive]} [selected?] (let [num-colors (mx/react storage-num-colors-ref) - on-click #(rs/emit! (dc/select-collection :own nil))] + on-click #(st/emit! (dc/select-collection :own nil))] [:li {:on-click on-click :class (when selected? "current")} [:span.element-title "Storage"] [:span.element-subtitle @@ -133,7 +133,7 @@ (when own? [:li [:a.btn-primary - {:on-click #(rs/emit! (dc/create-collection))} + {:on-click #(st/emit! (dc/create-collection))} "+ New library"]]) (when own? (nav-item-storage (nil? selected))) @@ -150,14 +150,14 @@ builtin? (= type :builtin)] (letfn [(select-tab [type] (if (= type :own) - (rs/emit! (dc/select-collection type)) + (st/emit! (dc/select-collection type)) (let [coll (->> (map second colls) (filter #(= type (:type %))) (sort-by :created-at) (first))] (if coll - (rs/emit! (dc/select-collection type (:id coll))) - (rs/emit! (dc/select-collection type))))))] + (st/emit! (dc/select-collection type (:id coll))) + (st/emit! (dc/select-collection type))))))] [:div.library-bar [:div.library-bar-inside [:ul.library-tabs @@ -207,7 +207,7 @@ (let [editable? (or (= type :own) (nil? id)) local (:rum/local own)] (letfn [(delete [event] - (rs/emit! (dc/delete-selected-colors))) + (st/emit! (dc/delete-selected-colors))) (on-delete [event] (udl/open! :confirm {:on-accept delete})) (on-toggle-copy [event] @@ -220,12 +220,12 @@ (swap! local assoc :show-move-tooltip false :show-copy-tooltip false) - (rs/emit! (dc/copy-selected selected))) + (st/emit! (dc/copy-selected selected))) (on-move [selected] (swap! local assoc :show-move-tooltip false :show-copy-tooltip false) - (rs/emit! (dc/move-selected id selected)))] + (st/emit! (dc/move-selected id selected)))] ;; MULTISELECT OPTIONS BAR [:div.multiselect-bar @@ -263,7 +263,7 @@ [color selected?] (let [color-rgb (hex->rgb color)] (letfn [(toggle-selection [event] - (rs/emit! (dc/toggle-color-selection color))) + (st/emit! (dc/toggle-color-selection color))) (toggle-selection-shifted [event] (when (k/shift? event) (toggle-selection event)))] @@ -307,7 +307,7 @@ (defn- colors-page-will-mount [own] (let [[type id] (:rum/args own)] - (rs/emit! (dc/initialize type id)) + (st/emit! (dc/initialize type id)) own)) (defn- colors-page-did-remount @@ -316,7 +316,7 @@ [new-type new-id] (:rum/args own)] (when (or (not= old-type new-type) (not= old-id new-id)) - (rs/emit! (dc/initialize new-type new-id))) + (st/emit! (dc/initialize new-type new-id))) own)) (mx/defc colors-page @@ -344,7 +344,7 @@ (let [params {:id coll :from color :to (:hex @local)}] - (rs/emit! (dc/replace-color params)) + (st/emit! (dc/replace-color params)) (udl/close!))) (on-change [event] (let [value (str/trim (dom/event->value event))] diff --git a/frontend/src/uxbox/main/ui/dashboard/elements.cljs b/frontend/src/uxbox/main/ui/dashboard/elements.cljs index f1e0df447..3eb102c80 100644 --- a/frontend/src/uxbox/main/ui/dashboard/elements.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/elements.cljs @@ -8,7 +8,7 @@ (ns uxbox.main.ui.dashboard.elements (:require [sablono.core :as html :refer-macros [html]] [rum.core :as rum] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.main.data.dashboard :as dd] [uxbox.main.data.lightbox :as udl] [uxbox.main.ui.icons :as i] @@ -144,12 +144,12 @@ ;; (defn elements-page-will-mount ;; [own] -;; (rs/emit! (dd/initialize :dashboard/elements)) +;; (st/emit! (dd/initialize :dashboard/elements)) ;; own) ;; (defn elements-page-did-remount ;; [old-state state] -;; (rs/emit! (dd/initialize :dashboard/elements)) +;; (st/emit! (dd/initialize :dashboard/elements)) ;; state) ;; (def elements-page diff --git a/frontend/src/uxbox/main/ui/dashboard/header.cljs b/frontend/src/uxbox/main/ui/dashboard/header.cljs index 19dc2b01f..e2208e061 100644 --- a/frontend/src/uxbox/main/ui/dashboard/header.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/header.cljs @@ -7,7 +7,7 @@ (ns uxbox.main.ui.dashboard.header (:require [lentes.core :as l] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.projects :as dp] [uxbox.main.ui.navigation :as nav] [uxbox.main.ui.icons :as i] @@ -15,7 +15,7 @@ [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] [uxbox.util.mixins :as mx :include-macros true] - [uxbox.util.rstore :as rs])) + [potok.core :as ptk])) (def header-ref (-> (l/key :dashboard) diff --git a/frontend/src/uxbox/main/ui/dashboard/icons.cljs b/frontend/src/uxbox/main/ui/dashboard/icons.cljs index 820478b92..c69b29e25 100644 --- a/frontend/src/uxbox/main/ui/dashboard/icons.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/icons.cljs @@ -8,7 +8,7 @@ (ns uxbox.main.ui.dashboard.icons (:require [lentes.core :as l] [cuerdas.core :as str] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.lightbox :as udl] [uxbox.main.data.icons :as di] [uxbox.main.ui.icons :as i] @@ -20,7 +20,7 @@ [uxbox.util.data :refer (read-string)] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.datetime :as dt] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.forms :as sc] [uxbox.util.lens :as ul] [uxbox.util.i18n :refer (tr)] @@ -78,7 +78,7 @@ (letfn [(on-save [e] (let [dom (mx/ref-node own "input") name (.-innerText dom)] - (rs/emit! (di/rename-collection id (str/trim name))) + (st/emit! (di/rename-collection id (str/trim name))) (swap! local assoc :edit false))) (on-cancel [e] (swap! local assoc :edit false)) @@ -93,7 +93,7 @@ (dom/stop-propagation e) (on-save e)))) (delete [] - (rs/emit! (di/delete-collection id))) + (st/emit! (di/delete-collection id))) (on-delete [] (udl/open! :confirm {:on-accept delete}))] [:div.dashboard-title @@ -133,7 +133,7 @@ [{:keys [id type name num-icons] :as coll} selected?] (letfn [(on-click [event] (let [type (or type :own)] - (rs/emit! (di/select-collection type id))))] + (st/emit! (di/select-collection type id))))] (let [num-icons (or num-icons (react-count-icons id))] [:li {:on-click on-click :class-name (when selected? "current")} @@ -155,7 +155,7 @@ (when own? [:li [:a.btn-primary - {:on-click #(rs/emit! (di/create-collection))} + {:on-click #(st/emit! (di/create-collection))} "+ New collection"]]) (when own? (nav-item nil (nil? selected))) @@ -175,8 +175,8 @@ (let [colls (->> (map second colls) (filter #(= :builtin (:type %))) (sort-by :name))] - (rs/emit! (di/select-collection type (:id (first colls))))) - (rs/emit! (di/select-collection type))))] + (st/emit! (di/select-collection type (:id (first colls))))) + (st/emit! (di/select-collection type))))] [:div.library-bar [:div.library-bar-inside [:ul.library-tabs @@ -198,7 +198,7 @@ (dom/click (mx/ref-node own "file-input"))) (on-file-selected [event] (let [files (dom/get-event-files event)] - (rs/emit! (di/create-icons coll-id files))))] + (st/emit! (di/create-icons coll-id files))))] [:div.grid-item.small-item.add-project {:on-click forward-click} [:span "+ New icon"] [:input.upload-image-input @@ -240,7 +240,7 @@ (let [editable? (or (= type :own) (nil? coll)) local (:rum/local own)] (letfn [(delete [] - (rs/emit! (di/delete-selected))) + (st/emit! (di/delete-selected))) (on-delete [event] (udl/open! :confirm {:on-accept delete})) (on-toggle-copy [event] @@ -252,15 +252,15 @@ (swap! local assoc :show-move-tooltip false :show-copy-tooltip false) - (rs/emit! (di/copy-selected selected))) + (st/emit! (di/copy-selected selected))) (on-move [selected] (swap! local assoc :show-move-tooltip false :show-copy-tooltip false) - (rs/emit! (di/move-selected selected))) + (st/emit! (di/move-selected selected))) (on-rename [event] (let [selected (first selected)] - (rs/emit! (di/update-opts :edition selected))))] + (st/emit! (di/update-opts :edition selected))))] ;; MULTISELECT OPTIONS BAR [:div.multiselect-bar (if editable? @@ -301,7 +301,7 @@ {:mixins [mx/static]} [{:keys [id created-at] :as icon} selected? edition?] (letfn [(toggle-selection [event] - (rs/emit! (di/toggle-icon-selection id))) + (st/emit! (di/toggle-icon-selection id))) (toggle-selection-shifted [event] (when (kbd/shift? event) (toggle-selection event))) @@ -311,12 +311,12 @@ (on-blur [event] (let [target (dom/event->target event) name (dom/get-value target)] - (rs/emit! (di/update-opts :edition false) + (st/emit! (di/update-opts :edition false) (di/rename-icon id name)))) (on-edit [event] (dom/stop-propagation event) (dom/prevent-default event) - (rs/emit! (di/update-opts :edition id)))] + (st/emit! (di/update-opts :edition id)))] [:div.grid-item.small-item.project-th {:on-click toggle-selection-shifted :id (str "grid-item-" id)} @@ -381,13 +381,13 @@ (letfn [(on-term-change [event] (let [term (-> (dom/get-target event) (dom/get-value))] - (rs/emit! (di/update-opts :filter term)))) + (st/emit! (di/update-opts :filter term)))) (on-ordering-change [event] (let [value (dom/event->value event) value (read-string value)] - (rs/emit! (di/update-opts :order value)))) + (st/emit! (di/update-opts :order value)))) (on-clear [event] - (rs/emit! (di/update-opts :filter "")))] + (st/emit! (di/update-opts :filter "")))] [:section.dashboard-bar.library-gap [:div.dashboard-info @@ -420,7 +420,7 @@ (defn- icons-page-will-mount [own] (let [[type id] (:rum/args own)] - (rs/emit! (di/initialize type id)) + (st/emit! (di/initialize type id)) own)) (defn- icons-page-did-remount @@ -429,7 +429,7 @@ [new-type new-id] (:rum/args own)] (when (or (not= old-type new-type) (not= old-id new-id)) - (rs/emit! (di/initialize new-type new-id))) + (st/emit! (di/initialize new-type new-id))) own)) (mx/defc icons-page diff --git a/frontend/src/uxbox/main/ui/dashboard/images.cljs b/frontend/src/uxbox/main/ui/dashboard/images.cljs index a5f7606ce..194fe18bd 100644 --- a/frontend/src/uxbox/main/ui/dashboard/images.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/images.cljs @@ -9,8 +9,8 @@ (:require [cuerdas.core :as str] [lentes.core :as l] [uxbox.util.i18n :as t :refer (tr)] - [uxbox.main.state :as st] - [uxbox.util.rstore :as rs] + [uxbox.store :as st] + [potok.core :as ptk] [uxbox.main.data.lightbox :as udl] [uxbox.main.data.images :as di] [uxbox.main.ui.icons :as i] @@ -76,7 +76,7 @@ (letfn [(on-save [e] (let [dom (mx/ref-node own "input") name (dom/get-inner-text dom)] - (rs/emit! (di/rename-collection id (str/trim name))) + (st/emit! (di/rename-collection id (str/trim name))) (swap! local assoc :edit false))) (on-cancel [e] (swap! local assoc :edit false)) @@ -91,7 +91,7 @@ (dom/stop-propagation e) (on-save e)))) (delete [] - (rs/emit! (di/delete-collection id))) + (st/emit! (di/delete-collection id))) (on-delete [] (udl/open! :confirm {:on-accept delete}))] [:div.dashboard-title @@ -131,7 +131,7 @@ [{:keys [id type name] :as coll} selected?] (letfn [(on-click [event] (let [type (or type :own)] - (rs/emit! (di/select-collection type id))))] + (st/emit! (di/select-collection type id))))] (let [num-images (react-count-images id)] [:li {:on-click on-click :class-name (when selected? "current")} @@ -153,7 +153,7 @@ (when own? [:li [:a.btn-primary - {:on-click #(rs/emit! (di/create-collection))} + {:on-click #(st/emit! (di/create-collection))} "+ New library"]]) (when own? (nav-item nil (nil? selected))) @@ -170,14 +170,14 @@ builtin? (= type :builtin)] (letfn [(select-tab [type] (if own? - (rs/emit! (di/select-collection type)) + (st/emit! (di/select-collection type)) (let [coll (->> (map second colls) (filter #(= type (:type %))) (sort-by :name) (first))] (if coll - (rs/emit! (di/select-collection type (:id coll))) - (rs/emit! (di/select-collection type))))))] + (st/emit! (di/select-collection type (:id coll))) + (st/emit! (di/select-collection type))))))] [:div.library-bar [:div.library-bar-inside [:ul.library-tabs @@ -199,7 +199,7 @@ (dom/click (mx/ref-node own "file-input"))) (on-file-selected [event] (let [files (dom/get-event-files event)] - (rs/emit! (di/create-images coll-id files))))] + (st/emit! (di/create-images coll-id files))))] (let [uploading? (mx/react uploading?-ref)] [:div.grid-item.add-project {:on-click forward-click} (if uploading? @@ -244,7 +244,7 @@ (let [editable? (or (= type :own) (nil? coll)) local (:rum/local own)] (letfn [(delete [] - (rs/emit! (di/delete-selected))) + (st/emit! (di/delete-selected))) (on-delete [event] (udl/open! :confirm {:on-accept delete})) (on-toggle-copy [event] @@ -255,15 +255,15 @@ (swap! local assoc :show-move-tooltip false :show-copy-tooltip false) - (rs/emit! (di/copy-selected selected))) + (st/emit! (di/copy-selected selected))) (on-move [selected] (swap! local assoc :show-move-tooltip false :show-copy-tooltip false) - (rs/emit! (di/move-selected selected))) + (st/emit! (di/move-selected selected))) (on-rename [event] (let [selected (first selected)] - (rs/emit! (di/update-opts :edition selected))))] + (st/emit! (di/update-opts :edition selected))))] ;; MULTISELECT OPTIONS BAR [:div.multiselect-bar (if editable? @@ -304,7 +304,7 @@ {:mixins [mx/static]} [{:keys [id created-at] :as image} selected? edition?] (letfn [(toggle-selection [event] - (rs/emit! (di/toggle-image-selection id))) + (st/emit! (di/toggle-image-selection id))) (toggle-selection-shifted [event] (when (kbd/shift? event) (toggle-selection event))) @@ -314,12 +314,12 @@ (on-blur [event] (let [target (dom/event->target event) name (dom/get-value target)] - (rs/emit! (di/update-opts :edition false) + (st/emit! (di/update-opts :edition false) (di/rename-image id name)))) (on-edit [event] (dom/stop-propagation event) (dom/prevent-default event) - (rs/emit! (di/update-opts :edition id)))] + (st/emit! (di/update-opts :edition id)))] [:div.grid-item.images-th {:on-click toggle-selection-shifted} [:div.grid-item-th @@ -385,13 +385,13 @@ (letfn [(on-term-change [event] (let [term (-> (dom/get-target event) (dom/get-value))] - (rs/emit! (di/update-opts :filter term)))) + (st/emit! (di/update-opts :filter term)))) (on-ordering-change [event] (let [value (dom/event->value event) value (read-string value)] - (rs/emit! (di/update-opts :order value)))) + (st/emit! (di/update-opts :order value)))) (on-clear [event] - (rs/emit! (di/update-opts :filter "")))] + (st/emit! (di/update-opts :filter "")))] [:section.dashboard-bar.library-gap [:div.dashboard-info @@ -424,7 +424,7 @@ (defn- images-page-will-mount [own] (let [[type id] (:rum/args own)] - (rs/emit! (di/initialize type id)) + (st/emit! (di/initialize type id)) own)) (defn- images-page-did-remount @@ -433,7 +433,7 @@ [new-type new-id] (:rum/args own)] (when (or (not= old-type new-type) (not= old-id new-id)) - (rs/emit! (di/initialize new-type new-id))) + (st/emit! (di/initialize new-type new-id))) own)) (mx/defc images-page diff --git a/frontend/src/uxbox/main/ui/dashboard/projects.cljs b/frontend/src/uxbox/main/ui/dashboard/projects.cljs index f5779ddf9..690ee1c8a 100644 --- a/frontend/src/uxbox/main/ui/dashboard/projects.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/projects.cljs @@ -8,7 +8,7 @@ (ns uxbox.main.ui.dashboard.projects (:require [lentes.core :as l] [cuerdas.core :as str] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.projects :as udp] [uxbox.main.data.lightbox :as udl] [uxbox.main.ui.icons :as i] @@ -19,7 +19,7 @@ [uxbox.main.exports :as exports] [uxbox.util.i18n :as t :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.data :refer (read-string)] [uxbox.util.dom :as dom] [uxbox.util.blob :as blob] @@ -109,13 +109,13 @@ (letfn [(on-term-change [event] (let [term (-> (dom/get-target event) (dom/get-value))] - (rs/emit! (udp/update-opts :filter term)))) + (st/emit! (udp/update-opts :filter term)))) (on-ordering-change [event] (let [value (dom/event->value event) value (read-string value)] - (rs/emit! (udp/update-opts :order value)))) + (st/emit! (udp/update-opts :order value)))) (on-clear [event] - (rs/emit! (udp/update-opts :filter "")))] + (st/emit! (udp/update-opts :filter "")))] [:section.dashboard-bar [:div.dashboard-info @@ -177,9 +177,9 @@ {:mixins [mx/static (mx/local)]} [{:keys [rum/local] :as own} project] (letfn [(on-navigate [event] - (rs/emit! (udp/go-to (:id project)))) + (st/emit! (udp/go-to (:id project)))) (delete [] - (rs/emit! (udp/delete-project project))) + (st/emit! (udp/delete-project project))) (on-delete [event] (dom/stop-propagation event) (udl/open! :confirm {:on-accept delete})) @@ -191,7 +191,7 @@ name (dom/get-value target) id (:id project)] (swap! local assoc :edition false) - (rs/emit! (udp/rename-project id name)))) + (st/emit! (udp/rename-project id name)))) (on-edit [event] (dom/stop-propagation event) (dom/prevent-default event) @@ -251,12 +251,12 @@ (defn projects-page-will-mount [own] - (rs/emit! (udp/initialize)) + (st/emit! (udp/initialize)) own) (defn projects-page-did-remount [old-own own] - (rs/emit! (udp/initialize)) + (st/emit! (udp/initialize)) own) (mx/defc projects-page @@ -350,7 +350,7 @@ {:value "Go go go!" :on-click #(do (dom/prevent-default %) - (rs/emit! (udp/create-project @local)) + (st/emit! (udp/create-project @local)) (udl/close!)) :type "submit"}])] diff --git a/frontend/src/uxbox/main/ui/lightbox.cljs b/frontend/src/uxbox/main/ui/lightbox.cljs index d42010ad8..fd5da1e9f 100644 --- a/frontend/src/uxbox/main/ui/lightbox.cljs +++ b/frontend/src/uxbox/main/ui/lightbox.cljs @@ -2,7 +2,7 @@ (:require [sablono.core :as html :refer-macros [html]] [rum.core :as rum] [lentes.core :as l] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.lightbox :as udl] [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.ui.keyboard :as k] diff --git a/frontend/src/uxbox/main/ui/loader.cljs b/frontend/src/uxbox/main/ui/loader.cljs index 5839d1ace..755098d10 100644 --- a/frontend/src/uxbox/main/ui/loader.cljs +++ b/frontend/src/uxbox/main/ui/loader.cljs @@ -7,21 +7,11 @@ (ns uxbox.main.ui.loader (:require [sablono.core :refer-macros [html]] [rum.core :as rum] - [uxbox.main.state :as st] - [uxbox.util.rstore :as rs] + [uxbox.store :as st] [uxbox.main.ui.icons :as i] [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.ui.shapes])) -;; --- Error Handling - -(defn- on-error - [error] - ;; Disable loader in case of error. - (reset! st/loader false)) - -(rs/add-error-watcher :loader on-error) - ;; --- Component (defn loader-render diff --git a/frontend/src/uxbox/main/ui/messages.cljs b/frontend/src/uxbox/main/ui/messages.cljs index 968de8ea6..077ea2c60 100644 --- a/frontend/src/uxbox/main/ui/messages.cljs +++ b/frontend/src/uxbox/main/ui/messages.cljs @@ -2,7 +2,7 @@ (:require [sablono.core :as html :refer-macros [html]] [rum.core :as rum] [lentes.core :as l] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.messages :as udm] [uxbox.main.ui.icons :as i] [uxbox.util.timers :as ts] diff --git a/frontend/src/uxbox/main/ui/settings.cljs b/frontend/src/uxbox/main/ui/settings.cljs index 5d9898db0..be3524b68 100644 --- a/frontend/src/uxbox/main/ui/settings.cljs +++ b/frontend/src/uxbox/main/ui/settings.cljs @@ -10,7 +10,7 @@ [rum.core :as rum] [cuerdas.core :as str] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.main.ui.icons :as i] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.dom :as dom] diff --git a/frontend/src/uxbox/main/ui/settings/header.cljs b/frontend/src/uxbox/main/ui/settings/header.cljs index 6e5146cfc..a8245bcd8 100644 --- a/frontend/src/uxbox/main/ui/settings/header.cljs +++ b/frontend/src/uxbox/main/ui/settings/header.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.projects :as dp] [uxbox.main.ui.navigation :as nav] [uxbox.main.ui.icons :as i] diff --git a/frontend/src/uxbox/main/ui/settings/notifications.cljs b/frontend/src/uxbox/main/ui/settings/notifications.cljs index 1247e1a97..6b77662b4 100644 --- a/frontend/src/uxbox/main/ui/settings/notifications.cljs +++ b/frontend/src/uxbox/main/ui/settings/notifications.cljs @@ -10,7 +10,7 @@ [rum.core :as rum] [cuerdas.core :as str] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.main.ui.icons :as i] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.dom :as dom] diff --git a/frontend/src/uxbox/main/ui/settings/password.cljs b/frontend/src/uxbox/main/ui/settings/password.cljs index 99a11ee8a..f629bbb94 100644 --- a/frontend/src/uxbox/main/ui/settings/password.cljs +++ b/frontend/src/uxbox/main/ui/settings/password.cljs @@ -9,11 +9,11 @@ (:require [lentes.core :as l] [cuerdas.core :as str] [uxbox.util.i18n :as t :refer (tr)] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.forms :as forms] [uxbox.util.dom :as dom] [uxbox.util.mixins :as mx :include-macros true] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.users :as udu] [uxbox.main.ui.icons :as i] [uxbox.main.ui.messages :as uum] @@ -41,7 +41,7 @@ (set-value! field value))) (on-submit [event] (println "on-submit" data) - #_(rs/emit! (udu/update-password form)))] + #_(st/emit! (udu/update-password form)))] (println "password-form" data) [:form.password-form [:span.user-settings-label "Change password"] diff --git a/frontend/src/uxbox/main/ui/settings/profile.cljs b/frontend/src/uxbox/main/ui/settings/profile.cljs index f31cf491d..1a5b0f30b 100644 --- a/frontend/src/uxbox/main/ui/settings/profile.cljs +++ b/frontend/src/uxbox/main/ui/settings/profile.cljs @@ -10,11 +10,11 @@ [lentes.core :as l] [uxbox.util.forms :as forms] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.interop :refer (iterable->seq)] [uxbox.util.dom :as dom] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.ui.icons :as i] [uxbox.main.ui.settings.header :refer (header)] [uxbox.main.ui.messages :as uum] @@ -59,7 +59,7 @@ (on-success [] (forms/clear! :profile)) (on-submit [event] - (rs/emit! (udu/update-profile data on-success on-error)))] + (st/emit! (udu/update-profile data on-success on-error)))] [:form.profile-form [:span.user-settings-label "Name, username and email"] [:input.input-text @@ -124,7 +124,7 @@ file (-> (dom/get-files target) (iterable->seq) (first))] - (rs/emit! (udu/update-photo file)) + (st/emit! (udu/update-photo file)) (dom/clean-value! target)))] (let [{:keys [photo]} (mx/react profile-ref) photo (if (or (str/empty? photo) (nil? photo)) diff --git a/frontend/src/uxbox/main/ui/shapes/common.cljs b/frontend/src/uxbox/main/ui/shapes/common.cljs index 5cb878310..a84755b0e 100644 --- a/frontend/src/uxbox/main/ui/shapes/common.cljs +++ b/frontend/src/uxbox/main/ui/shapes/common.cljs @@ -8,8 +8,8 @@ (:require [sablono.core :refer-macros [html]] [lentes.core :as l] [beicon.core :as rx] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.keyboard :as kbd] [uxbox.main.ui.workspace.base :as wb] @@ -41,10 +41,10 @@ (rx/filter #(= % :mouse/up)) (rx/take 1)) stream (rx/take-until stoper wb/mouse-delta-s) - on-move #(rs/emit! (uds/move-shape shape %)) + on-move #(st/emit! (uds/move-shape shape %)) on-stop #(rlocks/release! :shape/move)] (when @wb/alignment-ref - (rs/emit! (uds/initial-align-shape shape))) + (st/emit! (uds/initial-align-shape shape))) (rx/subscribe stream on-move nil on-stop)))] (rlocks/acquire! :shape/move) @@ -65,16 +65,16 @@ (and (not selected?) (empty? selected)) (do (dom/stop-propagation event) - (rs/emit! (uds/select-shape id)) + (st/emit! (uds/select-shape id)) (start-move)) (and (not selected?) (not (empty? selected))) (do (dom/stop-propagation event) (if (kbd/shift? event) - (rs/emit! (uds/select-shape id)) + (st/emit! (uds/select-shape id)) (do - (rs/emit! (uds/deselect-all) + (st/emit! (uds/deselect-all) (uds/select-shape id)) (start-move)))) diff --git a/frontend/src/uxbox/main/ui/shapes/group.cljs b/frontend/src/uxbox/main/ui/shapes/group.cljs index 9a1996d75..172b02ec0 100644 --- a/frontend/src/uxbox/main/ui/shapes/group.cljs +++ b/frontend/src/uxbox/main/ui/shapes/group.cljs @@ -6,7 +6,7 @@ (ns uxbox.main.ui.shapes.group (:require [lentes.core :as l] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.ui.shapes.common :as common] [uxbox.main.ui.shapes.attrs :as attrs] diff --git a/frontend/src/uxbox/main/ui/shapes/image.cljs b/frontend/src/uxbox/main/ui/shapes/image.cljs index 6e07c785c..55aec1857 100644 --- a/frontend/src/uxbox/main/ui/shapes/image.cljs +++ b/frontend/src/uxbox/main/ui/shapes/image.cljs @@ -9,8 +9,8 @@ [lentes.core :as l] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.http :as http] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.ui.shapes.common :as common] [uxbox.main.ui.shapes.attrs :as attrs] [uxbox.main.data.images :as udi] @@ -31,7 +31,7 @@ [own] (let [{:keys [image]} (first (:rum/args own))] (println (:rum/args own)) - (rs/emit! (udi/fetch-image image)) + (st/emit! (udi/fetch-image image)) own)) (mx/defcs image-component diff --git a/frontend/src/uxbox/main/ui/shapes/path.cljs b/frontend/src/uxbox/main/ui/shapes/path.cljs index e006456fb..91ca3cfcd 100644 --- a/frontend/src/uxbox/main/ui/shapes/path.cljs +++ b/frontend/src/uxbox/main/ui/shapes/path.cljs @@ -6,7 +6,8 @@ (ns uxbox.main.ui.shapes.path (:require [uxbox.util.mixins :as mx :include-macros true] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.ui.shapes.common :as common] [uxbox.main.ui.shapes.attrs :as attrs] [uxbox.main.data.shapes :as uds] @@ -25,7 +26,7 @@ (common/on-mouse-down event shape selected)) (on-double-click [event] (when selected? - (rs/emit! (uds/start-edition-mode id))))] + (st/emit! (uds/start-edition-mode id))))] [:g.shape {:class (when selected? "selected") :on-double-click on-double-click :on-mouse-down on-mouse-down} diff --git a/frontend/src/uxbox/main/ui/shapes/selection.cljs b/frontend/src/uxbox/main/ui/shapes/selection.cljs index ce099ec76..86603bf34 100644 --- a/frontend/src/uxbox/main/ui/shapes/selection.cljs +++ b/frontend/src/uxbox/main/ui/shapes/selection.cljs @@ -9,9 +9,9 @@ "Multiple selection handlers component." (:require [lentes.core :as l] [beicon.core :as rx] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.util.mixins :as mx :include-macros true] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.workspace.base :as wb] [uxbox.util.rlocks :as rlocks] @@ -47,7 +47,7 @@ [vid sid] (letfn [(on-resize [[delta ctrl?]] (let [params {:vid vid :delta (assoc delta :lock ctrl?)}] - (rs/emit! (uds/update-vertex-position sid params)))) + (st/emit! (uds/update-vertex-position sid params)))) (on-end [] (rlocks/release! :shape/resize))] (let [stoper (->> wb/events-s @@ -59,7 +59,7 @@ (rx/with-latest-from vector wb/mouse-ctrl-s))] (rlocks/acquire! :shape/resize) (when @wb/alignment-ref - (rs/emit! (uds/initial-vertext-align sid vid))) + (st/emit! (uds/initial-vertext-align sid vid))) (rx/subscribe stream on-resize nil on-end)))) ;; --- Selection Handlers (Component) @@ -145,7 +145,7 @@ (defn start-path-edition [shape-id index] (letfn [(on-move [delta] - (rs/emit! (uds/update-path shape-id index delta))) + (st/emit! (uds/update-path shape-id index delta))) (on-end [] (rlocks/release! :shape/resize))] (let [stoper (->> wb/events-s @@ -155,7 +155,7 @@ stream (rx/take-until stoper wb/mouse-delta-s)] (rlocks/acquire! :shape/resize) (when @wb/alignment-ref - (rs/emit! (uds/initial-path-point-align shape-id index))) + (st/emit! (uds/initial-path-point-align shape-id index))) (rx/subscribe stream on-move nil on-end)))) (mx/defc path-edition-selection-handlers diff --git a/frontend/src/uxbox/main/ui/shapes/text.cljs b/frontend/src/uxbox/main/ui/shapes/text.cljs index 7d59a1801..8acd4e75d 100644 --- a/frontend/src/uxbox/main/ui/shapes/text.cljs +++ b/frontend/src/uxbox/main/ui/shapes/text.cljs @@ -8,10 +8,11 @@ (:require [cuerdas.core :as str] [lentes.core :as l] [goog.events :as events] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.color :as color] [uxbox.util.dom :as dom] + [uxbox.store :as st] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.shapes.common :as common] [uxbox.main.ui.shapes.attrs :as attrs] @@ -46,7 +47,7 @@ (handle-mouse-down event shape selected)) (on-double-click [event] (dom/stop-propagation event) - (rs/emit! (uds/start-edition-mode id)))] + (st/emit! (uds/start-edition-mode id)))] [:g.shape {:class (when selected? "selected") :ref "main" :on-double-click on-double-click @@ -113,7 +114,7 @@ (on-done)) (on-input [ev] (let [content (dom/event->inner-text ev)] - (rs/emit! (uds/update-text id {:content content}))))] + (st/emit! (uds/update-text id {:content content}))))] [:g [:rect (merge props +select-rect-attrs+)] [:foreignObject props diff --git a/frontend/src/uxbox/main/ui/users.cljs b/frontend/src/uxbox/main/ui/users.cljs index 42d958742..d1dcd4a2c 100644 --- a/frontend/src/uxbox/main/ui/users.cljs +++ b/frontend/src/uxbox/main/ui/users.cljs @@ -10,8 +10,8 @@ [lentes.core :as l] [rum.core :as rum] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as s] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.auth :as da] [uxbox.main.data.lightbox :as udl] [uxbox.main.ui.icons :as i] @@ -38,7 +38,7 @@ [:li {:on-click #(r/go :settings/profile)} i/user [:span "Your account"]] - [:li {:on-click #(rs/emit! (da/logout))} + [:li {:on-click #(st/emit! (da/logout))} i/exit [:span "Exit"]]]))) @@ -52,7 +52,7 @@ (def profile-ref (as-> (l/key :profile) $ - (l/derive $ s/state))) + (l/derive $ st/state))) (defn user-render [own] diff --git a/frontend/src/uxbox/main/ui/workspace.cljs b/frontend/src/uxbox/main/ui/workspace.cljs index 8d91ebfe4..7bc3c45ef 100644 --- a/frontend/src/uxbox/main/ui/workspace.cljs +++ b/frontend/src/uxbox/main/ui/workspace.cljs @@ -10,7 +10,8 @@ [rum.core :as rum] [beicon.core :as rx] [uxbox.main.constants :as c] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as dw] [uxbox.main.data.pages :as udp] [uxbox.main.data.history :as udh] @@ -39,7 +40,7 @@ (defn- workspace-will-mount [own] (let [[projectid pageid] (:rum/args own)] - (rs/emit! (dw/initialize projectid pageid)) + (st/emit! (dw/initialize projectid pageid)) own)) (defn- workspace-did-mount @@ -76,7 +77,7 @@ [oldprojectid oldpageid] (:rum/args old-state)] (if (not= pageid oldpageid) (do - (rs/emit! (dw/initialize projectid pageid)) + (st/emit! (dw/initialize projectid pageid)) (.close (::sub2 old-state)) (.close (::sub3 old-state)) (assoc state @@ -103,8 +104,8 @@ (dom/prevent-default event) (dom/stop-propagation event) (if (pos? (.-deltaY event)) - (rs/emit! (dw/increase-zoom)) - (rs/emit! (dw/decrease-zoom))) + (st/emit! (dw/increase-zoom)) + (st/emit! (dw/decrease-zoom))) (let [dom (mx/ref-node own "workspace-canvas")] (set! (.-scrollLeft dom) (* c/canvas-start-scroll-x @wb/zoom-ref)) diff --git a/frontend/src/uxbox/main/ui/workspace/base.cljs b/frontend/src/uxbox/main/ui/workspace/base.cljs index c3d99cf3d..58118c8c6 100644 --- a/frontend/src/uxbox/main/ui/workspace/base.cljs +++ b/frontend/src/uxbox/main/ui/workspace/base.cljs @@ -8,8 +8,8 @@ (ns uxbox.main.ui.workspace.base (:require [beicon.core :as rx] [lentes.core :as l] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as dw] [uxbox.main.data.shapes :as uds] [uxbox.util.geom.point :as gpt] diff --git a/frontend/src/uxbox/main/ui/workspace/canvas.cljs b/frontend/src/uxbox/main/ui/workspace/canvas.cljs index 66fc918eb..3caf9224f 100644 --- a/frontend/src/uxbox/main/ui/workspace/canvas.cljs +++ b/frontend/src/uxbox/main/ui/workspace/canvas.cljs @@ -9,7 +9,7 @@ (:require [beicon.core :as rx] [lentes.core :as l] [goog.events :as events] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.geom.point :as gpt] [uxbox.util.dom :as dom] [uxbox.util.data :refer (parse-int)] diff --git a/frontend/src/uxbox/main/ui/workspace/clipboard.cljs b/frontend/src/uxbox/main/ui/workspace/clipboard.cljs index fb5dbe8b5..4eac4171d 100644 --- a/frontend/src/uxbox/main/ui/workspace/clipboard.cljs +++ b/frontend/src/uxbox/main/ui/workspace/clipboard.cljs @@ -7,12 +7,12 @@ (ns uxbox.main.ui.workspace.clipboard (:require [lentes.core :as l] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.lightbox :as udl] [uxbox.main.data.workspace :as udw] [uxbox.main.ui.icons :as i] [uxbox.main.ui.lightbox :as lbx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.dom :as dom] [uxbox.util.datetime :as dt])) @@ -25,7 +25,7 @@ {:mixins [mx/static mx/reactive]} [] (letfn [(on-paste [item] - (rs/emit! (udw/paste-from-clipboard (:id item))) + (st/emit! (udw/paste-from-clipboard (:id item))) (udl/close!)) (on-close [event] (dom/prevent-default event) diff --git a/frontend/src/uxbox/main/ui/workspace/colorpalette.cljs b/frontend/src/uxbox/main/ui/workspace/colorpalette.cljs index aae5dc59b..28805ff28 100644 --- a/frontend/src/uxbox/main/ui/workspace/colorpalette.cljs +++ b/frontend/src/uxbox/main/ui/workspace/colorpalette.cljs @@ -8,7 +8,7 @@ (ns uxbox.main.ui.workspace.colorpalette (:require [beicon.core :as rx] [lentes.core :as l] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.workspace :as dw] [uxbox.main.data.shapes :as uds] [uxbox.main.data.colors :as dc] @@ -16,7 +16,7 @@ [uxbox.main.ui.workspace.base :as wb] [uxbox.main.ui.icons :as i] [uxbox.main.ui.keyboard :as kbd] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.lens :as ul] [uxbox.util.data :refer (read-string)] [uxbox.util.color :refer (hex->rgb)] @@ -35,8 +35,8 @@ (letfn [(select-color [event color] (dom/prevent-default event) (if (kbd/shift? event) - (rs/emit! (uds/update-selected-shapes-stroke {:color color})) - (rs/emit! (uds/update-selected-shapes-fill {:color color}))))] + (st/emit! (uds/update-selected-shapes-stroke {:color color})) + (st/emit! (uds/update-selected-shapes-fill {:color color}))))] [:div.color-palette-content (for [hex-color colors :let [rgb-vec (hex->rgb hex-color) @@ -59,7 +59,7 @@ (let [value (read-string (dom/event->value event))] (swap! local assoc :selected value))) (close [event] - (rs/emit! (dw/toggle-flag :colorpalette)))] + (st/emit! (dw/toggle-flag :colorpalette)))] [:div.color-palette [:div.color-palette-actions [:select.input-select {:on-change select-collection} @@ -78,7 +78,7 @@ (defn- colorpalette-will-mount [own] - (rs/emit! (dc/fetch-collections)) + (st/emit! (dc/fetch-collections)) own) (mx/defc colorpalette diff --git a/frontend/src/uxbox/main/ui/workspace/colorpicker.cljs b/frontend/src/uxbox/main/ui/workspace/colorpicker.cljs index be00840a9..9df368ffc 100644 --- a/frontend/src/uxbox/main/ui/workspace/colorpicker.cljs +++ b/frontend/src/uxbox/main/ui/workspace/colorpicker.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.workspace.base :as wb] @@ -38,7 +38,7 @@ top (- y 50)] (letfn [(change-color [color] (let [attrs {:color color}] - (rs/emit! + (st/emit! (case attr :stroke (uds/update-stroke-attrs (:id shape) attrs) :fill (uds/update-fill-attrs (:id shape) attrs))))) diff --git a/frontend/src/uxbox/main/ui/workspace/download.cljs b/frontend/src/uxbox/main/ui/workspace/download.cljs index d4e19f6a6..08c310072 100644 --- a/frontend/src/uxbox/main/ui/workspace/download.cljs +++ b/frontend/src/uxbox/main/ui/workspace/download.cljs @@ -10,7 +10,7 @@ [beicon.core :as rx] [uxbox.main.data.lightbox :as udl] [uxbox.main.exports :as exports] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.ui.icons :as i] [uxbox.main.ui.lightbox :as lbx] [uxbox.main.ui.workspace.base :as wb] @@ -19,7 +19,7 @@ [uxbox.util.datetime :as dt] [uxbox.util.dom :as dom] [uxbox.util.mixins :as mx :include-macros true] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.zip :as zip] [lentes.core :as l])) diff --git a/frontend/src/uxbox/main/ui/workspace/drawarea.cljs b/frontend/src/uxbox/main/ui/workspace/drawarea.cljs index 58f445943..8acb3c886 100644 --- a/frontend/src/uxbox/main/ui/workspace/drawarea.cljs +++ b/frontend/src/uxbox/main/ui/workspace/drawarea.cljs @@ -8,14 +8,15 @@ (ns uxbox.main.ui.workspace.drawarea "Draw interaction and component." (:require [beicon.core :as rx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.mixins :as mx :include-macros true] + [uxbox.util.rlocks :as rlocks] + [uxbox.store :as st] [uxbox.main.constants :as c] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.shapes :as shapes] [uxbox.main.ui.workspace.base :as wb] - [uxbox.util.rlocks :as rlocks] [uxbox.main.geom :as geom] [uxbox.util.geom.point :as gpt] [uxbox.util.geom.path :as path] @@ -128,7 +129,7 @@ :x2 (+ x 200) :y2 (+ y (/ 200 proportion))} shape (geom/setup shape props)] - (rs/emit! (uds/add-shape shape) + (st/emit! (uds/add-shape shape) (udw/select-for-drawing nil) (uds/select-first-shape)) (rlocks/release! :ui/draw))) @@ -232,7 +233,7 @@ (on-end [] (let [shape @drawing-shape] - (rs/emit! (uds/add-shape shape) + (st/emit! (uds/add-shape shape) (udw/select-for-drawing nil) (uds/select-first-shape)) (reset! drawing-shape nil) @@ -268,7 +269,7 @@ (on-end [] (let [shape (simplify-shape @drawing-shape)] - (rs/emit! (uds/add-shape shape) + (st/emit! (uds/add-shape shape) (udw/select-for-drawing nil) (uds/select-first-shape)) (reset! drawing-shape nil) @@ -301,7 +302,7 @@ (let [shape @drawing-shape shpos @drawing-position shape (geom/resize shape shpos)] - (rs/emit! (uds/add-shape shape) + (st/emit! (uds/add-shape shape) (udw/select-for-drawing nil) (uds/select-first-shape)) (reset! drawing-position nil) diff --git a/frontend/src/uxbox/main/ui/workspace/header.cljs b/frontend/src/uxbox/main/ui/workspace/header.cljs index 8f7e529cb..c88b19de2 100644 --- a/frontend/src/uxbox/main/ui/workspace/header.cljs +++ b/frontend/src/uxbox/main/ui/workspace/header.cljs @@ -11,7 +11,8 @@ [beicon.core :as rx] [uxbox.config :as cfg] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as dw] [uxbox.main.data.history :as udh] [uxbox.main.data.lightbox :as udl] @@ -33,8 +34,8 @@ coords (some-> (mx/react wb/mouse-canvas-a) (gpt/divide zoom) (gpt/round 1)) - increase #(rs/emit! (dw/increase-zoom)) - decrease #(rs/emit! (dw/decrease-zoom))] + increase #(st/emit! (dw/increase-zoom)) + decrease #(st/emit! (dw/decrease-zoom))] (html [:ul.options-view [:li.coordinates {:alt "x"} @@ -66,9 +67,9 @@ (let [project (mx/react wb/project-ref) page (mx/react wb/page-ref) flags (mx/react wb/flags-ref) - toggle #(rs/emit! (dw/toggle-flag %)) - on-undo #(rs/emit! (udh/backwards-to-previous-version)) - on-redo #(rs/emit! (udh/forward-to-next-version)) + toggle #(st/emit! (dw/toggle-flag %)) + on-undo #(st/emit! (udh/backwards-to-previous-version)) + on-redo #(st/emit! (udh/forward-to-next-version)) on-image #(udl/open! :import-image) on-download #(udl/open! :download)] (html diff --git a/frontend/src/uxbox/main/ui/workspace/images.cljs b/frontend/src/uxbox/main/ui/workspace/images.cljs index 8f9f33103..b50fb9bb2 100644 --- a/frontend/src/uxbox/main/ui/workspace/images.cljs +++ b/frontend/src/uxbox/main/ui/workspace/images.cljs @@ -8,11 +8,11 @@ (ns uxbox.main.ui.workspace.images (:require [lentes.core :as l] [uxbox.util.i18n :as t :refer (tr)] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.data :as data :refer (read-string)] [uxbox.util.dom :as dom] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.lightbox :as udl] [uxbox.main.data.images :as udi] [uxbox.main.data.workspace :as udw] @@ -54,11 +54,11 @@ :metadata {:width width :height height} :image id}] - (rs/emit! (udw/select-for-drawing shape)) + (st/emit! (udw/select-for-drawing shape)) (udl/close!))) (on-files-selected [event] (let [files (dom/get-event-files event)] - (rs/emit! (udi/create-images nil files on-uploaded)))) + (st/emit! (udi/create-images nil files on-uploaded)))) (on-select-from-library [event] (dom/prevent-default event) (udl/open! :import-image-from-collections)) @@ -96,7 +96,7 @@ :metadata {:width width :height height} :image id}] - (rs/emit! (udw/select-for-drawing shape)) + (st/emit! (udw/select-for-drawing shape)) (udl/close!)))] [:div.library-item {:key (str id) :on-double-click on-double-click} @@ -115,10 +115,10 @@ (defn will-mount [own] (let [local (:rum/local own)] - (rs/emit! (udi/fetch-collections)) - (rs/emit! (udi/fetch-images nil)) + (st/emit! (udi/fetch-collections)) + (st/emit! (udi/fetch-images nil)) (add-watch local ::key (fn [_ _ _ v] - (rs/emit! (udi/fetch-images (:id v))))) + (st/emit! (udi/fetch-images (:id v))))) own)) (defn will-unmount diff --git a/frontend/src/uxbox/main/ui/workspace/recent_colors.cljs b/frontend/src/uxbox/main/ui/workspace/recent_colors.cljs index 5a137bf9a..094599ffc 100644 --- a/frontend/src/uxbox/main/ui/workspace/recent_colors.cljs +++ b/frontend/src/uxbox/main/ui/workspace/recent_colors.cljs @@ -10,8 +10,8 @@ [rum.core :as rum] [lentes.core :as l] [uxbox.util.i18n :refer (tr)] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as dw] [uxbox.main.ui.icons :as i] [uxbox.util.mixins :as mx :include-macros true] diff --git a/frontend/src/uxbox/main/ui/workspace/ruler.cljs b/frontend/src/uxbox/main/ui/workspace/ruler.cljs index 415526a63..68abbfb78 100644 --- a/frontend/src/uxbox/main/ui/workspace/ruler.cljs +++ b/frontend/src/uxbox/main/ui/workspace/ruler.cljs @@ -10,7 +10,7 @@ [rum.core :as rum] [beicon.core :as rx] [uxbox.main.constants :as c] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.math :as mth] [uxbox.main.ui.workspace.base :as wb] [uxbox.util.mixins :as mx :include-macros true] diff --git a/frontend/src/uxbox/main/ui/workspace/rules.cljs b/frontend/src/uxbox/main/ui/workspace/rules.cljs index 7f995dee9..2c87e8336 100644 --- a/frontend/src/uxbox/main/ui/workspace/rules.cljs +++ b/frontend/src/uxbox/main/ui/workspace/rules.cljs @@ -11,7 +11,7 @@ [cuerdas.core :as str] [beicon.core :as rx] [uxbox.main.constants :as c] - [uxbox.main.state :as s] + [uxbox.store :as s] [uxbox.util.dom :as dom] [uxbox.main.ui.workspace.base :as wb] [uxbox.util.mixins :as mx :include-macros true])) diff --git a/frontend/src/uxbox/main/ui/workspace/selrect.cljs b/frontend/src/uxbox/main/ui/workspace/selrect.cljs index cd343edbe..1dfab0a31 100644 --- a/frontend/src/uxbox/main/ui/workspace/selrect.cljs +++ b/frontend/src/uxbox/main/ui/workspace/selrect.cljs @@ -8,8 +8,9 @@ (ns uxbox.main.ui.workspace.selrect "Mouse selection interaction and component." (:require [beicon.core :as rx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.mixins :as mx :include-macros true] + [uxbox.store :as st] [uxbox.main.constants :as c] [uxbox.main.data.workspace :as dw] [uxbox.main.data.shapes :as uds] @@ -94,7 +95,7 @@ [] (let [rect (-> (selrect->rect @position) (translate-to-canvas))] - (rs/emit! (uds/deselect-all) + (st/emit! (uds/deselect-all) (uds/select-shapes rect)) (rlocks/release! :ui/selrect) (reset! position nil))) diff --git a/frontend/src/uxbox/main/ui/workspace/settings.cljs b/frontend/src/uxbox/main/ui/workspace/settings.cljs index 6cd69b620..951638b83 100644 --- a/frontend/src/uxbox/main/ui/workspace/settings.cljs +++ b/frontend/src/uxbox/main/ui/workspace/settings.cljs @@ -8,8 +8,8 @@ (ns uxbox.main.ui.workspace.settings (:require [lentes.core :as l] [uxbox.main.constants :as c] - [uxbox.main.state :as st] - [uxbox.util.rstore :as rs] + [uxbox.store :as st] + [potok.core :as ptk] [uxbox.main.data.pages :as udp] [uxbox.main.data.workspace :as udw] [uxbox.main.data.lightbox :as udl] @@ -65,7 +65,7 @@ (let [[errors data] (forms/validate data +settings-form+)] (if errors (set-errors! errors) - (rs/emit! (udw/update-metadata id data) + (st/emit! (udw/update-metadata id data) (forms/clear :workspace-settings) (udl/hide-lightbox)))))] [:form {:on-submit on-submit} diff --git a/frontend/src/uxbox/main/ui/workspace/shortcuts.cljs b/frontend/src/uxbox/main/ui/workspace/shortcuts.cljs index 1c4804d7f..fe435a234 100644 --- a/frontend/src/uxbox/main/ui/workspace/shortcuts.cljs +++ b/frontend/src/uxbox/main/ui/workspace/shortcuts.cljs @@ -8,7 +8,8 @@ (ns uxbox.main.ui.workspace.shortcuts (:require [goog.events :as events] [beicon.core :as rx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.lightbox :as udl] [uxbox.main.data.workspace :as dw] [uxbox.main.data.shapes :as uds] @@ -25,30 +26,30 @@ ;; --- Shortcuts (defonce +shortcuts+ - {:shift+g #(rs/emit! (dw/toggle-flag :grid)) - :ctrl+g #(rs/emit! (uds/group-selected)) - :ctrl+shift+g #(rs/emit! (uds/degroup-selected)) - :ctrl+shift+m #(rs/emit! (dw/toggle-flag :sitemap)) - :ctrl+shift+f #(rs/emit! (dw/toggle-flag :drawtools)) - :ctrl+shift+i #(rs/emit! (dw/toggle-flag :icons)) - :ctrl+shift+l #(rs/emit! (dw/toggle-flag :layers)) - :ctrl+0 #(rs/emit! (dw/reset-zoom)) - :ctrl+r #(rs/emit! (dw/toggle-flag :ruler)) - :ctrl+d #(rs/emit! (uds/duplicate-selected)) - :ctrl+c #(rs/emit! (dw/copy-to-clipboard)) - :ctrl+v #(rs/emit! (dw/paste-from-clipboard)) + {:shift+g #(st/emit! (dw/toggle-flag :grid)) + :ctrl+g #(st/emit! (uds/group-selected)) + :ctrl+shift+g #(st/emit! (uds/degroup-selected)) + :ctrl+shift+m #(st/emit! (dw/toggle-flag :sitemap)) + :ctrl+shift+f #(st/emit! (dw/toggle-flag :drawtools)) + :ctrl+shift+i #(st/emit! (dw/toggle-flag :icons)) + :ctrl+shift+l #(st/emit! (dw/toggle-flag :layers)) + :ctrl+0 #(st/emit! (dw/reset-zoom)) + :ctrl+r #(st/emit! (dw/toggle-flag :ruler)) + :ctrl+d #(st/emit! (uds/duplicate-selected)) + :ctrl+c #(st/emit! (dw/copy-to-clipboard)) + :ctrl+v #(st/emit! (dw/paste-from-clipboard)) :ctrl+shift+v #(udl/open! :clipboard) - :ctrl+z #(rs/emit! (udu/undo)) - :ctrl+shift+z #(rs/emit! (udu/redo)) - :ctrl+b #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-rect+)) - :ctrl+e #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-circle+)) - :ctrl+t #(rs/emit! (dw/select-for-drawing wsd/+draw-tool-text+)) - :esc #(rs/emit! (uds/deselect-all)) - :delete #(rs/emit! (uds/delete-selected)) - :ctrl+up #(rs/emit! (uds/move-selected-layer :up)) - :ctrl+down #(rs/emit! (uds/move-selected-layer :down)) - :ctrl+shift+up #(rs/emit! (uds/move-selected-layer :top)) - :ctrl+shift+down #(rs/emit! (uds/move-selected-layer :bottom)) + :ctrl+z #(st/emit! (udu/undo)) + :ctrl+shift+z #(st/emit! (udu/redo)) + :ctrl+b #(st/emit! (dw/select-for-drawing wsd/+draw-tool-rect+)) + :ctrl+e #(st/emit! (dw/select-for-drawing wsd/+draw-tool-circle+)) + :ctrl+t #(st/emit! (dw/select-for-drawing wsd/+draw-tool-text+)) + :esc #(st/emit! (uds/deselect-all)) + :delete #(st/emit! (uds/delete-selected)) + :ctrl+up #(st/emit! (uds/move-selected-layer :up)) + :ctrl+down #(st/emit! (uds/move-selected-layer :down)) + :ctrl+shift+up #(st/emit! (uds/move-selected-layer :top)) + :ctrl+shift+down #(st/emit! (uds/move-selected-layer :bottom)) :shift+up #(move-selected :up :fast) :shift+down #(move-selected :down :fast) :shift+right #(move-selected :right :fast) @@ -90,8 +91,8 @@ (defn- move-selected [dir speed] (case speed - :std (rs/emit! (uds/move-selected dir 1)) - :fast (rs/emit! (uds/move-selected dir 20)))) + :std (st/emit! (uds/move-selected dir 1)) + :fast (st/emit! (uds/move-selected dir 20)))) ;; --- Mixin diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar.cljs index 73abc84d4..471b80ba2 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar.cljs @@ -7,9 +7,9 @@ (ns uxbox.main.ui.workspace.sidebar (:require [lentes.core :as l] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.ui.workspace.base :as wb] [uxbox.main.ui.workspace.sidebar.options :refer (options-toolbox)] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs index 5b9313de4..2b6cf3bcd 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/drawtools.cljs @@ -10,11 +10,11 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.data :refer (read-string)] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.dom :as dom] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.workspace :as dw] [uxbox.main.ui.workspace.base :as wb] [uxbox.main.ui.icons :as i])) @@ -82,14 +82,14 @@ (defn- select-for-draw [shape] - (rs/emit! (dw/select-for-drawing shape))) + (st/emit! (dw/select-for-drawing shape))) (mx/defc draw-toolbox {:mixins [mx/static mx/reactive]} [own] (let [workspace (mx/react wb/workspace-ref) drawing (mx/react drawing-shape) - close #(rs/emit! (dw/toggle-flag :drawtools)) + close #(st/emit! (dw/toggle-flag :drawtools)) tools (->> (into [] +draw-tools+) (sort-by (comp :priority second)))] [:div#form-tools.tool-window.drawing-tools diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/history.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/history.cljs index 153391668..606fa5962 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/history.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/history.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as dw] [uxbox.main.data.pages :as udp] [uxbox.main.data.history :as udh] @@ -36,14 +36,14 @@ [own item selected] (letfn [(on-select [event] (dom/prevent-default event) - (rs/emit! (udh/select-page-history (:version item)))) + (st/emit! (udh/select-page-history (:version item)))) (on-pinned [event] (dom/prevent-default event) (dom/stop-propagation event) (let [item (assoc item :label "no label" :pinned (not (:pinned item)))] - (rs/emit! (udh/update-history-item item))))] + (st/emit! (udh/update-history-item item))))] (let [selected? (= (:version item) selected)] (html [:li {:class (when selected? "current") :on-click on-select} @@ -65,13 +65,13 @@ [own page history] (letfn [(on-select [event] (dom/prevent-default event) - (rs/emit! (udh/deselect-page-history (:id page)))) + (st/emit! (udh/deselect-page-history (:id page)))) (on-load-more [event] (dom/prevent-default event) (let [since (:min-version history) params {:since since}] - (rs/emit! (udh/fetch-page-history (:id page) params))))] + (st/emit! (udh/fetch-page-history (:id page) params))))] (let [selected (:selected history) show-more? (pos? (:min-version history))] @@ -121,7 +121,7 @@ page (mx/react wb/page-ref) history (mx/react history-ref) section (:section @local :main) - close #(rs/emit! (dw/toggle-flag :document-history)) + close #(st/emit! (dw/toggle-flag :document-history)) main? (= section :main) pinned? (= section :pinned) show-main #(swap! local assoc :section :main) @@ -156,8 +156,8 @@ [own page] (let [history (mx/react history-ref) version (:selected history) - on-accept #(rs/emit! (udh/apply-selected-history page)) - on-cancel #(rs/emit! (udh/deselect-page-history page))] + on-accept #(st/emit! (udh/apply-selected-history page)) + on-cancel #(st/emit! (udh/deselect-page-history page))] (when (or version (:deselecting history)) (html [:div.message-version diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/icons.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/icons.cljs index 0c088985b..42b6ab412 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/icons.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/icons.cljs @@ -8,8 +8,8 @@ (ns uxbox.main.ui.workspace.sidebar.icons (:require [lentes.core :as l] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as dw] [uxbox.main.data.icons :as udi] [uxbox.main.ui.shapes.icon :as icon] @@ -40,10 +40,10 @@ (defn- icons-toolbox-will-mount [own] (let [local (:rum/local own)] - (rs/emit! (udi/fetch-collections)) - (rs/emit! (udi/fetch-icons nil)) + (st/emit! (udi/fetch-collections)) + (st/emit! (udi/fetch-icons nil)) (add-watch local ::key (fn [_ _ _ {:keys [id]}] - (rs/emit! (udi/fetch-icons id)))) + (st/emit! (udi/fetch-icons id)))) own)) (defn- icons-toolbox-will-unmount @@ -69,14 +69,14 @@ (filter #(= (:id coll) (:collection %))))] (letfn [(on-close [event] - (rs/emit! (dw/toggle-flag :icons))) + (st/emit! (dw/toggle-flag :icons))) (on-select [icon event] - (rs/emit! (dw/select-for-drawing icon))) + (st/emit! (dw/select-for-drawing icon))) (on-change [event] (let [value (-> (dom/event->value event) (read-string))] (swap! local assoc :id value) - (rs/emit! (dw/select-for-drawing nil))))] + (st/emit! (dw/select-for-drawing nil))))] [:div#form-figures.tool-window [:div.tool-window-bar [:div.tool-window-icon i/icon-set] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs index fa305100d..3f91947b1 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/layers.cljs @@ -10,8 +10,8 @@ [cuerdas.core :as str] [goog.events :as events] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.util.data :refer (read-string classnames)] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] @@ -41,17 +41,17 @@ nil (.-ctrlKey event) - (rs/emit! (uds/select-shape id)) + (st/emit! (uds/select-shape id)) (> (count selected) 1) - (rs/emit! (uds/deselect-all) + (st/emit! (uds/deselect-all) (uds/select-shape id)) (contains? selected id) - (rs/emit! (uds/select-shape id)) + (st/emit! (uds/select-shape id)) :else - (rs/emit! (uds/deselect-all) + (st/emit! (uds/deselect-all) (uds/select-shape id))))) (defn- toggle-visibility @@ -60,10 +60,10 @@ (let [id (:id item) hidden? (:hidden item)] (if hidden? - (rs/emit! (uds/show-shape id)) - (rs/emit! (uds/hide-shape id))) + (st/emit! (uds/show-shape id)) + (st/emit! (uds/hide-shape id))) (when (contains? selected id) - (rs/emit! (uds/select-shape id))))) + (st/emit! (uds/select-shape id))))) (defn- toggle-blocking [item event] @@ -71,8 +71,8 @@ (let [id (:id item) blocked? (:blocked item)] (if blocked? - (rs/emit! (uds/unblock-shape id)) - (rs/emit! (uds/block-shape id))))) + (st/emit! (uds/unblock-shape id)) + (st/emit! (uds/block-shape id))))) (defn- element-icon [item] @@ -116,7 +116,7 @@ data {:id (:id shape) :name (dom/get-value target)}] (set! (.-draggable parent) true) - (rs/emit! (uds/update-shape data)) + (st/emit! (uds/update-shape data)) (swap! local assoc :edition false))) (on-key-down [event] (js/console.log event) @@ -168,8 +168,8 @@ (let [id (dnd/get-data event) over (:over @local)] (case (:over @local) - :top (rs/emit! (uds/drop-shape id (:id item) :before)) - :bottom (rs/emit! (uds/drop-shape id (:id item) :after))) + :top (st/emit! (uds/drop-shape id (:id item) :before)) + :bottom (st/emit! (uds/drop-shape id (:id item) :after))) (swap! local assoc :dragging false :over nil))) (on-drag-over [event] (dom/prevent-default event) @@ -228,13 +228,13 @@ (letfn [(toggle-collapse [event] (dom/stop-propagation event) (if (:collapsed item) - (rs/emit! (uds/uncollapse-shape id)) - (rs/emit! (uds/collapse-shape id)))) + (st/emit! (uds/uncollapse-shape id)) + (st/emit! (uds/collapse-shape id)))) (toggle-locking [event] (dom/stop-propagation event) (if (:locked item) - (rs/emit! (uds/unlock-shape id)) - (rs/emit! (uds/lock-shape id)))) + (st/emit! (uds/unlock-shape id)) + (st/emit! (uds/lock-shape id)))) (on-drag-start [event] (let [target (dom/event->target event)] (dnd/set-allowed-effect! event "move") @@ -247,9 +247,9 @@ (let [coming-id (dnd/get-data event) over (:over @local)] (case (:over @local) - :top (rs/emit! (uds/drop-shape coming-id id :before)) - :bottom (rs/emit! (uds/drop-shape coming-id id :after)) - :middle (rs/emit! (uds/drop-shape coming-id id :inside))) + :top (st/emit! (uds/drop-shape coming-id id :before)) + :bottom (st/emit! (uds/drop-shape coming-id id :after)) + :middle (st/emit! (uds/drop-shape coming-id id :inside))) (swap! local assoc :dragging false :over nil))) (on-drag-over [event] (dom/prevent-default event) @@ -309,11 +309,11 @@ selected (:selected workspace) shapes-map (mx/react wb/shapes-by-id-ref) page (mx/react (focus-page (:page workspace))) - close #(rs/emit! (udw/toggle-flag :layers)) - duplicate #(rs/emit! (uds/duplicate-selected)) - group #(rs/emit! (uds/group-selected)) - degroup #(rs/emit! (uds/degroup-selected)) - delete #(rs/emit! (uds/delete-selected)) + close #(st/emit! (udw/toggle-flag :layers)) + duplicate #(st/emit! (uds/duplicate-selected)) + group #(st/emit! (uds/group-selected)) + degroup #(st/emit! (uds/degroup-selected)) + delete #(st/emit! (uds/delete-selected)) dragel (volatile! nil)] [:div#layers.tool-window [:div.tool-window-bar diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options.cljs index 0fff5367d..8bedc0ddd 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options.cljs @@ -10,8 +10,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.workspace.base :as wb] @@ -132,7 +132,7 @@ {:mixins [mx/static mx/reactive]} [] (let [shape (mx/react selected-shape-ref) - close #(rs/emit! (udw/toggle-flag :element-options))] + close #(st/emit! (udw/toggle-flag :element-options))] [:div.elementa-options.tool-window [:div.tool-window-bar [:div.tool-window-icon i/options] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/circle_measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/circle_measures.cljs index 7da27c083..6f2a5b681 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/circle_measures.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/circle_measures.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.icons :as i] @@ -31,22 +31,22 @@ value (parse-int value 0) sid (:id shape) props {attr value}] - (rs/emit! (uds/update-size sid props)))) + (st/emit! (uds/update-size sid props)))) (on-rotation-change [event] (let [value (dom/event->value event) value (parse-int value 0) sid (:id shape)] - (rs/emit! (uds/update-rotation sid value)))) + (st/emit! (uds/update-rotation sid value)))) (on-pos-change [attr event] (let [value (dom/event->value event) value (parse-int value nil) sid (:id shape) props {attr value}] - (rs/emit! (uds/update-position sid props)))) + (st/emit! (uds/update-position sid props)))) (on-proportion-lock-change [event] (if (:proportion-lock shape) - (rs/emit! (uds/unlock-proportions id)) - (rs/emit! (uds/lock-proportions id))))] + (st/emit! (uds/unlock-proportions id)) + (st/emit! (uds/lock-proportions id))))] [:div.element-set {:key (str (:id menu))} [:div.element-set-title (:name menu)] [:div.element-set-content diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/fill.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/fill.cljs index 50bf77148..5853f51b8 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/fill.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/fill.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.shapes :as uds] [uxbox.main.data.lightbox :as udl] [uxbox.main.ui.icons :as i] @@ -24,7 +24,7 @@ [own menu shape] (letfn [(change-fill [value] (let [sid (:id shape)] - (rs/emit! (uds/update-fill-attrs sid value)))) + (st/emit! (uds/update-fill-attrs sid value)))) (on-color-change [event] (let [value (dom/event->value event)] (change-fill {:color value}))) diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/icon_measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/icon_measures.cljs index 3f45fcb14..7348fe695 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/icon_measures.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/icon_measures.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.icons :as i] @@ -30,18 +30,18 @@ value (parse-int value 0) sid (:id shape) props {attr value}] - (rs/emit! (uds/update-size sid props)))) + (st/emit! (uds/update-size sid props)))) (on-rotation-change [event] (let [value (dom/event->value event) value (parse-int value 0) sid (:id shape)] - (rs/emit! (uds/update-rotation sid value)))) + (st/emit! (uds/update-rotation sid value)))) (on-pos-change [attr event] (let [value (dom/event->value event) value (parse-int value nil) sid (:id shape) props {attr value}] - (rs/emit! (uds/update-position sid props))))] + (st/emit! (uds/update-position sid props))))] (let [size (geom/size shape)] (html [:div.element-set {:key (str (:id menu))} diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/interactions.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/interactions.cljs index 73b9adac7..e77e02171 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/interactions.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/interactions.cljs @@ -11,9 +11,9 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.mixins :as mx :include-macros true] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.shapes :as uds] [uxbox.main.data.lightbox :as udl] [uxbox.main.ui.workspace.sidebar.sitemap :refer (pages-ref)] @@ -62,7 +62,7 @@ (delete [item] (let [sid (:id shape) id (:id item)] - (rs/emit! (uds/delete-interaction sid id)))) + (st/emit! (uds/delete-interaction sid id)))) (on-delete [item event] (dom/prevent-default event) (let [delete (partial delete item)] @@ -543,7 +543,7 @@ (dom/prevent-default event) (let [shape-id (:id shape) data (deref form-ref)] - (rs/emit! (uds/update-interaction shape-id data)) + (st/emit! (uds/update-interaction shape-id data)) (reset! form-ref nil))) (on-cancel [event] (dom/prevent-default event) diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/line_measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/line_measures.cljs index 24842ef67..aca3e2328 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/line_measures.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/line_measures.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.icons :as i] @@ -29,13 +29,13 @@ (let [value (dom/event->value event) value (parse-int value 0) sid (:id shape)] - (rs/emit! (uds/update-rotation sid value)))) + (st/emit! (uds/update-rotation sid value)))) (on-pos-change [attr event] (let [value (dom/event->value event) value (parse-int value nil) sid (:id shape) props {attr value}] - (rs/emit! (uds/update-line-attrs sid props))))] + (st/emit! (uds/update-line-attrs sid props))))] (html [:div.element-set {:key (str (:id menu))} [:div.element-set-title (:name menu)] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/page.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/page.cljs index 3b7e37109..1dee67c4e 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/page.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/page.cljs @@ -10,8 +10,8 @@ (:require [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.icons :as i] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/rect_measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/rect_measures.cljs index d73425b5b..b5ed11a8d 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/rect_measures.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/rect_measures.cljs @@ -9,8 +9,8 @@ (:require [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.icons :as i] @@ -28,28 +28,28 @@ (let [value (-> (dom/event->value event) (parse-int 0)) sid (:id shape) props {attr value}] - (rs/emit! (uds/update-size sid props)))) + (st/emit! (uds/update-size sid props)))) (on-rotation-change [event] (let [value (dom/event->value event) value (parse-int value 0) sid (:id shape)] - (rs/emit! (uds/update-rotation sid value)))) + (st/emit! (uds/update-rotation sid value)))) (on-pos-change [attr event] (let [value (dom/event->value event) value (parse-int value nil) sid (:id shape) props {attr value}] - (rs/emit! (uds/update-position sid props)))) + (st/emit! (uds/update-position sid props)))) (on-border-change [attr event] (let [value (dom/event->value event) value (parse-int value nil) sid (:id shape) props {attr value}] - (rs/emit! (uds/update-radius-attrs sid props)))) + (st/emit! (uds/update-radius-attrs sid props)))) (on-proportion-lock-change [event] (if (:proportion-lock shape) - (rs/emit! (uds/unlock-proportions id)) - (rs/emit! (uds/lock-proportions id))))] + (st/emit! (uds/unlock-proportions id)) + (st/emit! (uds/lock-proportions id))))] (let [size (geom/size shape)] [:div.element-set [:div.element-set-title (:name menu)] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/stroke.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/stroke.cljs index 2078649fa..717dfae1e 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/stroke.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/stroke.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.shapes :as uds] [uxbox.main.data.lightbox :as udl] [uxbox.main.ui.icons :as i] @@ -24,7 +24,7 @@ [own menu shape] (letfn [(change-stroke [value] (let [sid (:id shape)] - (rs/emit! (uds/update-stroke-attrs sid value)))) + (st/emit! (uds/update-stroke-attrs sid value)))) (on-width-change [event] (let [value (dom/event->value event) value (parse-float value 1)] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/text.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/text.cljs index 89043a448..91b27d6f9 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/text.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/text.cljs @@ -11,8 +11,8 @@ [lentes.core :as l] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.workspace :as udw] [uxbox.main.data.shapes :as uds] [uxbox.main.ui.workspace.base :as wb] @@ -39,26 +39,26 @@ params {:family (read-string value) :weight "normal" :style "normal"}] - (rs/emit! (uds/update-font-attrs sid params)))) + (st/emit! (uds/update-font-attrs sid params)))) (on-font-size-change [event] (let [value (dom/event->value event) params {:size (parse-int value)} sid (:id shape)] - (rs/emit! (uds/update-font-attrs sid params)))) + (st/emit! (uds/update-font-attrs sid params)))) (on-font-letter-spacing-change [event] (let [value (dom/event->value event) params {:letter-spacing (parse-float value)} sid (:id shape)] - (rs/emit! (uds/update-font-attrs sid params)))) + (st/emit! (uds/update-font-attrs sid params)))) (on-font-line-height-change [event] (let [value (dom/event->value event) params {:line-height (parse-float value)} sid (:id shape)] - (rs/emit! (uds/update-font-attrs sid params)))) + (st/emit! (uds/update-font-attrs sid params)))) (on-font-align-change [event value] (let [params {:align value} sid (:id shape)] - (rs/emit! (uds/update-font-attrs sid params)))) + (st/emit! (uds/update-font-attrs sid params)))) (on-font-style-change [event] (let [value (dom/event->value event) @@ -66,7 +66,7 @@ sid (:id shape) params {:style style :weight weight}] - (rs/emit! (uds/update-font-attrs sid params))))] + (st/emit! (uds/update-font-attrs sid params))))] (let [{:keys [family style weight size align line-height letter-spacing] :or {family "sourcesanspro" align "left" diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/sitemap.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/sitemap.cljs index bcdb0d166..ea5fb7d6f 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/sitemap.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/sitemap.cljs @@ -10,8 +10,8 @@ [cuerdas.core :as str] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.data.projects :as dp] [uxbox.main.data.pages :as udp] [uxbox.main.data.workspace :as dw] @@ -45,11 +45,11 @@ (udl/open! :page-form {:page page})) (on-navigate [event] - (rs/emit! (dp/go-to (:project page) (:id page)))) + (st/emit! (dp/go-to (:project page) (:id page)))) (delete [] - (let [next #(rs/emit! (dp/go-to (:project page)))] - (rs/emit! (udp/delete-page (:id page) next)))) + (let [next #(st/emit! (dp/go-to (:project page)))] + (st/emit! (udp/delete-page (:id page) next)))) (on-delete [event] (dom/prevent-default event) @@ -71,7 +71,7 @@ pages (mx/react pages-ref) current (mx/react wb/page-ref) create #(udl/open! :page-form {:page {:project (:id project)}}) - close #(rs/emit! (dw/toggle-flag :sitemap))] + close #(st/emit! (dw/toggle-flag :sitemap))] [:div.sitemap.tool-window [:div.tool-window-bar [:div.tool-window-icon i/project-tree] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/sitemap_pageform.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/sitemap_pageform.cljs index ee74c4f70..b8c305dae 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/sitemap_pageform.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/sitemap_pageform.cljs @@ -8,7 +8,7 @@ (ns uxbox.main.ui.workspace.sidebar.sitemap-pageform (:require [lentes.core :as l] [cuerdas.core :as str] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.data.pages :as udp] [uxbox.main.data.workspace :as dw] [uxbox.main.data.lightbox :as udl] @@ -17,7 +17,7 @@ [uxbox.main.ui.lightbox :as lbx] [uxbox.util.i18n :refer (tr)] [uxbox.util.router :as r] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.forms :as forms] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.data :refer (deep-merge parse-int)] @@ -81,8 +81,8 @@ (dom/prevent-default e) (udl/close!) (if (nil? id) - (rs/emit! (udp/create-page data)) - (rs/emit! (udp/update-page id data))))] + (st/emit! (udp/create-page data)) + (st/emit! (udp/update-page id data))))] [:form [:input#project-name.input-text {:placeholder "Page name" diff --git a/frontend/src/uxbox/store.cljs b/frontend/src/uxbox/store.cljs new file mode 100644 index 000000000..52a5e6028 --- /dev/null +++ b/frontend/src/uxbox/store.cljs @@ -0,0 +1,35 @@ +;; 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/. +;; +;; Copyright (c) 2015-2016 Andrey Antukh + +(ns uxbox.store + (:require [beicon.core :as rx] + [lentes.core :as l] + [potok.core :as ptk])) + +(enable-console-print!) + +(def ^:dynamic *on-error* identity) + +(defonce state (atom {})) +(defonce loader (atom false)) +(defonce store (ptk/store {:on-error #(*on-error* %)})) + +(def auth-ref + (-> (l/key :auth) + (l/derive state))) + +(defn emit! + ([event] + (ptk/emit! store event)) + ([event & events] + (apply ptk/emit! store (cons event events)))) + +(defn init + "Initialize the state materialization." + [initial-state] + (let [istate (if (fn? initial-state) (initial-state) initial-state)] + (emit! (constantly istate)) + (rx/to-atom store state))) diff --git a/frontend/src/uxbox/util/forms.cljs b/frontend/src/uxbox/util/forms.cljs index 2c990b05d..e9a5ecba2 100644 --- a/frontend/src/uxbox/util/forms.cljs +++ b/frontend/src/uxbox/util/forms.cljs @@ -7,10 +7,11 @@ (ns uxbox.util.forms (:refer-clojure :exclude [keyword uuid vector boolean map set]) - (:require [struct.core :as st] + (:require [struct.core :as f] [lentes.core :as l] [beicon.core :as rx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.i18n :refer (tr)])) @@ -21,35 +22,35 @@ ;; --- Form Validators (def required - (assoc st/required :message "errors.form.required")) + (assoc f/required :message "errors.form.required")) (def string - (assoc st/string :message "errors.form.string")) + (assoc f/string :message "errors.form.string")) (def number - (assoc st/number :message "errors.form.number")) + (assoc f/number :message "errors.form.number")) (def integer - (assoc st/integer :message "errors.form.integer")) + (assoc f/integer :message "errors.form.integer")) (def boolean - (assoc st/boolean :message "errors.form.bool")) + (assoc f/boolean :message "errors.form.bool")) (def identical-to - (assoc st/identical-to :message "errors.form.identical-to")) + (assoc f/identical-to :message "errors.form.identical-to")) -(def in-range st/in-range) -;; (def uuid-like st/uuid-like) -(def uuid st/uuid) -(def keyword st/keyword) -(def integer-str st/integer-str) -(def number-str st/number-str) -;; (def boolean-like st/boolean-like) -(def email st/email) -;; (def function st/function) -(def positive st/positive) -;; (def validate st/validate) -;; (def validate! st/validate!) +(def in-range f/in-range) +;; (def uuid-like f/uuid-like) +(def uuid f/uuid) +(def keyword f/keyword) +(def integer-str f/integer-str) +(def number-str f/number-str) +;; (def boolean-like f/boolean-like) +(def email f/email) +;; (def function f/function) +(def positive f/positive) +;; (def validate f/validate) +;; (def validate! f/validate!) (def max-len {:message "errors.form.max-len" @@ -75,7 +76,7 @@ ([data schema] (validate data schema nil)) ([data schema opts] - (st/validate data schema opts))) + (f/validate data schema opts))) (defn validate! ([data schema] @@ -98,8 +99,8 @@ ;; --- Set Error (defrecord SetError [type field error] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:errors type field] error))) (defn set-error @@ -113,13 +114,13 @@ (defn set-error! [& args] - (rs/emit! (apply set-error args))) + (st/emit! (apply set-error args))) ;; --- Set Errors (defrecord SetErrors [type errors] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:errors type] errors))) (defn set-errors @@ -133,13 +134,13 @@ (defn set-errors! [& args] - (rs/emit! (apply set-errors args))) + (st/emit! (apply set-errors args))) ;; --- Set Value (defrecord SetValue [type field value] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [form-path (into [:forms type] (if (coll? field) field [field])) errors-path (into [:errors type] (if (coll? field) field [field]))] (-> state @@ -155,13 +156,13 @@ (defn set-value! [type field value] - (rs/emit! (set-value type field value))) + (st/emit! (set-value type field value))) ;; --- Validate Form ;; (defrecord ValidateForm [type form data on-success] -;; rs/WatchEvent -;; (-apply-watch [_ state stream] +;; ptk/WatchEvent +;; (watch [_ state stream] ;; (let [[errors data] (validate data form)] ;; (if errors ;; (rx/of (set-errors type errors)) @@ -179,13 +180,13 @@ ;; (defn validate-form! ;; [& args] -;; (rs/emit! (apply validate-form args))) +;; (f/emit! (apply validate-form args))) ;; --- Clear Form (defrecord ClearForm [type] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:forms type] nil))) (defn clear-form @@ -195,13 +196,13 @@ (defn clear-form! [type] - (rs/emit! (clear-form type))) + (st/emit! (clear-form type))) ;; --- Clear Form (defrecord ClearErrors [type] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (assoc-in state [:errors type] nil))) (defn clear-errors @@ -211,13 +212,13 @@ (defn clear-errors! [type] - (rs/emit! (clear-errors type))) + (st/emit! (clear-errors type))) ;; --- Clear (defrecord Clear [type] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (clear-form type) (clear-errors type)))) @@ -227,7 +228,7 @@ (defn clear! [type] - (rs/emit! (clear type))) + (st/emit! (clear type))) ;; --- Helpers diff --git a/frontend/src/uxbox/util/router.cljs b/frontend/src/uxbox/util/router.cljs index 93d501776..4168aaf69 100644 --- a/frontend/src/uxbox/util/router.cljs +++ b/frontend/src/uxbox/util/router.cljs @@ -8,7 +8,8 @@ (ns uxbox.util.router (:require [bide.core :as r] [beicon.core :as rx] - [uxbox.util.rstore :as rs])) + [potok.core :as ptk] + [uxbox.store :as st])) (enable-console-print!) @@ -17,8 +18,8 @@ ;; --- Update Location (Event) (defrecord UpdateLocation [id params] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [route (merge {:id id} (when params {:params params}))] @@ -35,8 +36,8 @@ ;; --- Navigate (Event) (defrecord Navigate [id params] - rs/EffectEvent - (-apply-effect [_ state] + ptk/EffectEvent + (effect [_ state stream] (r/navigate! +router+ id params))) (defn navigate @@ -51,7 +52,7 @@ ([routes] (init routes nil)) ([routes {:keys [default] :or {default :auth/login}}] - (let [opts {:on-navigate #(rs/emit! (update-location %1 %2)) + (let [opts {:on-navigate #(st/emit! (update-location %1 %2)) :default default} router (-> (r/router routes) (r/start! opts))] @@ -62,7 +63,7 @@ "Redirect the user to other url." ([id] (go id nil)) ([id params] - (rs/emit! (navigate id params)))) + (st/emit! (navigate id params)))) (defn route-for "Given a location handler and optional parameter map, return the URI diff --git a/frontend/src/uxbox/util/rstore.cljs b/frontend/src/uxbox/util/rstore.cljs deleted file mode 100644 index a30a947b7..000000000 --- a/frontend/src/uxbox/util/rstore.cljs +++ /dev/null @@ -1,115 +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/. -;; -;; Copyright (c) 2015-2016 Andrey Antukh -;; Copyright (c) 2015-2016 Juan de la Cruz - -(ns uxbox.util.rstore - "Reactive storage management architecture helpers." - (:require [beicon.core :as rx])) - -;; An abstraction for implement a simple state -;; transition. The `-apply-update` function receives -;; the state and shoudl return the transformed state. - -(defprotocol UpdateEvent - (-apply-update [event state])) - -;; An abstraction for perform some async stuff such -;; as communicate with api rest or other resources -;; that implies asynchronous access. -;; The `-apply-watch` receives the state and should -;; return a reactive stream of events (that can be -;; of `UpdateEvent`, `WatchEvent` or `EffectEvent`. - -(defprotocol WatchEvent - (-apply-watch [event state s])) - -;; An abstraction for perform just side effects. It -;; receives state and its return value is completly -;; ignored. - -(defprotocol EffectEvent - (-apply-effect [event state])) - -(defn update? - "Return `true` when `e` satisfies - the UpdateEvent protocol." - [e] - (satisfies? UpdateEvent e)) - -(defn watch? - "Return `true` when `e` satisfies - the WatchEvent protocol." - [e] - (satisfies? WatchEvent e)) - -(defn effect? - "Return `true` when `e` satisfies - the EffectEvent protocol." - [e] - (satisfies? EffectEvent e)) - -(extend-protocol UpdateEvent - function - (-apply-update [func state] - (func state))) - -(defonce ^:private bus (rx/bus)) -(defonce stream (rx/map identity bus)) - -(defn emit! - "Emits an event or a collection of them." - ([event] - (rx/push! bus event)) - ([event & events] - (run! emit! (cons event events)))) - -(defonce ^:private error-handlers - (atom {})) - -(defn add-error-watcher - [key callable] - (swap! error-handlers assoc key callable)) - -(defn remove-error-watcher - [key] - (swap! error-handlers dissoc key)) - -(defn- on-error - [error] - (doseq [[key value] @error-handlers] - (value error)) - (throw error)) - -(defn init - "Initializes the stream event loop and - return a stream with model changes." - [state] - (let [watch-s (rx/filter watch? stream) - effect-s (rx/filter effect? stream) - update-s (rx/filter update? stream) - state-s (->> update-s - (rx/scan #(-apply-update %2 %1) state) - (rx/catch on-error) - (rx/retry 1024) - (rx/share))] - - ;; Process event sources: combine with the latest model and the result will be - ;; pushed to the event-stream bus - (as-> watch-s $ - (rx/with-latest-from vector state-s $) - (rx/flat-map (fn [[event model]] (-apply-watch event model stream)) $) - (rx/catch on-error $) - (rx/retry 1024 $) - (rx/on-value $ emit!)) - - ;; Process effects: combine with the latest model to process the new effect - (as-> effect-s $ - (rx/with-latest-from vector state-s $) - (rx/subscribe $ (fn [[event model]] (-apply-effect event model)))) - - ;; Initialize the stream machinary with initial state. - (emit! #(merge % state)) - state-s)) diff --git a/frontend/src/uxbox/view.cljs b/frontend/src/uxbox/view.cljs index f055a8777..fabd74a16 100644 --- a/frontend/src/uxbox/view.cljs +++ b/frontend/src/uxbox/view.cljs @@ -6,10 +6,10 @@ (ns uxbox.view (:require [uxbox.config] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.view.ui :as ui])) -(defn initial-state +(defn- initial-state [] {:route nil :project nil diff --git a/frontend/src/uxbox/view/data/viewer.cljs b/frontend/src/uxbox/view/data/viewer.cljs index 15c102379..3c3845ba9 100644 --- a/frontend/src/uxbox/view/data/viewer.cljs +++ b/frontend/src/uxbox/view/data/viewer.cljs @@ -6,7 +6,7 @@ (ns uxbox.view.data.viewer (:require [beicon.core :as rx] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as rt] [uxbox.util.forms :as sc] [uxbox.util.data :refer (parse-int)] @@ -19,8 +19,8 @@ (declare load-data) (defrecord Initialize [token] - rs/WatchEvent - (-apply-watch [_ state s] + ptk/WatchEvent + (watch [_ state s] (rx/of (load-data token)))) (defn initialize @@ -44,8 +44,8 @@ (update :pages conj page)))) (defrecord DataLoaded [data] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [project (dissoc data :pages) pages (sort-by :created-at (:pages data))] (as-> state $ @@ -60,8 +60,8 @@ ;; --- Load Data (defrecord LoadData [token] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (->> (rp/req :fetch/project-by-token token) (rx/map :payload) (rx/map data-loaded)))) @@ -73,8 +73,8 @@ ;; --- Select Page (defrecord SelectPage [index] - rs/WatchEvent - (-apply-watch [_ state stream] + ptk/WatchEvent + (watch [_ state stream] (let [token (get-in state [:route :params :token])] (rx/of (rt/navigate :view/viewer {:token token :id index}))))) @@ -85,8 +85,8 @@ ;; --- Toggle Flag (defrecord ToggleFlag [key] - rs/UpdateEvent - (-apply-update [_ state] + ptk/UpdateEvent + (update [_ state] (let [flags (:flags state #{})] (if (contains? flags key) (assoc state :flags (disj flags key)) diff --git a/frontend/src/uxbox/view/ui.cljs b/frontend/src/uxbox/view/ui.cljs index 7b3eea82d..bc5db0179 100644 --- a/frontend/src/uxbox/view/ui.cljs +++ b/frontend/src/uxbox/view/ui.cljs @@ -7,17 +7,18 @@ (ns uxbox.view.ui (:require [lentes.core :as l] [uxbox.util.i18n :refer (tr)] - [uxbox.util.rstore :as rs] - [uxbox.util.router :as rt] - [uxbox.util.mixins :as mx :include-macros true] - [uxbox.util.dom :as dom] + [potok.core :as ptk] + [uxbox.store :as st] + [uxbox.main.data.messages :as dmsg] [uxbox.main.ui.loader :refer (loader)] [uxbox.main.ui.lightbox :refer (lightbox)] - [uxbox.main.state :as st] - [uxbox.main.data.messages :as dmsg] [uxbox.main.ui.icons :as i] [uxbox.view.ui.notfound :refer (notfound-page)] - [uxbox.view.ui.viewer :refer (viewer-page)])) + [uxbox.view.ui.viewer :refer (viewer-page)] + [uxbox.util.router :as rt] + [uxbox.util.mixins :as mx :include-macros true] + [uxbox.util.dom :as dom])) + (def route-id-ref (-> (l/in [:route :id]) @@ -39,7 +40,7 @@ (dmsg/error! (tr "errors.generic")) (js/console.error "Stack:" (.-stack error))))) -(rs/add-error-watcher :ui on-error) +(set! st/*on-error* on-error) ;; --- Main App (Component) diff --git a/frontend/src/uxbox/view/ui/viewer.cljs b/frontend/src/uxbox/view/ui/viewer.cljs index 5ce6fa5c0..6b91ba03c 100644 --- a/frontend/src/uxbox/view/ui/viewer.cljs +++ b/frontend/src/uxbox/view/ui/viewer.cljs @@ -8,11 +8,11 @@ (ns uxbox.view.ui.viewer (:require [lentes.core :as l] [uxbox.util.i18n :refer (tr)] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.router :as rt] [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.ui.icons :as i] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.view.data.viewer :as dv] [uxbox.view.ui.viewer.nav :refer (nav)] [uxbox.view.ui.viewer.canvas :refer (canvas)] @@ -33,7 +33,7 @@ (defn- viewer-page-will-mount [own] (letfn [(on-change [token] - (rs/emit! (dv/initialize token)))] + (st/emit! (dv/initialize token)))] (add-watch token-ref ::wkey #(on-change %4)) (on-change @token-ref) own)) diff --git a/frontend/src/uxbox/view/ui/viewer/canvas.cljs b/frontend/src/uxbox/view/ui/viewer/canvas.cljs index 156015fff..21728b463 100644 --- a/frontend/src/uxbox/view/ui/viewer/canvas.cljs +++ b/frontend/src/uxbox/view/ui/viewer/canvas.cljs @@ -11,7 +11,7 @@ [rum.core :as rum] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.data :refer (parse-int)] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.ui.shapes :as uus] [uxbox.main.ui.icons :as i] [uxbox.view.ui.viewer.shapes :as shapes])) diff --git a/frontend/src/uxbox/view/ui/viewer/interactions.cljs b/frontend/src/uxbox/view/ui/viewer/interactions.cljs index 428c6c44e..2bddaa1bf 100644 --- a/frontend/src/uxbox/view/ui/viewer/interactions.cljs +++ b/frontend/src/uxbox/view/ui/viewer/interactions.cljs @@ -6,12 +6,12 @@ (ns uxbox.view.ui.viewer.interactions (:require [uxbox.util.dom :as dom] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] [uxbox.util.geom.matrix :as gmt] [uxbox.util.geom.point :as gpt] [uxbox.util.timers :as ts] [uxbox.main.geom :as geom] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.view.data.viewer :as dv] [vendor.snapsvg]) ;; Documentation about available events: @@ -145,7 +145,7 @@ (defn- run-gotopage-interaction [{:keys [page]}] - (rs/emit! (dv/select-page page))) + (st/emit! (dv/select-page page))) (defn- run-color-interaction [{:keys [element fill-color stroke-color direction easing delay duration]}] diff --git a/frontend/src/uxbox/view/ui/viewer/nav.cljs b/frontend/src/uxbox/view/ui/viewer/nav.cljs index 9e5ae8292..a71b6e549 100644 --- a/frontend/src/uxbox/view/ui/viewer/nav.cljs +++ b/frontend/src/uxbox/view/ui/viewer/nav.cljs @@ -7,14 +7,15 @@ (ns uxbox.view.ui.viewer.nav (:require [uxbox.util.mixins :as mx :include-macros true] - [uxbox.util.rstore :as rs] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.ui.icons :as i] [uxbox.view.data.viewer :as dv])) (mx/defc nav [flags] - (let [toggle-sitemap #(rs/emit! (dv/toggle-flag :sitemap)) - toggle-interactions #(rs/emit! (dv/toggle-flag :interactions)) + (let [toggle-sitemap #(st/emit! (dv/toggle-flag :sitemap)) + toggle-interactions #(st/emit! (dv/toggle-flag :interactions)) sitemap? (contains? flags :sitemap) interactions? (contains? flags :interactions)] [:div.view-nav diff --git a/frontend/src/uxbox/view/ui/viewer/shapes.cljs b/frontend/src/uxbox/view/ui/viewer/shapes.cljs index 843e7e4df..8f76d4e73 100644 --- a/frontend/src/uxbox/view/ui/viewer/shapes.cljs +++ b/frontend/src/uxbox/view/ui/viewer/shapes.cljs @@ -8,7 +8,7 @@ (:require [goog.events :as events] [lentes.core :as l] [uxbox.util.mixins :as mx :include-macros true] - [uxbox.main.state :as st] + [uxbox.store :as st] [uxbox.main.geom :as geom] [uxbox.main.ui.shapes.rect :refer (rect-shape)] [uxbox.main.ui.shapes.icon :refer (icon-shape)] diff --git a/frontend/src/uxbox/view/ui/viewer/sitemap.cljs b/frontend/src/uxbox/view/ui/viewer/sitemap.cljs index 6c8eceff1..21b1480d8 100644 --- a/frontend/src/uxbox/view/ui/viewer/sitemap.cljs +++ b/frontend/src/uxbox/view/ui/viewer/sitemap.cljs @@ -11,8 +11,8 @@ [uxbox.util.i18n :refer (tr)] [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.data :refer (parse-int)] - [uxbox.util.rstore :as rs] - [uxbox.main.state :as st] + [potok.core :as ptk] + [uxbox.store :as st] [uxbox.main.ui.icons :as i] [uxbox.view.data.viewer :as dv])) @@ -39,7 +39,7 @@ (let [project-name (mx/react project-name-ref) pages (mx/react pages-ref) selected (mx/react selected-ref) - on-click #(rs/emit! (dv/select-page %))] + on-click #(st/emit! (dv/select-page %))] [:div.view-sitemap [:span.sitemap-title project-name] [:ul.sitemap-list