From 061fdcd5bd6c61957d5ef921dc362af0670db210 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Nov 2020 15:06:49 +0100 Subject: [PATCH] :bug: Fix many issues relted to comments on viewer. --- backend/src/app/services/queries/viewer.clj | 2 +- .../styles/main/partials/comments.scss | 1 + frontend/src/app/main/data/viewer.cljs | 47 +++++++++++-------- frontend/src/app/main/ui/comments.cljs | 2 +- frontend/src/app/main/ui/viewer.cljs | 8 ++-- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/backend/src/app/services/queries/viewer.clj b/backend/src/app/services/queries/viewer.clj index 38cd87221..27d52a88a 100644 --- a/backend/src/app/services/queries/viewer.clj +++ b/backend/src/app/services/queries/viewer.clj @@ -24,7 +24,7 @@ (def ^:private sql:project - "select p.id, p.name + "select p.id, p.name, p.team_id from project as p where p.id = ? and p.deleted_at is null") diff --git a/frontend/resources/styles/main/partials/comments.scss b/frontend/resources/styles/main/partials/comments.scss index b15588d89..59e46351d 100644 --- a/frontend/resources/styles/main/partials/comments.scss +++ b/frontend/resources/styles/main/partials/comments.scss @@ -45,6 +45,7 @@ .comments { max-height: 320px; + min-height: 105px; overflow-y: auto; } diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index 3aa7058f5..635c15569 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -9,19 +9,21 @@ (ns app.main.data.viewer (:require - [cljs.spec.alpha :as s] - [beicon.core :as rx] - [potok.core :as ptk] + [app.common.data :as d] + [app.common.exceptions :as ex] + [app.common.pages :as cp] + [app.common.pages-helpers :as cph] + [app.common.spec :as us] + [app.common.uuid :as uuid] [app.main.constants :as c] [app.main.repo :as rp] [app.main.store :as st] - [app.common.spec :as us] - [app.common.pages :as cp] - [app.common.data :as d] - [app.common.exceptions :as ex] + [app.main.data.comments :as dcm] + [app.util.avatars :as avatars] [app.util.router :as rt] - [app.common.uuid :as uuid] - [app.common.pages-helpers :as cph])) + [beicon.core :as rx] + [cljs.spec.alpha :as s] + [potok.core :as ptk])) ;; --- General Specs @@ -149,7 +151,8 @@ ptk/UpdateEvent (update [_ state] (let [objects (:objects page) - frames (extract-frames objects)] + frames (extract-frames objects) + users (map #(avatars/assoc-avatar % :fullname) users)] (-> state (assoc :viewer-libraries (d/index-by :id libraries) :viewer-data {:project project @@ -240,7 +243,9 @@ pparams (:path-params route) index (:index qparams)] (when (pos? index) - (rx/of (rt/nav screen pparams (assoc qparams :index (dec index))))))))) + (rx/of + (dcm/close-thread) + (rt/nav screen pparams (assoc qparams :index (dec index))))))))) (def select-next-frame (ptk/reify ::select-prev-frame @@ -253,7 +258,9 @@ index (:index qparams) total (count (get-in state [:viewer-data :frames]))] (when (< index (dec total)) - (rx/of (rt/nav screen pparams (assoc qparams :index (inc index))))))))) + (rx/of + (dcm/close-thread) + (rt/nav screen pparams (assoc qparams :index (inc index))))))))) (s/def ::interactions-mode #{:hide :show :show-on-click}) @@ -387,12 +394,12 @@ ;; --- Shortcuts (def shortcuts - {"+" #(st/emit! increase-zoom) - "-" #(st/emit! decrease-zoom) - "ctrl+a" #(st/emit! (select-all)) - "shift+0" #(st/emit! zoom-to-50) - "shift+1" #(st/emit! reset-zoom) - "shift+2" #(st/emit! zoom-to-200) - "left" #(st/emit! select-prev-frame) - "right" #(st/emit! select-next-frame)}) + {"+" (st/emitf increase-zoom) + "-" (st/emitf decrease-zoom) + "ctrl+a" (st/emitf (select-all)) + "shift+0" (st/emitf zoom-to-50) + "shift+1" (st/emitf reset-zoom) + "shift+2" (st/emitf zoom-to-200) + "left" (st/emitf select-prev-frame) + "right" (st/emitf select-next-frame)}) diff --git a/frontend/src/app/main/ui/comments.cljs b/frontend/src/app/main/ui/comments.cljs index b09fe8f92..a16dec9e7 100644 --- a/frontend/src/app/main/ui/comments.cljs +++ b/frontend/src/app/main/ui/comments.cljs @@ -185,7 +185,7 @@ (mf/defc comment-item [{:keys [comment thread users] :as props}] (let [owner (get users (:owner-id comment)) - profile (mf/use-state refs/profile) + profile (mf/deref refs/profile) options (mf/use-state false) edition? (mf/use-state false) diff --git a/frontend/src/app/main/ui/viewer.cljs b/frontend/src/app/main/ui/viewer.cljs index 73017aaeb..74fc8f162 100644 --- a/frontend/src/app/main/ui/viewer.cljs +++ b/frontend/src/app/main/ui/viewer.cljs @@ -78,7 +78,7 @@ on-click (mf/use-callback - (mf/deps cstate data) + (mf/deps cstate data frame) (fn [event] (dom/stop-propagation event) (if (some? (:open cstate)) @@ -98,13 +98,11 @@ on-draft-submit (mf/use-callback + (mf/deps frame) (fn [draft] (let [params (update draft :position gpt/transform modifier2)] - ;; (prn "on-draft-submit" params) - (st/emit! (dcm/create-thread params) - (dcm/close-thread))))) - ] + (dcm/close-thread)))))] [:div.comments-section {:on-click on-click} [:div.viewer-comments-container