mirror of https://github.com/logseq/logseq
enhance(rtc): update create-rtc-recent-updates-flow
inject user-info into recent-updates-flowexperiment/tanstack-table
parent
da4f9b5498
commit
c1126e756a
|
@ -1,7 +1,8 @@
|
||||||
(ns frontend.components.rtc.flows
|
(ns frontend.components.rtc.flows
|
||||||
(:require [frontend.state :as state]
|
(:require [frontend.state :as state]
|
||||||
[missionary.core :as m]
|
[missionary.core :as m]
|
||||||
[cljs-time.core :as t]))
|
[cljs-time.core :as t])
|
||||||
|
(:import [missionary Cancelled]))
|
||||||
|
|
||||||
(def rtc-log-flow
|
(def rtc-log-flow
|
||||||
(m/watch (:rtc/log @state/state)))
|
(m/watch (:rtc/log @state/state)))
|
||||||
|
@ -30,19 +31,27 @@
|
||||||
[minutes]
|
[minutes]
|
||||||
(let [*buffer (atom {})]
|
(let [*buffer (atom {})]
|
||||||
(m/ap
|
(m/ap
|
||||||
(let [latest-updates (m/?> (m/watch (:rtc/recent-updates @state/state)))]
|
(let [{:keys [graph-uuid online-users]} (m/?< (m/watch (:rtc/state @state/state)))
|
||||||
(when-let [graph-uuid (first (keys latest-updates))]
|
user-uuid->user (into {} (map (juxt :user/uuid identity)) online-users)
|
||||||
(let [mins-ago (t/minus (t/now) (t/minutes minutes))
|
graph-uuid (uuid graph-uuid)]
|
||||||
latest-keys (map (fn [[user-uuid _]] user-uuid) (get latest-updates graph-uuid))
|
(try
|
||||||
new-map
|
(let [latest-updates (m/?< (m/watch (:rtc/recent-updates @state/state)))]
|
||||||
{graph-uuid
|
(when-let [graph-uuid* (first (keys latest-updates))]
|
||||||
(into {}
|
(when (= graph-uuid graph-uuid*)
|
||||||
(map (fn [k]
|
(let [mins-ago (t/minus (t/now) (t/minutes minutes))
|
||||||
[k
|
latest-keys (map (fn [[user-uuid _]] user-uuid) (get latest-updates graph-uuid))
|
||||||
(take-while
|
new-map
|
||||||
(fn [[inst _]] (> inst mins-ago))
|
{graph-uuid
|
||||||
(concat (get-in latest-updates [graph-uuid k])
|
(into {}
|
||||||
(get-in @*buffer [graph-uuid k])))]))
|
(map (fn [user-uuid]
|
||||||
latest-keys)}]
|
[user-uuid
|
||||||
(swap! *buffer merge new-map)
|
{:user-info (user-uuid->user user-uuid)
|
||||||
@*buffer))))))
|
:updates
|
||||||
|
(take-while
|
||||||
|
(fn [[inst _]] (> inst mins-ago))
|
||||||
|
(concat (get-in latest-updates [graph-uuid user-uuid])
|
||||||
|
(get-in @*buffer [graph-uuid user-uuid])))}]))
|
||||||
|
latest-keys)}]
|
||||||
|
(swap! *buffer merge new-map)
|
||||||
|
@*buffer))))
|
||||||
|
(catch Cancelled _))))))
|
||||||
|
|
Loading…
Reference in New Issue