0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 16:30:37 -05:00

Fix inconsistencies in alignment related flags.

Related to #79.
This commit is contained in:
Andrey Antukh 2017-03-21 21:15:43 +01:00
parent 6e7a20974d
commit d69ab9edd8
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
3 changed files with 15 additions and 17 deletions

View file

@ -47,23 +47,23 @@
(declare initialize-alignment)
(defrecord InitializeWorkspace [project page]
(defrecord InitializeWorkspace [project-id page-id]
ptk/UpdateEvent
(update [_ state]
(let [default-flags #{:sitemap :drawtools :layers :element-options :rules}]
(if (:workspace state)
(update state :workspace merge
{:project project
:page page
{:project project-id
:page page-id
:selected #{}
:flags default-flags
:drawing nil
:drawing-tool nil
:tooltip nil})
(assoc state :workspace
{:project project
{:project project-id
:zoom 1
:page page
:page page-id
:flags default-flags
:selected #{}
:drawing nil
@ -71,9 +71,8 @@
:tooltip nil}))))
ptk/WatchEvent
(watch [_ state s]
(let [page-id page
page (get-in state [:pages page-id])]
(watch [_ state stream]
(let [page (get-in state [:pages page-id])]
;; Activate loaded if page is not fetched.
(when-not page (reset! st/loader true))
@ -82,13 +81,14 @@
(if page
(rx/of (initialize-alignment page-id))
(rx/merge
(rx/of (udp/fetch-pages project))
(->> (rx/filter udp/pages-fetched? s)
(rx/of (udp/fetch-pages project-id))
(->> (rx/filter udp/pages-fetched? stream)
(rx/take 1)
(rx/do #(reset! st/loader false))
(rx/map #(initialize-alignment page-id)))))
;; Initial history loading
;; FIXME: move this to the history sidebar component
(rx/of
(udh/fetch-page-history page-id)
(udh/fetch-pinned-page-history page-id)))))
@ -316,12 +316,8 @@
:height c/viewport-height
:x-axis (:grid-x-axis metadata c/grid-x-axis)
:y-axis (:grid-y-axis metadata c/grid-y-axis)}]
(rx/merge
(rx/of (deactivate-flag :grid-indexed)
(if (:grid-alignment metadata)
(activate-flag :grid-alignment)
(deactivate-flag :grid-alignment)))
(rx/concat
(rx/of (deactivate-flag :grid-indexed))
(->> (uwrk/initialize-alignment params)
(rx/map #(activate-flag :grid-indexed)))))))

View file

@ -2,6 +2,7 @@
(:require [lentes.core :as l]))
;; --- Workspace
;; --- FIXME: remove this ns
(def workspace (l/key :workspace))
(def workspace-flags (comp workspace (l/key :flags)))

View file

@ -104,7 +104,8 @@
(defn alignment-activated?
[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)
(contains? flags :grid)
(:grid-alignment metadata))))