0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

💄 Change stoper to stopper

This commit is contained in:
Aitor 2024-02-27 16:52:05 +01:00 committed by Andrey Antukh
parent c123cf6e98
commit f5dd199bc6
17 changed files with 75 additions and 77 deletions

View file

@ -63,7 +63,7 @@
ptk/WatchEvent
(watch [_ state stream]
(let [stoper-s (rx/filter (ptk/type? ::finalize) stream)
(let [stopper (rx/filter (ptk/type? ::finalize) stream)
profile-id (:profile-id state)]
(->> (rx/merge
@ -92,7 +92,7 @@
(rx/filter #(= id (:id %)))
(rx/map du/set-current-team)))
(rx/take-until stoper-s))))))
(rx/take-until stopper))))))
(defn finalize
[params]

View file

@ -234,7 +234,7 @@
ptk/EffectEvent
(effect [_ _ stream]
(let [session (atom nil)
stoper (rx/filter (ptk/type? ::initialize) stream)
stopper (rx/filter (ptk/type? ::initialize) stream)
buffer (atom #queue [])
profile (->> (rx/from-atom storage {:emit-current-value? true})
(rx/map :profile)
@ -259,7 +259,7 @@
(rx/tap (fn [_]
(l/debug :hint "events chunk persisted" :total (count chunk))))
(rx/map (constantly chunk))))))
(rx/take-until stoper)
(rx/take-until stopper)
(rx/subs! (fn [chunk]
(swap! buffer remove-from-buffer (count chunk)))
(fn [cause]
@ -290,7 +290,7 @@
(swap! buffer append-to-buffer event)))
(rx/switch-map #(rx/timer (inst-ms session-timeout)))
(rx/take-until stoper)
(rx/take-until stopper)
(rx/subs! (fn [_]
(l/debug :hint "session reinitialized")
(reset! session nil))

View file

@ -209,7 +209,7 @@
(rx/filter #(= @resource-id (:resource-id %)))
(rx/share))
stoper
stopper
(rx/filter #(or (= "ended" (:status %))
(= "error" (:status %)))
progress-stream)]
@ -228,12 +228,12 @@
(initialize-export-status exports cmd resource))))
;; We proceed to update the export state with incoming
;; progress updates. We delay the stoper for give some time
;; progress updates. We delay the stopper for give some time
;; to update the status with ended or errored status before
;; close the stream.
(->> progress-stream
(rx/map update-export-status)
(rx/take-until (rx/delay 500 stoper))
(rx/take-until (rx/delay 500 stopper))
(rx/finalize (fn []
(swap! st/ongoing-tasks disj :export))))
@ -246,7 +246,7 @@
(rx/take 1)
(rx/delay default-timeout)
(rx/map #(clear-export-state @resource-id))
(rx/take-until (rx/delay 6000 stoper))))))))
(rx/take-until (rx/delay 6000 stopper))))))))
(defn retry-last-export
[]

View file

@ -61,16 +61,16 @@
ptk/WatchEvent
(watch [_ _ stream]
(rx/merge
(let [stoper (rx/filter (ptk/type? ::hide) stream)]
(let [stopper (rx/filter (ptk/type? ::hide) stream)]
(->> stream
(rx/filter (ptk/type? :app.util.router/navigate))
(rx/map (constantly hide))
(rx/take-until stoper)))
(rx/take-until stopper)))
(when (:timeout data)
(let [stoper (rx/filter (ptk/type? ::show) stream)]
(let [stopper (rx/filter (ptk/type? ::show) stream)]
(->> (rx/of hide)
(rx/delay (:timeout data))
(rx/take-until stoper))))))))
(rx/take-until stopper))))))))
(def hide
(ptk/reify ::hide
@ -80,10 +80,10 @@
ptk/WatchEvent
(watch [_ _ stream]
(let [stoper (rx/filter (ptk/type? ::show) stream)]
(let [stopper (rx/filter (ptk/type? ::show) stream)]
(->> (rx/of #(dissoc % :message))
(rx/delay default-animation-timeout)
(rx/take-until stoper))))))
(rx/take-until stopper))))))
(defn hide-tag
[tag]

View file

@ -51,9 +51,9 @@
(vreset! ws-conn ws)
(let [stoper (rx/merge
(rx/filter (ptk/type? ::finalize) stream)
(rx/filter (ptk/type? ::initialize) stream))]
(let [stopper (rx/merge
(rx/filter (ptk/type? ::finalize) stream)
(rx/filter (ptk/type? ::initialize) stream))]
(->> (rx/merge
(rx/of #(assoc % :ws-conn ws))
@ -64,7 +64,7 @@
(->> (ws/get-rcv-stream ws)
(rx/filter ws/opened-event?)
(rx/map (fn [_] (ptk/data-event ::opened {})))))
(rx/take-until stoper)))))))
(rx/take-until stopper)))))))
;; --- Finalize Websocket

View file

@ -41,7 +41,6 @@
[app.main.data.workspace.changes :as dch]
[app.main.data.workspace.collapse :as dwco]
[app.main.data.workspace.drawing :as dwd]
[app.main.data.workspace.drawing.common :as dwdc]
[app.main.data.workspace.edition :as dwe]
[app.main.data.workspace.fix-bool-contents :as fbc]
[app.main.data.workspace.fix-broken-shapes :as fbs]
@ -153,7 +152,7 @@
(watch [_ _ stream]
(let [team-id (:id team)
file-id (:id file)
stoper-s (rx/filter (ptk/type? ::bundle-fetched) stream)]
stopper (rx/filter (ptk/type? ::bundle-fetched) stream)]
(->> (rx/concat
;; Initialize notifications
@ -204,7 +203,7 @@
(rx/of (with-meta (workspace-initialized)
{:file-id file-id})))
(rx/take-until stoper-s))))))
(rx/take-until stopper))))))
(defn- libraries-fetched
[libraries]
@ -2138,7 +2137,6 @@
(watch [_ _ _]
(if read-only?
(rx/of :interrupt
(dwdc/clear-drawing)
(remove-layout-flag :colorpalette)
(remove-layout-flag :textpalette))
(rx/empty)))))

View file

@ -526,9 +526,9 @@
(ptk/reify ::initialize-colorpicker
ptk/WatchEvent
(watch [_ _ stream]
(let [stoper (rx/merge
(rx/filter (ptk/type? ::finalize-colorpicker) stream)
(rx/filter (ptk/type? ::initialize-colorpicker) stream))]
(let [stopper (rx/merge
(rx/filter (ptk/type? ::finalize-colorpicker) stream)
(rx/filter (ptk/type? ::initialize-colorpicker) stream))]
(->> (rx/merge
(->> stream
@ -537,7 +537,7 @@
(rx/filter (ptk/type? ::update-colorpicker-color) stream)
(rx/filter (ptk/type? ::activate-colorpicker-gradient) stream))
(rx/map (constantly (colorpicker-onchange-runner on-change)))
(rx/take-until stoper))))
(rx/take-until stopper))))
ptk/UpdateEvent
(update [_ state]

View file

@ -34,7 +34,7 @@
(ptk/reify ::initialize-comments
ptk/WatchEvent
(watch [_ _ stream]
(let [stoper (rx/filter #(= ::finalize %) stream)]
(let [stopper (rx/filter #(= ::finalize %) stream)]
(rx/merge
(rx/of (dcm/retrieve-comment-threads file-id))
(->> stream
@ -45,11 +45,11 @@
(rx/filter (fn [[_ space]] (not space)))
(rx/map first)
(rx/map handle-comment-layer-click)
(rx/take-until stoper))
(rx/take-until stopper))
(->> stream
(rx/filter dwco/interrupt?)
(rx/map handle-interrupt)
(rx/take-until stoper)))))))
(rx/take-until stopper)))))))
(defn- handle-interrupt
[]

View file

@ -78,12 +78,12 @@
(ptk/reify ::handle-drawing
ptk/WatchEvent
(watch [_ state stream]
(let [stoper (rx/merge
(->> stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(->> stream
(rx/filter #(= % :interrupt))))
(let [stopper (rx/merge
(->> stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(->> stream
(rx/filter #(= % :interrupt))))
layout (get state :workspace-layout)
zoom (dm/get-in state [:workspace-local :zoom] 1)
@ -131,7 +131,7 @@
(rx/filter #(> (gpt/distance % initial) (/ 2 zoom)))
;; Take until before the snap calculation otherwise we could cancel the snap in the worker
;; and its a problem for fast moving drawing
(rx/take-until stoper)
(rx/take-until stopper)
(rx/with-latest-from ms/mouse-position-shift ms/mouse-position-mod)
(rx/switch-map
(fn [[point :as current]]

View file

@ -28,7 +28,7 @@
(def simplify-tolerance 0.3)
(defn stoper-event?
(defn stopper-event?
[{:keys [type] :as event}]
(and (mse/mouse-event? event)
(= type :up)))
@ -104,7 +104,7 @@
(ptk/reify ::handle-drawing
ptk/WatchEvent
(watch [_ _ stream]
(let [stoper (rx/filter stoper-event? stream)
(let [stopper (rx/filter stopper-event? stream)
mouse (rx/sample 10 ms/mouse-position)
shape (cts/setup-shape {:type :path
:initialized? true
@ -115,7 +115,7 @@
(rx/of #(update % :workspace-drawing assoc :object shape))
(->> mouse
(rx/map insert-point)
(rx/take-until stoper))
(rx/take-until stopper))
(rx/of
(setup-frame)
(finish-drawing)

View file

@ -38,7 +38,7 @@
(ptk/reify ::initialize
ptk/WatchEvent
(watch [_ state stream]
(let [stoper (rx/filter (ptk/type? ::finalize) stream)
(let [stopper (rx/filter (ptk/type? ::finalize) stream)
profile-id (:profile-id state)
initmsg [{:type :subscribe-file
@ -87,7 +87,7 @@
(rx/pipe (rxs/throttle 100))
(rx/map #(handle-pointer-send file-id (:pt %)))))
(rx/take-until stoper))]
(rx/take-until stopper))]
(rx/concat stream (rx/of (dws/send endmsg)))))))

View file

@ -120,12 +120,12 @@
ptk/WatchEvent
(watch [_ state stream]
(let [zoom (get-in state [:workspace-local :zoom] 1)
stoper (rx/merge
(->> stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(->> stream
(rx/filter dwc/interrupt?)))
stopper (rx/merge
(->> stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(->> stream
(rx/filter dwc/interrupt?)))
from-p @ms/mouse-position]
(rx/concat
@ -133,7 +133,7 @@
(rx/map #(grc/points->rect [from-p %]))
(rx/filter (partial valid-rect? zoom))
(rx/map update-area-selection)
(rx/take-until stoper))
(rx/take-until stopper))
(rx/of (select-node-area shift?)
(clear-area-selection))))))))

View file

@ -52,19 +52,19 @@
start (-> @ms/mouse-position to-pixel-snap)
stoper (rx/merge
(->> st/stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(->> st/stream
(rx/filter finish-edition?)))
stopper (rx/merge
(->> st/stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(->> st/stream
(rx/filter finish-edition?)))
position-stream
(->> ms/mouse-position
(rx/map to-pixel-snap)
(rx/filter (dragging? start zoom))
(rx/take 1)
(rx/take-until stoper))]
(rx/take-until stopper))]
(rx/merge
(->> position-stream

View file

@ -37,7 +37,7 @@
ptk/WatchEvent
(watch [_ _ stream]
(log/debug :hint "initialize persistence")
(let [stoper (rx/filter (ptk/type? ::initialize-persistence) stream)
(let [stopper (rx/filter (ptk/type? ::initialize-persistence) stream)
commits (l/atom [])
saving? (l/atom false)
@ -53,7 +53,7 @@
on-dirty
(fn []
;; Enable reload stoper
;; Enable reload stopper
(swap! st/ongoing-tasks conj :workspace-change)
(st/emit! (update-persistence-status {:status :pending})))
@ -64,7 +64,7 @@
on-saved
(fn []
;; Disable reload stoper
;; Disable reload stopper
(swap! st/ongoing-tasks disj :workspace-change)
(st/emit! (update-persistence-status {:status :saved}))
(reset! saving? false))]
@ -82,7 +82,7 @@
(assoc :file-id file-id))))
(rx/observe-on :async)
(rx/tap #(swap! commits conj %))
(rx/take-until (rx/delay 100 stoper))
(rx/take-until (rx/delay 100 stopper))
(rx/finalize (fn []
(log/debug :hint "finalize persistence: changes watcher"))))
@ -115,7 +115,7 @@
(rx/tap on-saved)
(rx/ignore)))
(rx/empty))))
(rx/take-until (rx/delay 100 stoper))
(rx/take-until (rx/delay 100 stopper))
(rx/finalize (fn []
(log/debug :hint "finalize persistence: save loop"))))
@ -126,7 +126,7 @@
(rx/filter library-file?)
(rx/filter (complement #(empty? (:changes %))))
(rx/map persist-synchronous-changes)
(rx/take-until (rx/delay 100 stoper))
(rx/take-until (rx/delay 100 stopper))
(rx/finalize (fn []
(log/debug :hint "finalize persistence: synchronous save loop")))))))))

View file

@ -64,12 +64,12 @@
ptk/WatchEvent
(watch [_ state stream]
(let [zoom (dm/get-in state [:workspace-local :zoom] 1)
stoper (rx/merge
(->> stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(->> stream
(rx/filter interrupt?)))
stopper (rx/merge
(->> stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(->> stream
(rx/filter interrupt?)))
init-position @ms/mouse-position
@ -99,7 +99,7 @@
(rx/scan calculate-selrect init-selrect)
(rx/filter #(or (> (dm/get-prop % :width) (/ 10 zoom))
(> (dm/get-prop % :height) (/ 10 zoom))))
(rx/take-until stoper))]
(rx/take-until stopper))]
(rx/concat
(if preserve?
@ -667,9 +667,9 @@
ptk/WatchEvent
(watch [_ _ stream]
(let [stoper (rx/filter (ptk/type? ::memorize-duplicated) stream)]
(let [stopper (rx/filter (ptk/type? ::memorize-duplicated) stream)]
(->> (rx/timer 10000) ;; This time may be adjusted after some user testing.
(rx/take-until stoper)
(rx/take-until stopper)
(rx/map clear-memorize-duplicated))))))
(defn calc-duplicate-delta

View file

@ -370,9 +370,9 @@
ptk/WatchEvent
(watch [_ _ stream]
(let [stoper (->> stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
(let [stopper (->> stream
(rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))
group (gsh/shapes->rect shapes)
group-center (grc/rect->center group)
@ -399,7 +399,7 @@
(fn [[pos mod? shift?]]
(let [delta-angle (calculate-angle pos mod? shift?)]
(dwm/set-rotation-modifiers delta-angle shapes group-center))))
(rx/take-until stoper))
(rx/take-until stopper))
(rx/of (dwm/apply-modifiers)
(finish-transform)))))))

View file

@ -149,7 +149,7 @@
ptk/EffectEvent
(effect [_ state stream]
(let [stoper (rx/filter (ptk/type? ::initialize-history) stream)
(let [stopper (rx/filter (ptk/type? ::initialize-history) stream)
history (:history state)
router (:router state)]
(ts/schedule #(on-change router (.getToken ^js history)))
@ -158,5 +158,5 @@
(fn []
(bhistory/disable! history)
(e/unlistenByKey key)))))
(rx/take-until stoper)
(rx/take-until stopper)
(rx/subs! #(on-change router %)))))))