Tienson Qin 3 ay önce
ebeveyn
işleme
e373350aef

+ 18 - 17
src/main/capacitor/components/app.cljs

@@ -1,4 +1,5 @@
 (ns capacitor.components.app
+  "App root"
   (:require ["../externals.js"]
             [capacitor.components.editor-toolbar :as editor-toolbar]
             [capacitor.components.modal :as modal]
@@ -8,7 +9,7 @@
             [capacitor.components.settings :as settings]
             [capacitor.components.ui :as ui-component]
             [capacitor.ionic :as ion]
-            [capacitor.state :as state]
+            [capacitor.state :as mobile-state]
             [clojure.string :as string]
             [frontend.components.journal :as journal]
             [frontend.components.rtc.indicator :as rtc-indicator]
@@ -21,7 +22,7 @@
             [frontend.handler.user :as user-handler]
             [frontend.mobile.util :as mobile-util]
             [frontend.rum :as frum]
-            [frontend.state :as fstate]
+            [frontend.state :as state]
             [frontend.ui :as ui]
             [goog.date :as gdate]
             [logseq.db :as ldb]
@@ -34,8 +35,8 @@
 
 (rum/defc app-graphs-select
   []
-  (let [current-repo (fstate/get-current-repo)
-        graphs (fstate/get-repos)
+  (let [current-repo (state/get-current-repo)
+        graphs (state/get-repos)
         short-repo-name (if current-repo
                           (db-conn/get-short-repo-name current-repo)
                           "Select a Graph")]
@@ -62,7 +63,7 @@
                                                                    (when-not (string/blank? db-name)
                                                                      (repo-handler/new-db! db-name)))
                                                                  (when (string/starts-with? role "logseq_db_")
-                                                                   (fstate/pub-event! [:graph/switch role])))))
+                                                                   (state/pub-event! [:graph/switch role])))))
                                                 :modal-props {:class "graph-switcher"}})))}
       [:span.flex.items-center.gap-2.opacity-80.pt-1
        [:strong.overflow-hidden.text-ellipsis.block.font-normal
@@ -114,15 +115,15 @@
                                 (let [apply-date! (fn [date]
                                                     (let [page-name (date/journal-name (gdate/Date. (js/Date. date)))]
                                                       (if-let [journal (db/get-page page-name)]
-                                                        (state/open-block-modal! journal)
+                                                        (mobile-state/open-block-modal! journal)
                                                         (-> (page-handler/<create! page-name {:redirect? false})
-                                                            (p/then #(state/open-block-modal! (db/get-page page-name)))))))]
+                                                            (p/then #(mobile-state/open-block-modal! (db/get-page page-name)))))))]
                                   (-> (.showDatePicker mobile-util/ui-local)
                                       (p/then (fn [^js e] (some-> e (.-value) (apply-date!)))))))}
                    [:span.text-muted-foreground {:slot "icon-only"}
                     (ion/tabler-icon "calendar-month" {:size 24})])
 
-                  (let [repo (fstate/get-current-repo)]
+                  (let [repo (state/get-current-repo)]
                     [:div.flex.flex-row.items-center.gap-2.text-muted-foreground
                      (when (and repo
                                 (ldb/get-graph-rtc-uuid (db/get-db))
@@ -154,15 +155,15 @@
                 (ui/inject-document-devices-envs!)
                 state)}
   [*page current-tab]
-  (let [db-restoring? (fstate/sub :db/restoring?)]
+  (let [db-restoring? (state/sub :db/restoring?)]
     (home-inner *page db-restoring? current-tab)))
 
 (defn use-theme-effects!
   [current-repo]
-  (let [[theme] (frum/use-atom-in fstate/state :ui/theme)]
+  (let [[theme] (frum/use-atom-in state/state :ui/theme)]
     (hooks/use-effect!
      (fn []
-       (fstate/sync-system-theme!)
+       (state/sync-system-theme!)
        (ui/setup-system-theme-effect!))
      [])
     (hooks/use-effect!
@@ -184,7 +185,7 @@
 
 (rum/defc tabs
   [current-repo]
-  (let [[current-tab _] (state/use-tab)
+  (let [[current-tab _] (mobile-state/use-tab)
         *home-page (hooks/use-ref nil)
         *search-page (hooks/use-ref nil)
         [presenting-element set-presenting-element!] (hooks/use-state nil)]
@@ -201,8 +202,8 @@
     (ion/tabs
      {:id "app-ion-tabs"
       :onIonTabsDidChange (fn [^js e]
-                            (state/set-tab! (.-tab (.-detail e))
-                                            (.-target e)))}
+                            (mobile-state/set-tab! (.-tab (.-detail e))
+                                                   (.-target e)))}
      (ion/tab
       {:tab "home"}
       (ion/content
@@ -230,9 +231,9 @@
 
 (rum/defc main < rum/reactive
   []
-  (let [current-repo (fstate/sub :git/current-repo)
-        show-action-bar? (fstate/sub :mobile/show-action-bar?)
-        {:keys [open?]} (rum/react state/*modal-data)]
+  (let [current-repo (state/sub :git/current-repo)
+        show-action-bar? (state/sub :mobile/show-action-bar?)
+        {:keys [open?]} (rum/react mobile-state/*modal-data)]
     (ion/app
      (tabs current-repo)
      (when-not open?

+ 2 - 32
src/main/capacitor/components/editor_toolbar.cljs

@@ -1,11 +1,9 @@
 (ns capacitor.components.editor-toolbar
-  (:require [dommy.core :as dom]
+  "Mobile editor toolbar"
+  (:require [capacitor.init :as init]
             [frontend.commands :as commands]
-            [frontend.date :as date]
             [frontend.handler.editor :as editor-handler]
-            [frontend.handler.page :as page-handler]
             [frontend.mobile.camera :as mobile-camera]
-            [capacitor.init :as init]
             [frontend.mobile.haptics :as haptics]
             [frontend.state :as state]
             [frontend.ui :as ui]
@@ -45,34 +43,6 @@
                           (command-handler)))}
     (ui/icon icon {:size ui/icon-size :class class})]])
 
-(rum/defc timestamp-submenu
-  [parent-id]
-  (let [callback (fn [event]
-                   (util/stop event)
-                   (let [target (gdom/getElement "mobile-toolbar-timestamp-submenu")]
-                     (dom/remove-class! target "show-submenu")))
-        command-cp (fn [action description]
-                     [:button
-                      {:on-pointer-down (fn [e]
-                                          (action)
-                                          (callback e))}
-                      description])]
-    [:div
-     [:div#mobile-toolbar-timestamp-submenu.submenu
-      {:style {:bottom @util/keyboard-height}}
-      (command-cp #(let [today (page-handler/get-page-ref-text (date/today))]
-                     (commands/simple-insert! parent-id today {}))
-                  "Today")
-      (command-cp #(let [tomorrow (page-handler/get-page-ref-text (date/tomorrow))]
-                     (commands/simple-insert! parent-id tomorrow {}))
-                  "Tomorrow")
-      (command-cp #(let [yesterday (page-handler/get-page-ref-text (date/yesterday))]
-                     (commands/simple-insert! parent-id yesterday {}))
-                  "Yesterday")
-      (command-cp #(let [timestamp (date/get-current-time)]
-                     (commands/simple-insert! parent-id timestamp {}))
-                  "Time")]]))
-
 (defn- insert-text
   [text opts]
   (when-let [parent-id (state/get-edit-input-id)]

+ 17 - 16
src/main/capacitor/components/modal.cljs

@@ -1,31 +1,32 @@
 (ns capacitor.components.modal
+  "Mobile modal"
   (:require ["../externals.js"]
             [capacitor.components.editor-toolbar :as mobile-bar]
             [capacitor.components.selection-toolbar :as selection-toolbar]
-            [capacitor.components.ui :as ui]
+            [capacitor.components.ui :as mobile-ui]
             [capacitor.init :as init]
             [capacitor.ionic :as ion]
-            [capacitor.state :as state]
+            [capacitor.state :as mobile-state]
             [frontend.components.page :as page]
             [frontend.db :as db]
             [frontend.handler.notification :as notification]
             [frontend.handler.page :as page-handler]
-            [frontend.state :as fstate]
-            [frontend.ui :as frontend-ui]
+            [frontend.state :as state]
+            [frontend.ui :as ui]
             [rum.core :as rum]))
 
 (rum/defc block-modal < rum/reactive
   [presenting-element]
-  (let [{:keys [open? block]} (rum/react state/*modal-data)
-        show-action-bar? (fstate/sub :mobile/show-action-bar?)
-        close! #(swap! state/*modal-data assoc :open? false)]
+  (let [{:keys [open? block]} (rum/react mobile-state/*modal-data)
+        show-action-bar? (state/sub :mobile/show-action-bar?)
+        close! #(swap! mobile-state/*modal-data assoc :open? false)]
     (when open?
-      (fstate/clear-edit!)
+      (state/clear-edit!)
       (init/keyboard-hide))
     (ion/modal
      {:isOpen (boolean open?)
       :presenting-element presenting-element
-      :onDidDismiss (fn [] (state/set-modal! nil))
+      :onDidDismiss (fn [] (mobile-state/set-modal! nil))
       :mode "ios"                                          ;; force card modal for android
       :expand "block"}
 
@@ -37,17 +38,17 @@
         (ion/tabler-icon "chevron-down" {:size 16 :stroke 3})]
        [:span.opacity-40.active:opacity-60
         {:on-click (fn []
-                     (ui/open-popup!
+                     (mobile-ui/open-popup!
                       (fn []
                         [:div.-mx-2
-                         (frontend-ui/menu-link
+                         (ui/menu-link
                           {:on-click (fn []
-                                       (ui/open-modal!
+                                       (mobile-ui/open-modal!
                                         "⚠️ Are you sure you want to delete this page(block)?"
                                         {:type :alert
                                          :on-action (fn [{:keys [role]}]
                                                       (when (not= role "cancel")
-                                                        (ui/close-popup!)
+                                                        (mobile-ui/close-popup!)
                                                         (some->
                                                          (:block/uuid block)
                                                          (page-handler/<delete!
@@ -63,8 +64,8 @@
                            (ion/tabler-icon "trash" {:class "opacity-80" :size 18})
                            "Delete"])
 
-                         (frontend-ui/menu-link
-                          {:on-click #(ui/close-popup!)}
+                         (ui/menu-link
+                          {:on-click #(mobile-ui/close-popup!)}
                           [:span.text-lg.flex.gap-2.items-center
                            (ion/tabler-icon "copy" {:class "opacity-80" :size 18})
                            "Copy"])])
@@ -73,7 +74,7 @@
         (ion/tabler-icon "dots-vertical" {:size 18 :stroke 2})])
 
       (ion/content {:class "ion-padding scrolling"}
-                   (ui/classic-app-container-wrap
+                   (mobile-ui/classic-app-container-wrap
                     (page/page-cp (db/entity [:block/uuid (:block/uuid block)])))
                    (mobile-bar/mobile-bar)
                    (when show-action-bar?

+ 8 - 7
src/main/capacitor/components/popup.cljs

@@ -1,6 +1,7 @@
 (ns capacitor.components.popup
+  "Mobile popup"
   (:require [capacitor.ionic :as ion]
-            [capacitor.state :as state]
+            [capacitor.state :as mobile-state]
             [dommy.core :as dom]
             [logseq.shui.popup.core :as shui-popup]
             [logseq.shui.ui :as shui]
@@ -40,9 +41,9 @@
 
     :else
     (when (fn? content-fn)
-      (state/set-popup! {:open? true
-                         :content-fn content-fn
-                         :opts opts})
+      (mobile-state/set-popup! {:open? true
+                                :content-fn content-fn
+                                :opts opts})
       (reset! *last-popup-modal? true))))
 
 (defn popup-hide!
@@ -50,7 +51,7 @@
   (cond
     (= :download-rtc-graph (first args))
     (do
-      (state/set-popup! nil)
+      (mobile-state/set-popup! nil)
       (js/setTimeout
        #(.select (dom/sel1 "ion-tabs") "home") 1000))
 
@@ -63,13 +64,13 @@
 
 (rum/defc popup < rum/reactive
   []
-  (let [{:keys [open? content-fn opts]} (rum/react state/*popup-data)]
+  (let [{:keys [open? content-fn opts]} (rum/react mobile-state/*popup-data)]
     (ion/modal
      (merge
       {:isOpen (boolean open?)
        :initialBreakpoint 0.75
        :breakpoints #js [0 0.75 1]
-       :onDidDismiss (fn [] (state/set-popup! nil))
+       :onDidDismiss (fn [] (mobile-state/set-popup! nil))
        :expand "block"}
       (:modal-props opts))
      (ion/content

+ 6 - 6
src/main/capacitor/components/search.cljs

@@ -1,14 +1,14 @@
 (ns capacitor.components.search
-  (:require [capacitor.components.modal :as modal]
-            [capacitor.ionic :as ion]
-            [capacitor.state :as state]
+  "Mobile search"
+  (:require [capacitor.ionic :as ion]
+            [capacitor.state :as mobile-state]
             [clojure.string :as string]
             [frontend.components.cmdk.core :as cmdk]
             [frontend.db :as db]
             [frontend.handler.block :as block-handler]
             [frontend.handler.search :as search-handler]
             [frontend.search :as search]
-            [frontend.state :as fstate]
+            [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.util :as util]
             [logseq.db :as ldb]
@@ -18,7 +18,7 @@
 
 (defn- search-blocks
   [input]
-  (p/let [repo (fstate/get-current-repo)
+  (p/let [repo (state/get-current-repo)
           blocks (search/block-search repo input
                                       {:limit 100 :built-in? true})
           blocks (remove nil? blocks)
@@ -117,7 +117,7 @@
          (let [block (or source-page source-block)]
            (ion/item
             {:on-click (fn []
-                         (state/open-block-modal! block))}
+                         (mobile-state/open-block-modal! block))}
             [:div.flex.flex-col.gap-1.py-1
              (when header
                [:div.opacity-50.text-sm

+ 3 - 2
src/main/capacitor/components/settings.cljs

@@ -1,15 +1,16 @@
 (ns capacitor.components.settings
+  "Mobile settings"
   (:require [capacitor.ionic :as ion]
             [frontend.components.repo :as repo]
             [frontend.components.user.login :as login]
             [frontend.handler.user :as user-handler]
-            [frontend.state :as fstate]
+            [frontend.state :as state]
             [logseq.shui.ui :as shui]
             [rum.core :as rum]))
 
 (rum/defc user-profile < rum/reactive
   []
-  (let [login? (and (fstate/sub :auth/id-token) (user-handler/logged-in?))]
+  (let [login? (and (state/sub :auth/id-token) (user-handler/logged-in?))]
     (if-not login?
       (shui/button
        {:variant :default

+ 10 - 19
src/main/capacitor/components/ui.cljs

@@ -1,12 +1,12 @@
 (ns capacitor.components.ui
+  "Mobile ui"
   (:require [capacitor.ionic :as ion]
+            [capacitor.state :as mobile-state]
             [cljs-bean.core :as bean]
             [frontend.handler.notification :as notification]
             [frontend.rum :as r]
-            [frontend.state :as fstate]
+            [frontend.state :as state]
             [frontend.ui :as ui]
-            [capacitor.components.popup :as popup]
-            [capacitor.state :as state]
             [medley.core :as medley]
             [react-transition-group :refer [CSSTransition TransitionGroup]]
             [rum.core :as rum]))
@@ -14,15 +14,6 @@
 (defonce transition-group (r/adapt-class TransitionGroup))
 (defonce css-transition (r/adapt-class CSSTransition))
 
-(rum/defc safe-page-container
-  [content {:keys [header-content page-props content-props]}]
-  (ion/page
-   (merge {:class "app-safe-page"} page-props)
-   (some-> header-content (ion/header))
-   (ion/content
-    (merge {:class "ion-padding"} content-props)
-    content)))
-
 (rum/defc classic-app-container-wrap
   [content]
   [:main#app-container-wrapper.ls-fold-button-on-right
@@ -91,7 +82,7 @@
 
 (rum/defc install-notifications < rum/reactive
   []
-  (let [contents (fstate/sub :notification/contents)]
+  (let [contents (state/sub :notification/contents)]
     (transition-group
      {:class-name "notifications ui__notifications"}
      (let [notifications
@@ -189,14 +180,14 @@
 
 (defn open-popup!
   [content-fn opts]
-  (state/set-popup!
-    {:open? true
-     :content-fn content-fn
-     :opts opts}))
+  (mobile-state/set-popup!
+   {:open? true
+    :content-fn content-fn
+    :opts opts}))
 
 (defn close-popup! []
-  (some-> state/*popup-data
-    (swap! assoc :open? false)))
+  (some-> mobile-state/*popup-data
+          (swap! assoc :open? false)))
 
 (rum/defc install-modals []
   (let [_ (r/use-atom *modals)]

+ 1 - 0
src/main/capacitor/core.cljs

@@ -1,4 +1,5 @@
 (ns capacitor.core
+  "Mobile core"
   (:require ["react-dom/client" :as rdc]
             [capacitor.components.app :as app]
             [capacitor.init :as init]

+ 2 - 0
src/main/capacitor/events.cljs

@@ -1,8 +1,10 @@
 (ns capacitor.events
+  "Mobile events"
   (:require [capacitor.init :as init]
             [frontend.handler.events :as events]
             [promesa.core :as p]))
 
+;; TODO: move more events here
 (defmethod events/handle :mobile/post-init [_]
   (p/do!
    (p/delay 1000)

+ 8 - 7
src/main/capacitor/init.cljs

@@ -4,7 +4,7 @@
             ["@capacitor/keyboard" :refer [^js Keyboard]]
             ["@capacitor/network" :refer [^js Network]]
             [capacitor.components.ui :as cc-ui]
-            [capacitor.state :as cc-state]
+            [capacitor.state :as mobile-state]
             [frontend.handler.editor :as editor-handler]
             [frontend.mobile.deeplink :as deeplink]
             [frontend.mobile.flows :as mobile-flows]
@@ -40,15 +40,15 @@
                 (fn []
                   (when (false?
                          (cond
-                ;; lightbox
-                           (and (js/document.querySelector ".pswp"))
+                           ;; lightbox
+                           (js/document.querySelector ".pswp")
                            (some-> js/window.photoLightbox (.destroy))
 
                 ;; TODO: move ui-related code to mobile events
                            (not-empty (cc-ui/get-modal))
                            (cc-ui/close-modal!)
 
-                           (not-empty @cc-state/*modal-data)
+                           (not-empty @mobile-state/*modal-data)
                            :skip
 
                            (not-empty (state/get-selection-blocks))
@@ -117,6 +117,7 @@
   []
   (.hide Keyboard))
 
-(defn keyboard-show
-  []
-  (.show Keyboard))
+(comment
+  (defn keyboard-show
+    []
+    (.show Keyboard)))

+ 26 - 21
src/main/capacitor/ionic.cljs

@@ -1,50 +1,55 @@
 (ns capacitor.ionic
+  "Ionic ui"
   (:refer-clojure :exclude [list])
-  (:require ["@capacitor/camera" :as ionicCamera]
-            [logseq.shui.icon.v2 :as shui-icon]
+  (:require [logseq.shui.icon.v2 :as shui-icon]
             [logseq.shui.util :as shui-util]))
 
 ;(def define-custom-component ionicLoader/defineCustomElements)
 (def ^js ionic-react js/window.LSIonic)
-(def ^js camera (.-Camera ionicCamera))
-(def ^js camera-result-type (.-CameraResultType ionicCamera))
-(def ^js useIonViewDidEnter (.-useIonViewDidEnter ionic-react))
-(def ^js useIonViewDidLeave (.-useIonViewDidLeave ionic-react))
-(def ^js useIonViewWillEnter (.-useIonViewWillEnter ionic-react))
-(def ^js useIonViewWillLeave (.-useIonViewWillLeave ionic-react))
 
 (def tabler-icon shui-icon/root)
 
 (defonce app (shui-util/react->rum (.-IonApp ionic-react) true))
 (defonce page (shui-util/react->rum (.-IonPage ionic-react) true))
-(defonce nav (shui-util/react->rum (.-IonNav ionic-react) true))
-(defonce nav-link (shui-util/react->rum (.-IonNavLink ionic-react) true))
+
 (defonce content (shui-util/react->rum (.-IonContent ionic-react) true))
 (defonce header (shui-util/react->rum (.-IonHeader ionic-react) true))
-(defonce back-button (shui-util/react->rum (.-IonBackButton ionic-react) false))
 (defonce buttons (shui-util/react->rum (.-IonButtons ionic-react) true))
 (defonce toolbar (shui-util/react->rum (.-IonToolbar ionic-react) true))
-(defonce loading (shui-util/react->rum (.-IonLoading ionic-react) true))
 (defonce title (shui-util/react->rum (.-IonTitle ionic-react) true))
 (defonce button (shui-util/react->rum (.-IonButton ionic-react) true))
 (defonce alert (shui-util/react->rum (.-IonAlert ionic-react) true))
-(defonce input (shui-util/react->rum (.-IonInput ionic-react) true))
-(defonce textarea (shui-util/react->rum (.-IonTextarea ionic-react) true))
-(defonce icon (shui-util/react->rum (.-IonIcon ionic-react) true))
-(defonce badge (shui-util/react->rum (.-IonBadge ionic-react) true))
 (defonce tabs (shui-util/react->rum (.-IonTabs ionic-react) false))
 (defonce tab (shui-util/react->rum (.-IonTab ionic-react) false))
 (defonce tab-bar (shui-util/react->rum (.-IonTabBar ionic-react) false))
 (defonce tab-button (shui-util/react->rum (.-IonTabButton ionic-react) false))
 (defonce modal (shui-util/react->rum (.-IonModal ionic-react) false))
-(defonce label (shui-util/react->rum (.-IonLabel ionic-react) false))
 (defonce list (shui-util/react->rum (.-IonList ionic-react) false))
 (defonce item (shui-util/react->rum (.-IonItem ionic-react) false))
-(defonce datetime (shui-util/react->rum (.-IonDatetime ionic-react) false))
-(defonce datetime-button (shui-util/react->rum (.-IonDatetimeButton ionic-react) false))
+
 (defonce refresher (shui-util/react->rum (.-IonRefresher ionic-react) false))
 (defonce refresher-content (shui-util/react->rum (.-IonRefresherContent ionic-react) false))
-(defonce menu (shui-util/react->rum (.-IonMenu ionic-react) false))
-(defonce menu-button (shui-util/react->rum (.-IonMenuButton ionic-react) false))
+
 (defonce action-sheet (shui-util/react->rum (.-IonActionSheet ionic-react) false))
 (defonce searchbar (shui-util/react->rum (.-IonSearchbar ionic-react) false))
+
+(comment
+  (def ^js camera (.-Camera ionicCamera))
+  (def ^js camera-result-type (.-CameraResultType ionicCamera))
+  (def ^js useIonViewDidEnter (.-useIonViewDidEnter ionic-react))
+  (def ^js useIonViewDidLeave (.-useIonViewDidLeave ionic-react))
+  (def ^js useIonViewWillEnter (.-useIonViewWillEnter ionic-react))
+  (def ^js useIonViewWillLeave (.-useIonViewWillLeave ionic-react))
+  (defonce nav (shui-util/react->rum (.-IonNav ionic-react) true))
+  (defonce nav-link (shui-util/react->rum (.-IonNavLink ionic-react) true))
+  (defonce back-button (shui-util/react->rum (.-IonBackButton ionic-react) false))
+  (defonce datetime (shui-util/react->rum (.-IonDatetime ionic-react) false))
+  (defonce datetime-button (shui-util/react->rum (.-IonDatetimeButton ionic-react) false))
+  (defonce menu (shui-util/react->rum (.-IonMenu ionic-react) false))
+  (defonce menu-button (shui-util/react->rum (.-IonMenuButton ionic-react) false))
+  (defonce label (shui-util/react->rum (.-IonLabel ionic-react) false))
+  (defonce input (shui-util/react->rum (.-IonInput ionic-react) true))
+  (defonce textarea (shui-util/react->rum (.-IonTextarea ionic-react) true))
+  (defonce icon (shui-util/react->rum (.-IonIcon ionic-react) true))
+  (defonce badge (shui-util/react->rum (.-IonBadge ionic-react) true))
+  (defonce loading (shui-util/react->rum (.-IonLoading ionic-react) true)))

+ 2 - 1
src/main/capacitor/state.cljs

@@ -1,4 +1,5 @@
 (ns capacitor.state
+  "Mobile state"
   (:require [frontend.rum :as r]))
 
 (defonce *tab (atom "home"))
@@ -24,4 +25,4 @@
   (reset! *popup-data data))
 
 (defn redirect-to-tab! [name]
-  (some-> @*tabs-el (.select name)))
+  (some-> @*tabs-el (.select name)))

+ 0 - 1
src/main/frontend/components/journal.cljs

@@ -6,7 +6,6 @@
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.util :as util]
-            [goog.dom :as gdom]
             [promesa.core :as p]
             [rum.core :as rum]))
 

+ 0 - 8
src/main/frontend/date.cljs

@@ -80,14 +80,6 @@
   []
   (journal-name))
 
-(defn today-forward
-  [d]
-  (journal-name (t/plus (start-of-day (tl/local-now)) (t/days d))))
-
-(defn today-backward
-  [d]
-  (journal-name (t/minus (start-of-day (tl/local-now)) (t/days d))))
-
 (defn tomorrow
   []
   (journal-name (t/plus (start-of-day (tl/local-now)) (t/days 1))))

+ 0 - 1
src/main/frontend/handler/assets.cljs

@@ -5,7 +5,6 @@
             [frontend.common.thread-api :as thread-api :refer [def-thread-api]]
             [frontend.config :as config]
             [frontend.fs :as fs]
-            [frontend.mobile.util :as mobile-util]
             [frontend.state :as state]
             [frontend.util :as util]
             [logseq.common.config :as common-config]

+ 0 - 10
src/main/frontend/handler/block.cljs

@@ -53,16 +53,6 @@
   [block]
   (get-timestamp block "Deadline"))
 
-(defn indentable?
-  [{:block/keys [parent] :as block}]
-  (when parent
-    (not= (:db/id (ldb/get-first-child (db/get-db) (:db/id parent)))
-          (:db/id block))))
-
-(defn outdentable?
-  [{:block/keys [level] :as _block}]
-  (not= level 1))
-
 (defn select-block!
   [block-uuid]
   (let [blocks (util/get-blocks-by-id block-uuid)]

+ 3 - 3
src/main/frontend/handler/events/ui.cljs

@@ -1,6 +1,7 @@
 (ns frontend.handler.events.ui
   "UI events"
-  (:require [clojure.core.async :as async]
+  (:require [capacitor.state :as mobile-state]
+            [clojure.core.async :as async]
             [clojure.core.async.interop :refer [p->c]]
             [frontend.components.cmdk.core :as cmdk]
             [frontend.components.file-sync :as file-sync]
@@ -34,7 +35,6 @@
             [frontend.mobile.util :as mobile-util]
             [frontend.modules.instrumentation.sentry :as sentry-event]
             [frontend.state :as state]
-            [capacitor.state :as cc-state]
             [frontend.ui :as ui]
             [frontend.util :as util]
             [goog.dom :as gdom]
@@ -89,7 +89,7 @@
 (defmethod events/handle :redirect-to-home [_]
   (page-handler/create-today-journal!)
   (when (util/capacitor-new?)
-    (cc-state/redirect-to-tab! "home")))
+    (mobile-state/redirect-to-tab! "home")))
 
 (defmethod events/handle :page/show-delete-dialog [[_ selected-rows ok-handler]]
   (shui/dialog-open!

+ 0 - 2
src/main/frontend/handler/repo.cljs

@@ -17,13 +17,11 @@
             [frontend.handler.route :as route-handler]
             [frontend.handler.ui :as ui-handler]
             [frontend.idb :as idb]
-            [frontend.mobile.util :as mobile-util]
             [frontend.persist-db :as persist-db]
             [frontend.search :as search]
             [frontend.state :as state]
             [frontend.undo-redo :as undo-redo]
             [frontend.util :as util]
-            [frontend.util.fs :as util-fs]
             [frontend.util.text :as text-util]
             [logseq.common.config :as common-config]
             [logseq.db.frontend.schema :as db-schema]

+ 2 - 6
src/main/frontend/mobile/camera.cljs

@@ -1,14 +1,10 @@
 (ns frontend.mobile.camera
   (:require ["@capacitor/camera" :refer [Camera CameraResultType]]
-            ["@capacitor/filesystem" :refer [Filesystem]]
-            [clojure.string :as string]
-            [frontend.commands :as commands]
             [frontend.date :as date]
             [frontend.handler.assets :as assets-handler]
+            [frontend.handler.editor :as editor-handler]
             [frontend.state :as state]
-            [frontend.util.cursor :as cursor]
             [frontend.util :as util]
-            [frontend.handler.editor :as editor-handler]
             [goog.object :as gobj]
             [lambdaisland.glogi :as log]
             [promesa.core :as p]))
@@ -34,7 +30,7 @@
                             _image-path (assets-handler/get-asset-path filename)
                             base64string (.-base64String photo)
                             file (js/File. #js [(util/base64string-to-unit8array base64string)]
-                                   filename #js {:type "image/jpeg"})]
+                                           filename #js {:type "image/jpeg"})]
                       file)))))
       (p/catch (fn [error]
                  (log/error :file/write-failed {:error error})))))

+ 0 - 8
src/main/frontend/state.cljs

@@ -1846,10 +1846,6 @@ Similar to re-frame subscriptions"
   []
   (toggle! :ui/settings-open?))
 
-(defn settings-open?
-  []
-  (:ui/settings-open? @state))
-
 (defn close-settings!
   []
   (set-state! :ui/settings-open? false))
@@ -2009,10 +2005,6 @@ Similar to re-frame subscriptions"
             (when (or (util/mobile?) (mobile-util/native-platform?))
               (set-state! :mobile/show-action-bar? false))))))))
 
-(defn action-bar-open?
-  []
-  (:mobile/show-action-bar? @state))
-
 (defn get-git-auto-commit-enabled?
   []
   (false? (sub [:electron/user-cfgs :git/disable-auto-commit?])))

+ 0 - 24
src/main/frontend/util.cljc

@@ -216,30 +216,6 @@
      []
      (gobj/get js/window "innerWidth")))
 
-;; Keep the following colors in sync with common.css
-#?(:cljs
-   (defn- get-computed-bg-color
-     []
-     ;; window.getComputedStyle(document.body, null).getPropertyValue('background-color');
-     (let [styles (js/window.getComputedStyle js/document.body)
-           bg-color (gobj/get styles "background-color")
-           ;; convert rgb(r,g,b) to #rrggbb
-           rgb2hex (fn [rgb]
-                     (->> rgb
-                          (map (comp #(.toString % 16) parse-long string/trim))
-                          (map #(if (< (count %) 2)
-                                  (str "0" %)
-                                  %))
-                          (string/join)
-                          (str "#")))]
-       (when (string/starts-with? bg-color "rgb")
-         (let [rgb (-> bg-color
-                       (string/replace #"^rgb[^\d]+" "")
-                       (string/replace #"\)$" "")
-                       (string/split #","))
-               rgb (take 3 rgb)]
-           (rgb2hex rgb))))))
-
 #?(:cljs
    (defn set-theme-light
      []

+ 0 - 12
src/main/frontend/util/fs.cljs

@@ -53,18 +53,6 @@
              (fn [^js e]
                (js/console.error "[fs read txid data error]" e))))))))
 
-(defn inflate-graphs-info
-  [graphs]
-  (if (seq graphs)
-    (p/all (for [{:keys [root] :as graph} graphs]
-             (p/let [sync-meta (read-graphs-txid-info root)]
-               (if sync-meta
-                 (assoc graph
-                        :sync-meta sync-meta
-                        :GraphUUID (second sync-meta))
-                 graph))))
-    []))
-
 (defn read-repo-file
   [repo-url file-rpath]
   (when-let [repo-dir (config/get-repo-dir repo-url)]

+ 29 - 33
src/main/frontend/util/thingatpt.cljs

@@ -1,14 +1,14 @@
 (ns ^:no-doc frontend.util.thingatpt
-  (:require [clojure.string :as string]
+  (:require [cljs.reader :as reader]
+            [clojure.string :as string]
+            [frontend.config :as config]
             [frontend.state :as state]
             [frontend.util.cursor :as cursor]
-            [frontend.config :as config]
-            [logseq.graph-parser.text :as text]
-            [logseq.graph-parser.property :as gp-property]
+            [goog.object :as gobj]
             [logseq.common.util.block-ref :as block-ref]
             [logseq.common.util.page-ref :as page-ref]
-            [cljs.reader :as reader]
-            [goog.object :as gobj]))
+            [logseq.graph-parser.property :as gp-property]
+            [logseq.graph-parser.text :as text]))
 
 (defn thing-at-point
   [bounds & [input ignore]]
@@ -17,22 +17,22 @@
         pos (cursor/pos input)
         [left right] (if (coll? bounds) bounds [bounds bounds])]
     (when-not (string/blank? content)
-     (let [start (string/last-index-of
-                  content left (if (= left right) (- pos (count left)) (dec pos)))
-           end (string/index-of
-                content right (if (= left right) pos (inc (- pos (count right)))))
-           end* (+ (count right) end)]
-       (when (and start end (not= start pos))
-         (let [thing (subs content (+ start (count left)) end)]
-           (when (every?
-                  false?
-                  (mapv #(string/includes? thing %)
-                        [left right ignore]))
-             {:full-content (subs content start end*)
-              :raw-content (subs content (+ start (count left)) end)
-              :bounds bounds
-              :start start
-              :end end*})))))))
+      (let [start (string/last-index-of
+                   content left (if (= left right) (- pos (count left)) (dec pos)))
+            end (string/index-of
+                 content right (if (= left right) pos (inc (- pos (count right)))))
+            end* (+ (count right) end)]
+        (when (and start end (not= start pos))
+          (let [thing (subs content (+ start (count left)) end)]
+            (when (every?
+                   false?
+                   (mapv #(string/includes? thing %)
+                         [left right ignore]))
+              {:full-content (subs content start end*)
+               :raw-content (subs content (+ start (count left)) end)
+               :bounds bounds
+               :start start
+               :end end*})))))))
 
 (defn line-at-point [& [input]]
   (let [input (or input (state/get-input))
@@ -61,10 +61,6 @@
            :link (text/get-page-name
                   (:full-content page-ref)))))
 
-(defn embed-macro-at-point [& [input]]
-  (when-let [macro (thing-at-point ["{{embed" "}}"] input)]
-    (assoc macro :type "macro")))
-
 ;; TODO support markdown YAML front matter
 ;; TODO support using org style properties in markdown
 (defn properties-at-point [& [input]]
@@ -116,13 +112,13 @@
 
 (defn- get-markup-at-point [& [input]]
   (let [format (state/get-preferred-format)] ;; TODO fix me to block's format
-   (or (thing-at-point (config/get-hr format) input)
-       (thing-at-point (config/get-bold format) input)
-       (thing-at-point (config/get-italic format) input)
-       (thing-at-point (config/get-underline format) input)
-       (thing-at-point (config/get-strike-through format) input)
-       (thing-at-point (config/get-highlight format) input)
-       (thing-at-point (config/get-code format) input))))
+    (or (thing-at-point (config/get-hr format) input)
+        (thing-at-point (config/get-bold format) input)
+        (thing-at-point (config/get-italic format) input)
+        (thing-at-point (config/get-underline format) input)
+        (thing-at-point (config/get-strike-through format) input)
+        (thing-at-point (config/get-highlight format) input)
+        (thing-at-point (config/get-code format) input))))
 
 (defn markup-at-point [& [input]]
   (when-let [markup (get-markup-at-point input)]

+ 2 - 3
src/main/frontend/worker/debug.cljs

@@ -1,8 +1,7 @@
 (ns frontend.worker.debug
   "For debug usage"
-  (:require [frontend.worker.state :as worker-state]
-            [logseq.db :as ldb]
-            [datascript.core :as d]))
+  (:require [datascript.core :as d]
+            [frontend.worker.state :as worker-state]))
 
 (defn get-conn
   "Get current db conn"