mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 08:50:57 -05:00
parent
6e7a20974d
commit
d69ab9edd8
3 changed files with 15 additions and 17 deletions
|
@ -47,23 +47,23 @@
|
||||||
|
|
||||||
(declare initialize-alignment)
|
(declare initialize-alignment)
|
||||||
|
|
||||||
(defrecord InitializeWorkspace [project page]
|
(defrecord InitializeWorkspace [project-id page-id]
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [default-flags #{:sitemap :drawtools :layers :element-options :rules}]
|
(let [default-flags #{:sitemap :drawtools :layers :element-options :rules}]
|
||||||
(if (:workspace state)
|
(if (:workspace state)
|
||||||
(update state :workspace merge
|
(update state :workspace merge
|
||||||
{:project project
|
{:project project-id
|
||||||
:page page
|
:page page-id
|
||||||
:selected #{}
|
:selected #{}
|
||||||
:flags default-flags
|
:flags default-flags
|
||||||
:drawing nil
|
:drawing nil
|
||||||
:drawing-tool nil
|
:drawing-tool nil
|
||||||
:tooltip nil})
|
:tooltip nil})
|
||||||
(assoc state :workspace
|
(assoc state :workspace
|
||||||
{:project project
|
{:project project-id
|
||||||
:zoom 1
|
:zoom 1
|
||||||
:page page
|
:page page-id
|
||||||
:flags default-flags
|
:flags default-flags
|
||||||
:selected #{}
|
:selected #{}
|
||||||
:drawing nil
|
:drawing nil
|
||||||
|
@ -71,9 +71,8 @@
|
||||||
:tooltip nil}))))
|
:tooltip nil}))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state s]
|
(watch [_ state stream]
|
||||||
(let [page-id page
|
(let [page (get-in state [:pages page-id])]
|
||||||
page (get-in state [:pages page-id])]
|
|
||||||
|
|
||||||
;; Activate loaded if page is not fetched.
|
;; Activate loaded if page is not fetched.
|
||||||
(when-not page (reset! st/loader true))
|
(when-not page (reset! st/loader true))
|
||||||
|
@ -82,13 +81,14 @@
|
||||||
(if page
|
(if page
|
||||||
(rx/of (initialize-alignment page-id))
|
(rx/of (initialize-alignment page-id))
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(rx/of (udp/fetch-pages project))
|
(rx/of (udp/fetch-pages project-id))
|
||||||
(->> (rx/filter udp/pages-fetched? s)
|
(->> (rx/filter udp/pages-fetched? stream)
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/do #(reset! st/loader false))
|
(rx/do #(reset! st/loader false))
|
||||||
(rx/map #(initialize-alignment page-id)))))
|
(rx/map #(initialize-alignment page-id)))))
|
||||||
|
|
||||||
;; Initial history loading
|
;; Initial history loading
|
||||||
|
;; FIXME: move this to the history sidebar component
|
||||||
(rx/of
|
(rx/of
|
||||||
(udh/fetch-page-history page-id)
|
(udh/fetch-page-history page-id)
|
||||||
(udh/fetch-pinned-page-history page-id)))))
|
(udh/fetch-pinned-page-history page-id)))))
|
||||||
|
@ -316,12 +316,8 @@
|
||||||
:height c/viewport-height
|
:height c/viewport-height
|
||||||
:x-axis (:grid-x-axis metadata c/grid-x-axis)
|
:x-axis (:grid-x-axis metadata c/grid-x-axis)
|
||||||
:y-axis (:grid-y-axis metadata c/grid-y-axis)}]
|
:y-axis (:grid-y-axis metadata c/grid-y-axis)}]
|
||||||
(rx/merge
|
(rx/concat
|
||||||
(rx/of (deactivate-flag :grid-indexed)
|
(rx/of (deactivate-flag :grid-indexed))
|
||||||
(if (:grid-alignment metadata)
|
|
||||||
(activate-flag :grid-alignment)
|
|
||||||
(deactivate-flag :grid-alignment)))
|
|
||||||
|
|
||||||
(->> (uwrk/initialize-alignment params)
|
(->> (uwrk/initialize-alignment params)
|
||||||
(rx/map #(activate-flag :grid-indexed)))))))
|
(rx/map #(activate-flag :grid-indexed)))))))
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(:require [lentes.core :as l]))
|
(:require [lentes.core :as l]))
|
||||||
|
|
||||||
;; --- Workspace
|
;; --- Workspace
|
||||||
|
;; --- FIXME: remove this ns
|
||||||
|
|
||||||
(def workspace (l/key :workspace))
|
(def workspace (l/key :workspace))
|
||||||
(def workspace-flags (comp workspace (l/key :flags)))
|
(def workspace-flags (comp workspace (l/key :flags)))
|
||||||
|
|
|
@ -104,7 +104,8 @@
|
||||||
(defn alignment-activated?
|
(defn alignment-activated?
|
||||||
[state]
|
[state]
|
||||||
(let [{:keys [page flags]} (:workspace state)
|
(let [{:keys [page flags]} (:workspace state)
|
||||||
metadata (merge c/page-metadata (get-in state [:pages page :metadata]))]
|
metadata (->> (get-in state [:pages page :metadata])
|
||||||
|
(merge c/page-metadata))]
|
||||||
(and (contains? flags :grid-indexed)
|
(and (contains? flags :grid-indexed)
|
||||||
(contains? flags :grid)
|
(contains? flags :grid)
|
||||||
(:grid-alignment metadata))))
|
(:grid-alignment metadata))))
|
||||||
|
|
Loading…
Reference in a new issue