Skip to content

Commit

Permalink
💄 Format frontend code
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz authored and Alotor committed Jan 8, 2024
1 parent b6ecc8b commit 833871d
Show file tree
Hide file tree
Showing 150 changed files with 1,836 additions and 1,871 deletions.
1 change: 1 addition & 0 deletions .cljfmt.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
:remove-surrounding-whitespace? true
:remove-consecutive-blank-lines? false
:extra-indents {rumext.v2/fnc [[:inner 0]]
cljs.test/async [[:inner 0]]
promesa.exec/thread [[:inner 0]]
specify! [[:inner 0] [:inner 1]]}
}
6 changes: 3 additions & 3 deletions frontend/src/app/libs/file_builder.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@
(rx/reduce conj [])
(rx/with-latest-from files-stream)
(rx/merge-map (fn [[data _]]
(->> (uz/compress-files data)
(rx/map #(vector file %)))))))))
(->> (uz/compress-files data)
(rx/map #(vector file %)))))))))

(deftype File [^:mutable file]
Object
Expand Down Expand Up @@ -263,4 +263,4 @@
(File. (fb/create-file name)))

(defn exports []
#js { :createFile create-file-export })
#js {:createFile create-file-export})
2 changes: 1 addition & 1 deletion frontend/src/app/libs/render.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(fn [resolve reject]
(->> (r/render-page data)
(rx/take 1)
(rx/subs! resolve reject))) )))
(rx/subs! resolve reject))))))

(defn exports []
#js {:renderPage render-page-export})
86 changes: 43 additions & 43 deletions frontend/src/app/main/data/comments.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@

ptk/WatchEvent
(watch [_ state _]
(let [share-id (-> state :viewer-local :share-id)]
(->> (rp/cmd! :update-comment-thread {:id id :is-resolved is-resolved :share-id share-id})
(rx/catch (fn [{:keys [type code] :as cause}]
(if (and (= type :restriction)
(= code :max-quote-reached))
(rx/throw cause)
(rx/throw {:type :comment-error}))))
(rx/ignore))))))
(let [share-id (-> state :viewer-local :share-id)]
(->> (rp/cmd! :update-comment-thread {:id id :is-resolved is-resolved :share-id share-id})
(rx/catch (fn [{:keys [type code] :as cause}]
(if (and (= type :restriction)
(= code :max-quote-reached))
(rx/throw cause)
(rx/throw {:type :comment-error}))))
(rx/ignore))))))

(defn add-comment
[thread content]
Expand All @@ -196,16 +196,16 @@
(ptk/reify ::create-comment
ptk/WatchEvent
(watch [_ state _]
(let [share-id (-> state :viewer-local :share-id)]
(rx/concat
(->> (rp/cmd! :create-comment {:thread-id (:id thread) :content content :share-id share-id})
(rx/map #(partial created %))
(rx/catch (fn [{:keys [type code] :as cause}]
(if (and (= type :restriction)
(= code :max-quote-reached))
(rx/throw cause)
(rx/throw {:type :comment-error})))))
(rx/of (refresh-comment-thread thread))))))))
(let [share-id (-> state :viewer-local :share-id)]
(rx/concat
(->> (rp/cmd! :create-comment {:thread-id (:id thread) :content content :share-id share-id})
(rx/map #(partial created %))
(rx/catch (fn [{:keys [type code] :as cause}]
(if (and (= type :restriction)
(= code :max-quote-reached))
(rx/throw cause)
(rx/throw {:type :comment-error})))))
(rx/of (refresh-comment-thread thread))))))))

(defn update-comment
[{:keys [id content thread-id] :as comment}]
Expand Down Expand Up @@ -309,14 +309,14 @@
(->
(assoc-in (conj path :position) (:position comment-thread))
(assoc-in (conj path :frame-id) (:frame-id comment-thread))))))
(fetched [[users comments] state]
(let [pages (-> (get-in state [:workspace-data :pages])
set)
comments (filter #(contains? pages (:page-id %)) comments)
state (-> state
(assoc :comment-threads (d/index-by :id comments))
(update :current-file-comments-users merge (d/index-by :id users)))]
(reduce set-comment-threds state comments)))]
(fetched [[users comments] state]
(let [pages (-> (get-in state [:workspace-data :pages])
set)
comments (filter #(contains? pages (:page-id %)) comments)
state (-> state
(assoc :comment-threads (d/index-by :id comments))
(update :current-file-comments-users merge (d/index-by :id users)))]
(reduce set-comment-threds state comments)))]

(ptk/reify ::retrieve-comment-threads
ptk/WatchEvent
Expand Down Expand Up @@ -491,23 +491,23 @@
([thread]
(update-comment-thread-frame thread uuid/zero))

([thread frame-id]
(dm/assert!
"expected valid comment thread"
(check-comment-thread! thread))

(ptk/reify ::update-comment-thread-frame
ptk/UpdateEvent
(update [_ state]
(let [thread-id (:id thread)]
(assoc-in state [:comment-threads thread-id :frame-id] frame-id)))

ptk/WatchEvent
(watch [_ _ _]
(let [thread-id (:id thread)]
(->> (rp/cmd! :update-comment-thread-frame {:id thread-id :frame-id frame-id})
(rx/catch #(rx/throw {:type :comment-error :code :update-comment-thread-frame}))
(rx/ignore)))))))
([thread frame-id]
(dm/assert!
"expected valid comment thread"
(check-comment-thread! thread))

(ptk/reify ::update-comment-thread-frame
ptk/UpdateEvent
(update [_ state]
(let [thread-id (:id thread)]
(assoc-in state [:comment-threads thread-id :frame-id] frame-id)))

ptk/WatchEvent
(watch [_ _ _]
(let [thread-id (:id thread)]
(->> (rp/cmd! :update-comment-thread-frame {:id thread-id :frame-id frame-id})
(rx/catch #(rx/throw {:type :comment-error :code :update-comment-thread-frame}))
(rx/ignore)))))))

(defn detach-comment-thread
"Detach comment threads that are inside a frame when that frame is deleted"
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/app/main/data/dashboard.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@
(ptk/reify ::fetch-builtin-templates
ptk/WatchEvent
(watch [_ _ _]
(->> (rp/cmd! :get-builtin-templates)
(rx/map builtin-templates-fetched)))))
(->> (rp/cmd! :get-builtin-templates)
(rx/map builtin-templates-fetched)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data Selection
Expand All @@ -320,7 +320,7 @@
(update [_ state]
(update state :dashboard-local
assoc :selected-files #{}
:selected-project nil))))
:selected-project nil))))

(defn toggle-file-select
[{:keys [id project-id] :as file}]
Expand Down Expand Up @@ -377,10 +377,10 @@
:or {on-success identity
on-error rx/throw}} (meta params)
features (features/get-enabled-features state)]
params {:name name
:emails #{emails}
:role role
:features features}
params {:name name
:emails #{emails}
:role role
:features features}
(->> (rp/cmd! :create-team-with-invitations params)
(rx/tap on-success)
(rx/map team-created)
Expand Down Expand Up @@ -817,7 +817,7 @@
(d/update-in-when [:dashboard-files id :is-shared] (constantly is-shared))
(d/update-in-when [:dashboard-recent-files id :is-shared] (constantly is-shared))
(cond->
(not is-shared)
(not is-shared)
(d/update-when :dashboard-shared-files dissoc id))))

ptk/WatchEvent
Expand Down Expand Up @@ -1010,9 +1010,9 @@
(let [team-id (:current-team-id state)]
(if (empty? term)
(do
(dom/focus! (dom/get-element "search-input"))
(rx/of (rt/nav :dashboard-search
{:team-id team-id})))
(dom/focus! (dom/get-element "search-input"))
(rx/of (rt/nav :dashboard-search
{:team-id team-id})))
(rx/of (rt/nav :dashboard-search
{:team-id team-id}
{:search-term term})))))
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/app/main/data/messages.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@
ptk/WatchEvent
(watch [_ _ stream]
(rx/merge
(let [stoper (rx/filter (ptk/type? ::hide) stream)]
(->> stream
(rx/filter (ptk/type? :app.util.router/navigate))
(rx/map (constantly hide))
(rx/take-until stoper)))
(when (:timeout data)
(let [stoper (rx/filter (ptk/type? ::show) stream)]
(->> (rx/of hide)
(rx/delay (:timeout data))
(rx/take-until stoper))))))))
(let [stoper (rx/filter (ptk/type? ::hide) stream)]
(->> stream
(rx/filter (ptk/type? :app.util.router/navigate))
(rx/map (constantly hide))
(rx/take-until stoper)))
(when (:timeout data)
(let [stoper (rx/filter (ptk/type? ::show) stream)]
(->> (rx/of hide)
(rx/delay (:timeout data))
(rx/take-until stoper))))))))

(def hide
(ptk/reify ::hide
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/main/data/users.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
(when profile
(swap! storage assoc :profile profile)
(i18n/set-locale! (:lang profile))
(when (not= previous-email email)
(swap! storage dissoc ::current-team-id)))))))
(when (not= previous-email email)
(swap! storage dissoc ::current-team-id)))))))

(defn fetch-profile
[]
Expand Down
28 changes: 14 additions & 14 deletions frontend/src/app/main/data/viewer.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
(-> state
(assoc :current-file-id file-id)
(update :viewer-local
(fn [lstate]
(if (nil? lstate)
default-local-state
lstate)))
(fn [lstate]
(if (nil? lstate)
default-local-state
lstate)))
(assoc-in [:viewer-local :share-id] share-id)
(assoc-in [:viewer-local :interactions-show?] interactions-show?)))

Expand Down Expand Up @@ -202,10 +202,10 @@
"fill" zoom-to-fill
nil))
(rx/of
(cond
(some? frame-id) (go-to-frame (uuid frame-id))
(some? index) (go-to-frame-by-index index)
:else (go-to-frame-auto)))))))))
(cond
(some? frame-id) (go-to-frame (uuid frame-id))
(some? index) (go-to-frame-by-index index)
:else (go-to-frame-auto)))))))))

(defn fetch-comment-threads
[{:keys [file-id page-id share-id] :as params}]
Expand Down Expand Up @@ -297,9 +297,9 @@
ptk/UpdateEvent
(update [_ state]
(let [srect (as-> (get-in state [:route :query-params :page-id]) %
(get-in state [:viewer :pages % :frames])
(nth % (get-in state [:route :query-params :index]))
(get % :selrect))
(get-in state [:viewer :pages % :frames])
(nth % (get-in state [:route :query-params :index]))
(get % :selrect))
orig-size (get-in state [:viewer-local :viewport-size])
wdiff (/ (:width orig-size) (:width srect))
hdiff (/ (:height orig-size) (:height srect))
Expand Down Expand Up @@ -514,9 +514,9 @@

(some? animation)
(assoc-in [:viewer-animations (:id frame)]
{:kind :go-to-frame
:orig-frame-id (:id frame)
:animation animation}))))
{:kind :go-to-frame
:orig-frame-id (:id frame)
:animation animation}))))

ptk/WatchEvent
(watch [_ state _]
Expand Down
Loading

0 comments on commit 833871d

Please sign in to comment.