diff --git a/backend/src/app/rpc/queries/teams.clj b/backend/src/app/rpc/queries/teams.clj index b1a931199..7840dfa71 100644 --- a/backend/src/app/rpc/queries/teams.clj +++ b/backend/src/app/rpc/queries/teams.clj @@ -158,18 +158,18 @@ ;; implemented in UI) (def sql:team-users - "select pf.id, pf.fullname, pf.photo + "select pf.id, pf.fullname, pf.photo_id from profile as pf inner join team_profile_rel as tpr on (tpr.profile_id = pf.id) where tpr.team_id = ? union - select pf.id, pf.fullname, pf.photo + select pf.id, pf.fullname, pf.photo_id from profile as pf inner join project_profile_rel as ppr on (ppr.profile_id = pf.id) inner join project as p on (ppr.project_id = p.id) where p.team_id = ? union - select pf.id, pf.fullname, pf.photo + select pf.id, pf.fullname, pf.photo_id from profile as pf inner join file_profile_rel as fpr on (fpr.profile_id = pf.id) inner join file as f on (fpr.file_id = f.id) diff --git a/frontend/src/app/main/data/workspace/notifications.cljs b/frontend/src/app/main/data/workspace/notifications.cljs index a4de61fcd..7a1c2622a 100644 --- a/frontend/src/app/main/data/workspace/notifications.cljs +++ b/frontend/src/app/main/data/workspace/notifications.cljs @@ -58,13 +58,19 @@ stoper (rx/filter #(= ::finalize %) stream) interval (* 1000 60)] (->> (rx/merge + ;; Each 60 seconds send a keepalive message for maintain + ;; this socket open. (->> (rx/timer interval interval) (rx/map #(send-keepalive file-id))) + + ;; Process all incoming messages. (->> (ws/-stream wsession) (rx/filter ws/message?) (rx/map (comp t/decode :payload)) (rx/filter #(s/valid? ::message %)) (rx/map process-message)) + + ;; Send back to backend all pointer messages. (->> stream (rx/filter ms/pointer-event?) (rx/sample 50) @@ -130,7 +136,7 @@ }) (defn handle-presence - [{:keys [sessions] :as msg}] + [{:keys [sessions] :as message}] (letfn [(assign-color [sessions session] (if (string? (:color session)) session @@ -152,12 +158,12 @@ (assoc sessions id session))) (update-sessions [previous profiles] - (let [previous (select-keys previous (map first sessions)) ; Initial clearing - pending (->> sessions - (filter #(not (contains? previous (first %)))) - (map (fn [[session-id profile-id]] - {:id session-id - :profile (get profiles profile-id)})))] + (let [previous (select-keys previous (map first sessions)) ; Initial clearing + pending (->> sessions + (filter #(not (contains? previous (first %)))) + (map (fn [[session-id profile-id]] + {:id session-id + :profile (get profiles profile-id)})))] (reduce assign-session previous pending)))] (ptk/reify ::handle-presence