Skip to content

Commit

Permalink
feat(feature): add switch to toggle timetracking
Browse files Browse the repository at this point in the history
Closed #548
  • Loading branch information
tiensonqin committed Oct 29, 2020
1 parent f5c775d commit 71272b2
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
5 changes: 5 additions & 0 deletions resources/static/css/common.css
Expand Up @@ -1297,3 +1297,8 @@ a.tag:hover {
.absolute-modal {
background: var(--ls-primary-background-color);
}

/* FIXME: not sure why this is not working for ui/toggle */
.translate-x-5 {
--transform-translate-x: 1.25rem;
}
13 changes: 13 additions & 0 deletions src/main/frontend/components/settings.cljs
Expand Up @@ -4,6 +4,7 @@
[frontend.handler.notification :as notification]
[frontend.handler.user :as user-handler]
[frontend.handler.ui :as ui-handler]
[frontend.handler.repo :as repo-handler]
[frontend.state :as state]
[frontend.util :as util]
[frontend.config :as config]
Expand Down Expand Up @@ -65,6 +66,7 @@
(let [preferred-format (keyword (state/sub [:me :preferred_format]))
preferred-workflow (keyword (state/sub [:me :preferred_workflow]))
preferred-language (state/sub [:preferred-language])
enable-timetracking? (state/enable-timetracking?)
github-token (state/sub [:me :access-token])
cors-proxy (state/sub [:me :cors_proxy])
logged? (state/logged?)
Expand Down Expand Up @@ -146,6 +148,17 @@
"NOW/LATER"
"TODO/DOING")])]]]]

[:div.mt-6.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-start.sm:pt-5
[:label.block.text-sm.font-medium.leading-5.opacity-70
{:for "enable_timetracking"}
(t :settings-page/enable-timetracking)]
[:div.mt-1.sm:mt-0.sm:col-span-2
[:div.max-w-lg.rounded-md.shadow-sm.sm:max-w-xs
(ui/toggle enable-timetracking?
(fn []
(let [value (not enable-timetracking?)]
(repo-handler/set-config! :feature/enable-timetracking? value))))]]]

[:hr]

(ui/admonition
Expand Down
2 changes: 2 additions & 0 deletions src/main/frontend/dicts.cljs
Expand Up @@ -277,6 +277,7 @@ title: How to take dummy notes?
:settings-page/edit-config-edn "Edit config.edn (for current repo)"
:settings-page/preferred-file-format "Preferred file format"
:settings-page/preferred-workflow "Preferred workflow"
:settings-page/enable-timetracking "Enable timetracking"
:settings-page/dont-use-other-peoples-proxy-servers "Don't use other people's proxy servers. It's very dangerous, which could make your token and notes stolen. Logseq will not be responsible for this loss if you use other people's proxy servers. You can deploy it yourself, check "
:settings-page/custom-cors-proxy-server "Custom CORS proxy server"
:settings-page/developer-mode "Developer mode"
Expand Down Expand Up @@ -522,6 +523,7 @@ title: How to take dummy notes?
:settings-page/edit-config-edn "编辑 config.edn (当前库)"
:settings-page/preferred-file-format "首选文件格式"
:settings-page/preferred-workflow "首选工作流"
:settings-page/enable-timetracking "开启 timetracking"
:settings-page/dont-use-other-peoples-proxy-servers "不要使用其他人的代理服务器。这非常危险,可能会使您的令牌和笔记被盗。 如果您使用其他人的代理服务器,Logseq 将不会对此损失负责。您可以自己部署它,请查阅 "
:settings-page/custom-cors-proxy-server "自定义 CORS 代理服务器"
:settings-page/developer-mode "开发者模式"
Expand Down
14 changes: 9 additions & 5 deletions src/main/frontend/handler/editor.cljs
Expand Up @@ -792,10 +792,13 @@

(defn- with-marker-time
[block marker]
(let [properties (:block/properties block)]
(assoc (into {} properties)
(string/lower-case marker)
(util/time-ms))))
(let [properties (:block/properties block)
properties (into {} properties)]
(if (state/enable-timetracking?)
(assoc properties
(string/lower-case marker)
(util/time-ms))
properties)))

(defn check
[{:block/keys [uuid marker content meta file dummy? repeated?] :as block}]
Expand Down Expand Up @@ -1282,7 +1285,8 @@
properties (into {} (:block/properties block))
properties (if (and
new-marker
(not= new-marker (:block/marker block)))
(not= new-marker (:block/marker block))
(state/enable-timetracking?))
(assoc properties new-marker (util/time-ms))
properties)]
(let [cache [(:block/uuid block) value]]
Expand Down
1 change: 0 additions & 1 deletion src/main/frontend/handler/repo.cljs
Expand Up @@ -405,7 +405,6 @@
(db/cloned? repo-url)
(not (state/get-edit-input-id)))
(-> (p/let [files (js/window.workerThread.getChangedFiles (util/get-repo-dir (state/get-current-repo)))]
(prn {:changed-files files})
(when (or
;; FIXME:
force?
Expand Down
3 changes: 2 additions & 1 deletion src/main/frontend/publishing/html.cljs
@@ -1,7 +1,8 @@
(ns frontend.publishing.html
(:require-macros [hiccups.core])
(:require [frontend.config :as config]
[frontend.state :as state]))
[frontend.state :as state]
[hiccups.runtime]))

(defn publishing-html
[transit-db app-state]
Expand Down
12 changes: 11 additions & 1 deletion src/main/frontend/state.cljs
Expand Up @@ -140,6 +140,10 @@
([repo-url]
(get-in @state [:config repo-url])))

(defn sub-config
[]
(sub :config))

(defn get-custom-css-link
[]
(:custom-css-url (get-config)))
Expand All @@ -150,7 +154,13 @@

(defn enable-grammarly?
[]
(true? (:enable-grammarly? (get-config))))
(true? (:feature/enable-grammarly?
(get (sub-config) (get-current-repo)))))

(defn enable-timetracking?
[]
(not (false? (:feature/enable-timetracking?
(get (sub-config) (get-current-repo))))))

(defn get-default-home
[]
Expand Down

0 comments on commit 71272b2

Please sign in to comment.