Merge branch 'master' into enhance/mobile-silk

This commit is contained in:
charlie
2025-07-09 08:48:15 +08:00
28 changed files with 126 additions and 245 deletions

View File

@@ -45,9 +45,7 @@ jobs:
with: with:
node-version: ${{ env.NODE_VERSION }} node-version: ${{ env.NODE_VERSION }}
cache: 'yarn' cache: 'yarn'
cache-dependency-path: | cache-dependency-path: yarn.lock
yarn.lock
static/yarn.lock
- name: Set up Java - name: Set up Java
uses: actions/setup-java@v3 uses: actions/setup-java@v3
@@ -181,105 +179,4 @@ jobs:
run: cd deps/db && yarn nbb-logseq script/export_graph.cljs ../../scripts/properties-graph -f properties.edn -T run: cd deps/db && yarn nbb-logseq script/export_graph.cljs ../../scripts/properties-graph -f properties.edn -T
- name: Create graph from the export and diff the two graphs - name: Create graph from the export and diff the two graphs
run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -T run: cd deps/db && yarn nbb-logseq -cp src:../outliner/src:script script/create_graph.cljs ./properties-graph2 properties.edn -iv && yarn nbb-logseq script/diff_graphs.cljs ../../scripts/properties-graph ./properties-graph2 -T
e2e-test:
# TODO: Re-enable when ready to enable tests for file graphs
if: false
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache-dependency-path: |
yarn.lock
static/yarn.lock
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}
- name: Set up Clojure
uses: DeLaGuardo/setup-clojure@10.1
with:
cli: ${{ env.CLOJURE_VERSION }}
- name: Clojure cache
uses: actions/cache@v3
id: clojure-deps
with:
path: |
~/.m2/repository
~/.gitlibs
key: ${{ runner.os }}-clojure-deps-${{ hashFiles('deps.edn') }}
restore-keys: ${{ runner.os }}-clojure-deps-
- name: Fetch Clojure deps
if: steps.clojure-deps.outputs.cache-hit != 'true'
run: clojure -A:cljs -P
- name: Shadow-cljs cache
uses: actions/cache@v3
with:
path: .shadow-cljs
# ensure update cache every time
key: ${{ runner.os }}-shadow-cljs-${{ github.sha }}
# will match most recent upload
restore-keys: |
${{ runner.os }}-shadow-cljs-
- name: Fetch yarn deps
run: yarn install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
# NOTE: require the app to be build in debug mode(compile instead of build).
- name: Prepare E2E test build
run: |
yarn gulp:build && clojure -M:cljs compile app publishing electron
(cd static && yarn install && yarn rebuild:all)
# Exits with 0 if yarn.lock is up to date or 1 if we forgot to update it
- name: Ensure static yarn.lock is up to date
run: git diff --exit-code static/yarn.lock
- name: Install Fluxbox
run: sudo apt-get update && sudo apt-get install -y fluxbox
# Emulate a virtual framebuffer on machines with no display hardware
- name: Run XVFB
run: Xvfb :1 -screen 0 1024x768x24 >/dev/null 2>&1 &
# Start a lightweight window manager to simulate window actions (maximize,restore etc)
- name: Start Fluxbox
run: DISPLAY=:1.0 fluxbox >/dev/null 2>&1 &
- name: Run Playwright test - 1/2
run: DISPLAY=:1.0 npx playwright test --reporter github --shard=1/2
env:
LOGSEQ_CI: true
DEBUG: "pw:api"
RELEASE: true # skip dev only test
- name: Run Playwright test - 2/2
run: DISPLAY=:1.0 npx playwright test --reporter github --shard=2/2
env:
LOGSEQ_CI: true
DEBUG: "pw:api"
RELEASE: true # skip dev only test
- name: Save test artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: e2e-test-report
path: e2e-dump/*
retention-days: 1

2
.gitignore vendored
View File

@@ -1,4 +1,3 @@
/e2e-dump
/target /target
/classes /classes
/checkouts /checkouts
@@ -15,7 +14,6 @@ pom.xml.asc
node_modules/ node_modules/
static/** static/**
!static/yarn.lock
tmp tmp
cljs-test-runner-out cljs-test-runner-out

View File

@@ -52,6 +52,7 @@ This is overview of this repository's most important directories and files.
- `src/main/frontend/worker/` contains code for the separate worker asset. - `src/main/frontend/worker/` contains code for the separate worker asset.
- `src/main/frontend/common/` contains common code shared by the worker asset and the frontend. - `src/main/frontend/common/` contains common code shared by the worker asset and the frontend.
- `src/main/logseq/` contains the api used by plugins. - `src/main/logseq/` contains the api used by plugins.
- `src/main/mobile/` contains code for new mobile app.
- `src/dev-cljs/` contains some development utilities. - `src/dev-cljs/` contains some development utilities.
- `deps/` contains ClojureScript dependencies or libraries used by the frontend. - `deps/` contains ClojureScript dependencies or libraries used by the frontend.

View File

@@ -13,3 +13,5 @@ Then, run the project's tests:
$ clojure -T:build test $ clojure -T:build test
If you would like to run individual tests, pass options to the test runner through `clojure -M:test`. For example, add a `^:focus` on a test and then run `clojure -M:test -i focus`. If you would like to run individual tests, pass options to the test runner through `clojure -M:test`. For example, add a `^:focus` on a test and then run `clojure -M:test -i focus`.
If e2e tests fail, `clj-e2e/e2e-dump/` contains console logs and screenshots to help debug.

View File

@@ -37,8 +37,7 @@
:logseq.class/Task :logseq.class/Task
{:title "Task" {:title "Task"
:schema {:properties [:logseq.property/status :logseq.property/priority :logseq.property/deadline :logseq.property/scheduled]} :schema {:properties [:logseq.property/status :logseq.property/priority :logseq.property/deadline :logseq.property/scheduled]}}
:properties {:logseq.property.class/hide-from-node true}}
:logseq.class/Query :logseq.class/Query
{:title "Query" {:title "Query"

View File

@@ -139,32 +139,8 @@ We have unit, performance and end to end tests.
### End to End Tests ### End to End Tests
Even though we have a nightly release channel, it's hard for testing users (thanks to the brave users!) to notice all issues in a limited time, as Logseq is covering so many features. Even though we have a nightly release channel, it's hard for testing users (thanks to the brave users!) to notice all issues in a limited time, as Logseq is covering so many features.
The only solution is automatic end-to-end tests - adding tests for GUI software is always painful but necessary. See https://github.com/logseq/logseq/pulls?q=E2E for e2e test examples.
To run end to end tests To run end to end tests, see [clj-e2e tests](/clj-e2e/README.md).
```sh
yarn electron-watch
# in another shell
yarn e2e-test # or npx playwright test
```
If e2e failed after first running:
- `rm -rdf ~/.logseq`
- `rm -rdf ~/.config/Logseq`
- `rm -rdf <repo dir>/tmp/`
- Windows: `rmdir /s %APPDATA%/Electron` (Reference: https://www.electronjs.org/de/docs/latest/api/app#appgetpathname)
There's a `traceAll()` helper function to enable playwright trace file dump for specific test files https://github.com/logseq/logseq/pull/8332
If e2e tests fail in the file, they can be debugged by examining a trace dump with [the
playwright trace
viewer](https://playwright.dev/docs/trace-viewer#recording-a-trace).
Locally this will get dumped into e2e-dump/.
On CI the trace file will be under Artifacts at the bottom of a run page e.g.
https://github.com/logseq/logseq/actions/runs/3574600322.
### Unit Testing ### Unit Testing

View File

@@ -52,7 +52,7 @@ const css = {
const common = { const common = {
clean () { clean () {
return del( return del(
['./static/**/*', '!./static/yarn.lock', '!./static/node_modules']) ['./static/**/*', '!./static/node_modules'])
}, },
syncResourceFile () { syncResourceFile () {

View File

@@ -56,7 +56,6 @@
"dev-electron-app": "gulp electron", "dev-electron-app": "gulp electron",
"release-electron": "run-s gulp:build && gulp electronMaker", "release-electron": "run-s gulp:build && gulp electronMaker",
"debug-electron": "cd static/ && yarn electron:debug", "debug-electron": "cd static/ && yarn electron:debug",
"e2e-test": "cross-env DEBUG=pw:api CI=true npx playwright test --reporter github",
"sync-android-release": "yarn clean && yarn release-mobile && rm -rf ./static/mobile/**/*.map && npx cap sync android", "sync-android-release": "yarn clean && yarn release-mobile && rm -rf ./static/mobile/**/*.map && npx cap sync android",
"sync-ios-release": "yarn clean && yarn release-mobile && rm -rf ./static/mobile/**/*.map && npx cap sync ios", "sync-ios-release": "yarn clean && yarn release-mobile && rm -rf ./static/mobile/**/*.map && npx cap sync ios",
"clean": "gulp clean", "clean": "gulp clean",

View File

@@ -1,17 +0,0 @@
#!/bin/sh
yarn clean && yarn release-publishing
/usr/bin/rm -rf /tmp/publishing
mkdir /tmp/publishing
cp -R ./static /tmp/publishing/
cp ./static/404.html /tmp/publishing/
/usr/bin/rm -rf /tmp/publishing/static/node_modules/
/usr/bin/rm /tmp/publishing/static/electron*
/usr/bin/rm /tmp/publishing/static/forge.config.js
/usr/bin/rm /tmp/publishing/static/package.json
/usr/bin/rm /tmp/publishing/static/yarn.lock
/usr/bin/rm /tmp/publishing/static/index.html
/usr/bin/rm /tmp/publishing/static/404.html
/usr/bin/rm /tmp/publishing/static/public.css
cd /tmp/publishing/
mv ./static/js/publishing/code-editor.js ./static/js/
tar -zcvf /tmp/logseq_publishing.tar.gz ./

View File

@@ -19,7 +19,9 @@
"frontend.handler.db-based." "frontend.handler.db-based."
"frontend.worker.handler.page.db-based" "frontend.worker.handler.page.db-based"
"frontend.components.property" "frontend.components.class" "frontend.components.property" "frontend.components.class"
"frontend.components.db-based" "frontend.components.objects" "frontend.components.query.view"])) "frontend.components.db-based" "frontend.components.objects" "frontend.components.query.view"
"mobile.core" "mobile.events" "mobile.externals" "mobile.init" "mobile.ionic" "mobile.state"
"mobile.components"]))
(def file-graph-ns (def file-graph-ns
"Namespaces or parent namespaces _only_ for file graphs" "Namespaces or parent namespaces _only_ for file graphs"
@@ -57,7 +59,8 @@
"src/main/frontend/components/objects.cljs" "src/main/frontend/components/objects.cljs"
"src/main/frontend/components/db_based" "src/main/frontend/components/db_based"
"src/main/frontend/components/query/view.cljs" "src/main/frontend/components/query/view.cljs"
"src/electron/electron/db.cljs"])) "src/electron/electron/db.cljs"
"src/main/mobile"]))
(def file-graph-paths (def file-graph-paths
"Paths _only_ for file graphs" "Paths _only_ for file graphs"
@@ -136,7 +139,10 @@
;; The next 3 are from components.property.value ;; The next 3 are from components.property.value
"{:block/name page-title})" "{:block/name page-title})"
"(when-not (db/get-page journal)" "(when-not (db/get-page journal)"
"(let [value (if datetime? (tc/to-long d) (db/get-page journal))]"} "(let [value (if datetime? (tc/to-long d) (db/get-page journal))]"
;; :block/name ones from src/main/mobile
"(if-let [journal (db/get-page page-name)]"
"(p/then #(mobile-state/open-block-modal! (db/get-page page-name)))))))]"}
res (grep-many file-concepts db-graph-paths) res (grep-many file-concepts db-graph-paths)
invalid-lines (when (= 0 (:exit res)) invalid-lines (when (= 0 (:exit res))
(remove #(some->> (string/split % #":\s+") second string/trim (contains? allowed-exceptions)) (remove #(some->> (string/split % #":\s+") second string/trim (contains? allowed-exceptions))

View File

@@ -2814,7 +2814,7 @@
:on-click #(db-property-handler/delete-property-value! (:db/id block) :block/tags (:db/id tag))} :on-click #(db-property-handler/delete-property-value! (:db/id block) :block/tags (:db/id tag))}
"Remove tag"))]) "Remove tag"))])
popup-opts))} popup-opts))}
(if (and @*hover? (not private-tag?)) (if (and @*hover? (not private-tag?) (not config/publishing?))
[:a.inline-flex.text-muted-foreground [:a.inline-flex.text-muted-foreground
{:title "Remove this tag" {:title "Remove this tag"
:style {:margin-top 1 :style {:margin-top 1
@@ -2844,7 +2844,10 @@
(:block/tags block) (:block/tags block)
(remove (fn [t] (remove (fn [t]
(or (ldb/inline-tag? (:block/raw-title block) t) (or (ldb/inline-tag? (:block/raw-title block) t)
(:logseq.property.class/hide-from-node t) (if (contains? t :logseq.property.class/hide-from-node)
(:logseq.property.class/hide-from-node t)
;; Mobile app hides by default while everything else doesn't
(if (util/capacitor-new?) true false))
(contains? hidden-internal-tags (:db/ident t)) (contains? hidden-internal-tags (:db/ident t))
(and (util/mobile?) (= (:db/ident t) :logseq.class/Task)))))) (and (util/mobile?) (= (:db/ident t) :logseq.class/Task))))))
popup-opts {:align :end popup-opts {:align :end
@@ -3079,7 +3082,9 @@
[:div.h-6 [:div.h-6
(shui/button {:variant :ghost (shui/button {:variant :ghost
:title "Open block references" :title "Open block references"
:class "px-1 py-0 w-5 h-5 opacity-70 hover:opacity-100" :class (str "px-1 py-0 w-5 h-5 opacity-70 hover:opacity-100" (when (and (util/mobile?)
(seq (:block/_parent block)))
" !pr-4"))
:size :sm :size :sm
:on-click (fn [e] :on-click (fn [e]
(if (gobj/get e "shiftKey") (if (gobj/get e "shiftKey")
@@ -3475,7 +3480,9 @@
:on-drop (fn [event] :on-drop (fn [event]
(block-drop event uuid block original-block *move-to')) (block-drop event uuid block original-block *move-to'))
:on-drag-end (fn [event] :on-drag-end (fn [event]
(dom/remove-class! (.-target event) "dragging") (doseq [block (or (seq (state/get-selection-blocks)) [(.-target event)])]
(dom/remove-class! block "dragging"))
(dom/remove! js/document.body (dom/sel1 "#dragging-ghost-element"))
(block-drag-end event *move-to'))})) (block-drag-end event *move-to'))}))
(defn- root-block? (defn- root-block?
@@ -3672,8 +3679,22 @@
(fn [event] (fn [event]
(when-not (state/editing?) (when-not (state/editing?)
(util/stop-propagation event) (util/stop-propagation event)
(dom/add-class! (.-target event) "dragging") (let [target ^js (.-target event)
(on-drag-start event block block-id)))) blocks (or (seq (state/get-selection-blocks)) [target])
multiple? (> (count blocks) 1)
element (when multiple?
(let [element (dom/create-element "div")]
(-> element
(dom/set-attr! "id" "dragging-ghost-element")
(dom/set-text! (str "Moving " (count blocks) " blocks"))
(dom/set-class! "p-2 rounded text-sm"))
element))]
(doseq [block blocks]
(dom/add-class! block "dragging"))
(on-drag-start event block block-id)
(when element
(dom/append! js/document.body element)
(dnd/set-drag-image! event element (/ (.-offsetWidth target) 2) (/ (.-offsetHeight target) 2)))))))
(:property-default-value? config) (:property-default-value? config)
(assoc :data-is-property-default-value (:property-default-value? config)) (assoc :data-is-property-default-value (:property-default-value? config))

View File

@@ -8,6 +8,7 @@
[frontend.components.page :as page] [frontend.components.page :as page]
[frontend.components.profiler :as profiler] [frontend.components.profiler :as profiler]
[frontend.components.shortcut-help :as shortcut-help] [frontend.components.shortcut-help :as shortcut-help]
[frontend.config :as config]
[frontend.context.i18n :refer [t]] [frontend.context.i18n :refer [t]]
[frontend.date :as date] [frontend.date :as date]
[frontend.db :as db] [frontend.db :as db]
@@ -437,7 +438,7 @@
(state/sidebar-add-block! repo "help" :help))} (state/sidebar-add-block! repo "help" :help))}
(t :right-side-bar/help)]] (t :right-side-bar/help)]]
(when (state/sub [:ui/developer-mode?]) (when (and (state/sub [:ui/developer-mode?]) (not config/publishing?))
[:div.text-sm [:div.text-sm
[:button.button.cp__right-sidebar-settings-btn {:on-click (fn [_e] [:button.button.cp__right-sidebar-settings-btn {:on-click (fn [_e]
(state/sidebar-add-block! repo "rtc" :rtc))} (state/sidebar-add-block! repo "rtc" :rtc))}

View File

@@ -124,9 +124,11 @@ main.ls-fold-button-on-right {
.ls-block { .ls-block {
.block-control { .block-control {
@apply absolute -right-3 pr-2 pt-1 top-0 z-[1] @apply absolute -right-3 pr-2 pt-1 top-0 z-[1]
opacity-20 active:opacity-100; opacity-50 active:opacity-100;
margin-top: 3px;
.rotating-arrow.collapsed svg { .rotating-arrow.collapsed svg {
margin-left: -2px;
transform: rotate(180deg); transform: rotate(180deg);
} }
} }
@@ -165,4 +167,4 @@ html[data-font='serif'] .ls-block, .ls-font-serif {
html[data-font='mono'] .ls-block, .ls-font-mono { html[data-font='mono'] .ls-block, .ls-font-mono {
font-family: iawriter-mono, Nitti, Menlo, Courier, monospace; font-family: iawriter-mono, Nitti, Menlo, Courier, monospace;
} }

View File

@@ -252,7 +252,7 @@
(p/let [block (or block (and (fn? create-new-block) (create-new-block)))] (p/let [block (or block (and (fn? create-new-block) (create-new-block)))]
(when block (when block
(cond (cond
(util/meta-key? e) (or (util/meta-key? e) (util/mobile?))
(redirect!) (redirect!)
(.-shiftKey e) (.-shiftKey e)
@@ -304,26 +304,27 @@
(render block*)))] (render block*)))]
[:div]) [:div])
(let [class (str "h-6 w-6 !p-1 text-muted-foreground transition-opacity duration-100 ease-in bg-gray-01 " (when-not (util/mobile?)
"opacity-" opacity)] (let [class (str "h-6 w-6 !p-1 text-muted-foreground transition-opacity duration-100 ease-in bg-gray-01 "
[:div.absolute.-right-1 "opacity-" opacity)]
[:div.flex.flex-row.items-center [:div.absolute.-right-1
(shui/button [:div.flex.flex-row.items-center
{:variant :ghost (shui/button
:title "Open" {:variant :ghost
:on-click (fn [e] :title "Open"
(util/stop-propagation e) :on-click (fn [e]
(redirect!)) (util/stop-propagation e)
:class class} (redirect!))
(ui/icon "arrow-right")) :class class}
(shui/button (ui/icon "arrow-right"))
{:variant :ghost (shui/button
:title "Open in sidebar" {:variant :ghost
:class class :title "Open in sidebar"
:on-click (fn [e] :class class
(util/stop-propagation e) :on-click (fn [e]
(add-to-sidebar!))} (util/stop-propagation e)
(ui/icon "layout-sidebar-right"))]])])) (add-to-sidebar!))}
(ui/icon "layout-sidebar-right"))]]))]))
(defn build-columns (defn build-columns
[config properties & {:keys [with-object-name? with-id? add-tags-column?] [config properties & {:keys [with-object-name? with-id? add-tags-column?]

View File

@@ -121,7 +121,9 @@
(when-not skip-refresh? (when-not skip-refresh?
(react/refresh-affected-queries! graph affected-keys {:skip-kv-custom-keys? true})))) (react/refresh-affected-queries! graph affected-keys {:skip-kv-custom-keys? true}))))
(if children-only? children block)) (if children-only?
children
(if skip-transact? block (db/entity (:db/id block)))))
(p/catch (fn [error] (p/catch (fn [error]
(js/console.error error) (js/console.error error)
(throw (ex-info "get-block error" {:block id-uuid-or-name})))))))) (throw (ex-info "get-block error" {:block id-uuid-or-name}))))))))

View File

@@ -26,7 +26,6 @@
[frontend.handler.plugin-config :as plugin-config-handler] [frontend.handler.plugin-config :as plugin-config-handler]
[frontend.handler.repo :as repo-handler] [frontend.handler.repo :as repo-handler]
[frontend.handler.repo-config :as repo-config-handler] [frontend.handler.repo-config :as repo-config-handler]
[frontend.handler.test :as test]
[frontend.handler.ui :as ui-handler] [frontend.handler.ui :as ui-handler]
[frontend.handler.user :as user-handler] [frontend.handler.user :as user-handler]
[frontend.idb :as idb] [frontend.idb :as idb]
@@ -138,7 +137,6 @@
[render] [render]
(idb/start) (idb/start)
(test/setup-test!)
(get-system-info) (get-system-info)
(set-global-error-notification!) (set-global-error-notification!)

View File

@@ -6,10 +6,18 @@
[frontend.handler.property :as property-handler] [frontend.handler.property :as property-handler]
[frontend.modules.outliner.op :as outliner-op] [frontend.modules.outliner.op :as outliner-op]
[frontend.modules.outliner.ui :as ui-outliner-tx] [frontend.modules.outliner.ui :as ui-outliner-tx]
[frontend.util.ref :as ref]
[frontend.state :as state] [frontend.state :as state]
[frontend.util.ref :as ref]
[logseq.db :as ldb])) [logseq.db :as ldb]))
(defn set-drag-image!
([e image]
(set-drag-image! e image 0 0))
([e image offset-x offset-y]
(let [dt (.-dataTransfer e)]
(.setDragImage dt image offset-x offset-y)
e)))
(defn move-blocks (defn move-blocks
[^js event blocks target-block original-block move-to] [^js event blocks target-block original-block move-to]
(let [target-block (db/entity (:db/id target-block)) (let [target-block (db/entity (:db/id target-block))

View File

@@ -1,16 +0,0 @@
(ns frontend.handler.test
"Prepare for running e2e tests"
(:require [frontend.storage :as storage]
[frontend.state :as state]))
(defn clear-whiteboard-storage-for-e2e-tests
[]
(storage/set :whiteboard/onboarding-whiteboard? false)
(storage/set :whiteboard/onboarding-tour? false)
(state/set-state! :whiteboard/onboarding-whiteboard? false)
(state/set-state! :whiteboard/onboarding-tour? false)
(prn :debug :whiteboard/onboarding-whiteboard? (:whiteboard/onboarding-whiteboard? @state/state)))
(defn setup-test!
[]
(set! (.-clearWhiteboardStorage js/window) clear-whiteboard-storage-for-e2e-tests))

View File

@@ -462,9 +462,11 @@
:binding []} :binding []}
:graph/add {:fn (fn [] (route-handler/redirect! {:to :graphs})) :graph/add {:fn (fn [] (route-handler/redirect! {:to :graphs}))
:inactive config/publishing?
:binding []} :binding []}
:graph/db-add {:fn #(state/pub-event! [:graph/new-db-graph]) :graph/db-add {:fn #(state/pub-event! [:graph/new-db-graph])
:inactive config/publishing?
:binding false} :binding false}
:graph/db-save {:fn #(state/pub-event! [:graph/save-db-to-disk]) :graph/db-save {:fn #(state/pub-event! [:graph/save-db-to-disk])
@@ -541,6 +543,7 @@
:editor/quick-add {:binding (if mac? "mod+e" "mod+alt+e") :editor/quick-add {:binding (if mac? "mod+e" "mod+alt+e")
:db-graph? true :db-graph? true
:inactive config/publishing?
:fn editor-handler/quick-add} :fn editor-handler/quick-add}
:editor/jump {:binding "mod+j" :editor/jump {:binding "mod+j"
:fn jump-handler/jump-to} :fn jump-handler/jump-to}

View File

@@ -85,7 +85,7 @@
(defn start-db-worker! (defn start-db-worker!
[] []
(when-not util/node-test? (when-not util/node-test?
(let [worker-url "js/db-worker.js" (let [worker-url (if config/publishing? "static/js/db-worker.js" "js/db-worker.js")
worker (js/Worker. (str worker-url "?electron=" (util/electron?) "&publishing=" config/publishing?)) worker (js/Worker. (str worker-url "?electron=" (util/electron?) "&publishing=" config/publishing?))
wrapped-worker* (Comlink/wrap worker) wrapped-worker* (Comlink/wrap worker)
wrapped-worker (fn [qkw direct-pass? & args] wrapped-worker (fn [qkw direct-pass? & args]

View File

@@ -249,7 +249,7 @@
(not (number? last-gc-at)) (not (number? last-gc-at))
(> (- (common-util/time-ms) last-gc-at) (* 3 24 3600 1000))) ; 3 days ago (> (- (common-util/time-ms) last-gc-at) (* 3 24 3600 1000))) ; 3 days ago
(println :debug "gc current graph") (println :debug "gc current graph")
(doseq [db [sqlite-db client-ops-db]] (doseq [db (if @*publishing? [sqlite-db] [sqlite-db client-ops-db])]
(sqlite-gc/gc-kvs-table! db {:full-gc? full-gc?}) (sqlite-gc/gc-kvs-table! db {:full-gc? full-gc?})
(.exec db "VACUUM")) (.exec db "VACUUM"))
(d/transact! datascript-conn [{:db/ident :logseq.kv/graph-last-gc-at (d/transact! datascript-conn [{:db/ident :logseq.kv/graph-last-gc-at

View File

@@ -7,6 +7,7 @@
[datascript.core :as d] [datascript.core :as d]
[frontend.common.search-fuzzy :as fuzzy] [frontend.common.search-fuzzy :as fuzzy]
[goog.object :as gobj] [goog.object :as gobj]
[logseq.common.config :as common-config]
[logseq.common.util :as common-util] [logseq.common.util :as common-util]
[logseq.common.util.namespace :as ns-util] [logseq.common.util.namespace :as ns-util]
[logseq.db :as ldb] [logseq.db :as ldb]
@@ -193,11 +194,17 @@ DROP TRIGGER IF EXISTS blocks_au;
(seq (fuzzy/search-normalize match true)) (seq (fuzzy/search-normalize match true))
(seq (fuzzy/search-normalize q true)))))) (seq (fuzzy/search-normalize q true))))))
(defn- hidden-entity?
[entity]
(or (ldb/hidden? entity)
(let [page (:block/page entity)]
(and (ldb/hidden? page)
(not= (:block/title page) common-config/quick-add-page-name)))))
(defn- page-or-object? (defn- page-or-object?
[entity] [entity]
(and (or (ldb/page? entity) (ldb/object? entity)) (and (or (ldb/page? entity) (ldb/object? entity))
(not (ldb/hidden? entity)) (not (hidden-entity? entity))))
(not (ldb/hidden? (:block/page entity)))))
(defn get-all-fuzzy-supported-blocks (defn get-all-fuzzy-supported-blocks
"Only pages and objects are supported now." "Only pages and objects are supported now."
@@ -209,9 +216,7 @@ DROP TRIGGER IF EXISTS blocks_au;
(map :e))) (map :e)))
blocks (->> (distinct (concat page-ids object-ids)) blocks (->> (distinct (concat page-ids object-ids))
(map #(d/entity db %)))] (map #(d/entity db %)))]
(->> blocks (remove hidden-entity? blocks)))
(remove ldb/hidden?)
(remove #(ldb/hidden? (:block/page %))))))
(defn- sanitize (defn- sanitize
[content] [content]
@@ -357,9 +362,7 @@ DROP TRIGGER IF EXISTS blocks_au;
(->> (d/datoms db :avet :block/uuid) (->> (d/datoms db :avet :block/uuid)
(map :v) (map :v)
(keep #(d/entity db [:block/uuid %])) (keep #(d/entity db [:block/uuid %]))
(remove (fn [e] (remove hidden-entity?))))
(or (ldb/hidden? e)
(ldb/hidden? (:block/page e))))))))
(defn build-blocks-indice (defn build-blocks-indice
[repo db] [repo db]
@@ -387,8 +390,7 @@ DROP TRIGGER IF EXISTS blocks_au;
(keep #(d/entity db-before %) blocks-to-remove-set)) (keep #(d/entity db-before %) blocks-to-remove-set))
:blocks-to-add (->> :blocks-to-add (->>
(keep #(d/entity db-after %) blocks-to-add-set') (keep #(d/entity db-after %) blocks-to-add-set')
(remove ldb/hidden?) (remove hidden-entity?))})))
(remove #(ldb/hidden? (:block/page %))))})))
(defn- get-affected-blocks (defn- get-affected-blocks
[repo tx-report] [repo tx-report]

View File

@@ -4,7 +4,6 @@
[clojure.string :as string] [clojure.string :as string]
[frontend.components.journal :as journal] [frontend.components.journal :as journal]
[frontend.components.rtc.indicator :as rtc-indicator] [frontend.components.rtc.indicator :as rtc-indicator]
[frontend.config :as config]
[frontend.date :as date] [frontend.date :as date]
[frontend.db :as db] [frontend.db :as db]
[frontend.db.conn :as db-conn] [frontend.db.conn :as db-conn]
@@ -137,7 +136,6 @@
(when (and repo (when (and repo
(ldb/get-graph-rtc-uuid (db/get-db)) (ldb/get-graph-rtc-uuid (db/get-db))
(user-handler/logged-in?) (user-handler/logged-in?)
(config/db-based-graph? repo)
(user-handler/team-member?)) (user-handler/team-member?))
[:<> [:<>
;; (rum/with-key (rtc-collaborators) ;; (rum/with-key (rtc-collaborators)

View File

@@ -1,7 +1,6 @@
(ns mobile.components.editor-toolbar (ns mobile.components.editor-toolbar
"Mobile editor toolbar" "Mobile editor toolbar"
(:require [mobile.init :as init] (:require [frontend.commands :as commands]
[frontend.commands :as commands]
[frontend.handler.editor :as editor-handler] [frontend.handler.editor :as editor-handler]
[frontend.mobile.camera :as mobile-camera] [frontend.mobile.camera :as mobile-camera]
[frontend.mobile.haptics :as haptics] [frontend.mobile.haptics :as haptics]
@@ -11,6 +10,8 @@
[frontend.util.cursor :as cursor] [frontend.util.cursor :as cursor]
[goog.dom :as gdom] [goog.dom :as gdom]
[logseq.common.util.page-ref :as page-ref] [logseq.common.util.page-ref :as page-ref]
[mobile.init :as init]
[promesa.core :as p]
[rum.core :as rum])) [rum.core :as rum]))
(defn- blur-if-compositing (defn- blur-if-compositing
@@ -93,6 +94,7 @@
(command #(let [parent-id (state/get-edit-input-id)] (command #(let [parent-id (state/get-edit-input-id)]
(mobile-camera/embed-photo parent-id)) {:icon "camera"} true)] (mobile-camera/embed-photo parent-id)) {:icon "camera"} true)]
[:div.toolbar-hide-keyboard [:div.toolbar-hide-keyboard
(command #(do (command #(p/do!
(state/clear-edit!) (editor-handler/save-current-block!)
(init/keyboard-hide)) {:icon "keyboard-show"})]]))) (state/clear-edit!)
(init/keyboard-hide)) {:icon "keyboard-show"})]])))

View File

@@ -7,7 +7,7 @@
[frontend.handler.page :as page-handler] [frontend.handler.page :as page-handler]
[frontend.state :as state] [frontend.state :as state]
[frontend.ui :as ui] [frontend.ui :as ui]
[logseq.db :as ldb] [logseq.db.frontend.entity-util :as entity-util]
[mobile.components.ui :as mobile-ui] [mobile.components.ui :as mobile-ui]
[mobile.init :as init] [mobile.init :as init]
[mobile.ionic :as ion] [mobile.ionic :as ion]
@@ -49,7 +49,7 @@
{:on-click (fn [] {:on-click (fn []
(mobile-ui/open-modal! (mobile-ui/open-modal!
(str "⚠️ Are you sure you want to delete this " (str "⚠️ Are you sure you want to delete this "
(if (ldb/page? block) "page" "block") (if (entity-util/page? block) "page" "block")
"?") "?")
{:type :alert {:type :alert
:on-action (fn [{:keys [role]}] :on-action (fn [{:keys [role]}]

View File

@@ -77,21 +77,18 @@
[1 #js [0 1]] [1 #js [0 1]]
[0.75 #js [0 0.75 1]])] [0.75 #js [0 0.75 1]])]
(when open? (when open?
(if (= :ls-quick-add (:id opts)) (state/clear-edit!)
(when-let [add-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)] (init/keyboard-hide))
(when (:block/_parent add-page)
(js/setTimeout
(fn []
(let [block (last (ldb/sort-by-order (:block/_parent add-page)))]
(editor-handler/edit-block! block :max {:container-id :unknown-container})))
500)))
(do
(state/clear-edit!)
(init/keyboard-hide))))
(ion/modal (ion/modal
(merge (merge
{:isOpen (boolean open?) {:isOpen (boolean open?)
:initialBreakpoint initial-breakpoint :initialBreakpoint initial-breakpoint
:onDidPresent (fn []
(when (= :ls-quick-add (:id opts))
(when-let [add-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)]
(when (:block/_parent add-page)
(let [block (last (ldb/sort-by-order (:block/_parent add-page)))]
(editor-handler/edit-block! block :max {:container-id :unknown-container}))))))
:breakpoints breakpoints :breakpoints breakpoints
:onDidDismiss (fn [] :onDidDismiss (fn []
(mobile-state/set-popup! nil) (mobile-state/set-popup! nil)

View File

@@ -1,8 +1,6 @@
(ns mobile.components.search (ns mobile.components.search
"Mobile search" "Mobile search"
(:require [mobile.ionic :as ion] (:require [clojure.string :as string]
[mobile.state :as mobile-state]
[clojure.string :as string]
[frontend.components.cmdk.core :as cmdk] [frontend.components.cmdk.core :as cmdk]
[frontend.db :as db] [frontend.db :as db]
[frontend.handler.block :as block-handler] [frontend.handler.block :as block-handler]
@@ -13,6 +11,8 @@
[frontend.util :as util] [frontend.util :as util]
[logseq.db :as ldb] [logseq.db :as ldb]
[logseq.shui.hooks :as hooks] [logseq.shui.hooks :as hooks]
[mobile.ionic :as ion]
[mobile.state :as mobile-state]
[promesa.core :as p] [promesa.core :as p]
[rum.core :as rum])) [rum.core :as rum]))
@@ -106,7 +106,7 @@
(ion/item (ion/item
{:on-click #(set-input! item)} {:on-click #(set-input! item)}
[:div.flex.flex-row.items-center.gap-1 [:div.flex.flex-row.items-center.gap-1
(ui/icon "search" {:size 14 (ui/icon "search" {:size 15
:class "text-muted-foreground"}) :class "text-muted-foreground"})
item])))] item])))]
@@ -122,7 +122,7 @@
(when header (when header
[:div.opacity-50.text-sm [:div.opacity-50.text-sm
header]) header])
[:div.flex.flex-row.items-center.gap-1 [:div.flex.flex-row.items-start.gap-1
(when icon (ui/icon icon {:size 14 (when icon (ui/icon icon {:size 15
:class "text-muted-foreground"})) :class "text-muted-foreground mt-1"}))
[:div text]]])))))))) [:div text]]]))))))))

View File

@@ -30,5 +30,6 @@
@import "src/main/frontend/extensions/code.css"; @import "src/main/frontend/extensions/code.css";
@import "src/main/frontend/components/file_sync.css"; @import "src/main/frontend/components/file_sync.css";
@import "src/main/frontend/components/table.css"; @import "src/main/frontend/components/table.css";
@import "src/main/frontend/components/command_palette.css";
@import-glob "src/main/mobile/**/[!_]*.css"; @import-glob "src/main/mobile/**/[!_]*.css";