mirror of https://github.com/logseq/logseq
Move time-ms to common.util
parent
a6f83c2445
commit
b5d8d569ce
|
@ -1,4 +1,6 @@
|
|||
{:paths ["src" "resources"]
|
||||
:deps {com.andrewmcveigh/cljs-time {:git/url "https://github.com/logseq/cljs-time" ;; fork
|
||||
:sha "5704fbf48d3478eedcf24d458c8964b3c2fd59a9"}}
|
||||
:aliases
|
||||
{:test {:extra-paths ["test"]
|
||||
:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{:paths ["src" "resources"]
|
||||
:deps
|
||||
{io.github.nextjournal/nbb-test-runner
|
||||
{com.andrewmcveigh/cljs-time
|
||||
{:git/url "https://github.com/logseq/cljs-time" ;; fork
|
||||
:sha "5704fbf48d3478eedcf24d458c8964b3c2fd59a9"}
|
||||
io.github.nextjournal/nbb-test-runner
|
||||
{:git/sha "60ed57aa04bca8d604f5ba6b28848bd887109347"}}}
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
[clojure.string :as string]
|
||||
[clojure.walk :as walk]
|
||||
[logseq.common.log :as log]
|
||||
[goog.string :as gstring]))
|
||||
[goog.string :as gstring]
|
||||
[cljs-time.coerce :as tc]
|
||||
[cljs-time.core :as t]))
|
||||
|
||||
(defn safe-decode-uri-component
|
||||
[uri]
|
||||
|
@ -329,3 +331,7 @@
|
|||
[& cols]
|
||||
(->> (apply concat cols)
|
||||
(remove nil?)))
|
||||
|
||||
(defn time-ms
|
||||
[]
|
||||
(tc/to-long (t/now)))
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
(defn- block-with-timestamps
|
||||
[block]
|
||||
(let [updated-at (util/time-ms)
|
||||
(let [updated-at (common-util/time-ms)
|
||||
block (cond->
|
||||
(assoc block :block/updated-at updated-at)
|
||||
(nil? (:block/created-at block))
|
||||
|
@ -67,7 +67,7 @@
|
|||
|
||||
(defn block-with-updated-at
|
||||
[block]
|
||||
(let [updated-at (util/time-ms)]
|
||||
(let [updated-at (common-util/time-ms)]
|
||||
(assoc block :block/updated-at updated-at)))
|
||||
|
||||
(defn- remove-orphaned-page-refs!
|
||||
|
@ -97,9 +97,9 @@
|
|||
[txs-state block-entity m]
|
||||
(when-let [e (:block/page block-entity)]
|
||||
(let [m' (cond-> {:db/id (:db/id e)
|
||||
:block/updated-at (util/time-ms)}
|
||||
:block/updated-at (common-util/time-ms)}
|
||||
(not (:block/created-at e))
|
||||
(assoc :block/created-at (util/time-ms)))
|
||||
(assoc :block/created-at (common-util/time-ms)))
|
||||
txs (if (or (:block/pre-block? block-entity)
|
||||
(:block/pre-block? m))
|
||||
(let [properties (:block/properties m)
|
||||
|
|
|
@ -855,7 +855,7 @@
|
|||
@ref)))
|
||||
|
||||
#?(:cljs
|
||||
(def time-ms worker-util/time-ms))
|
||||
(def time-ms common-util/time-ms))
|
||||
|
||||
(defn d
|
||||
[k f]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns frontend.worker.state
|
||||
"State hub for worker"
|
||||
(:require [frontend.worker.util :as worker-util]))
|
||||
(:require [logseq.common.util :as common-util]))
|
||||
|
||||
(defonce *state (atom {:db/latest-transact-time {}
|
||||
:worker/context {}}))
|
||||
|
@ -36,12 +36,12 @@
|
|||
(or
|
||||
(nil? last-input-time)
|
||||
|
||||
(let [now (worker-util/time-ms)]
|
||||
(let [now (common-util/time-ms)]
|
||||
(>= (- now last-input-time) diff))))))
|
||||
|
||||
(defn set-db-latest-tx-time!
|
||||
[repo]
|
||||
(swap! *state assoc-in [:db/latest-transact-time repo] (worker-util/time-ms)))
|
||||
(swap! *state assoc-in [:db/latest-transact-time repo] (common-util/time-ms)))
|
||||
|
||||
(defn get-context
|
||||
[]
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
[logseq.common.util :as common-util]
|
||||
[clojure.core.async :as async]
|
||||
[cljs.core.async.impl.channels :refer [ManyToManyChannel]]
|
||||
[cljs-time.coerce :as tc]
|
||||
[cljs-time.core :as t]
|
||||
[cljs-bean.core :as bean]))
|
||||
|
||||
(defn search-normalize
|
||||
|
@ -77,10 +75,6 @@
|
|||
(async/close! ch))))
|
||||
ch))
|
||||
|
||||
(defn time-ms
|
||||
[]
|
||||
(tc/to-long (t/now)))
|
||||
|
||||
(defn post-message
|
||||
[type data]
|
||||
(.postMessage js/self (bean/->js [type data])))
|
||||
|
|
Loading…
Reference in New Issue