Răsfoiți Sursa

fix: error or notify loudly if db transactions aren't being transacted

followup to
https://github.com/logseq/logseq/pull/10726#discussion_r1431990823
Gabriel Horner 1 an în urmă
părinte
comite
0fc1fd0f15

+ 3 - 2
deps/db/src/logseq/db/sqlite/db.cljs

@@ -104,5 +104,6 @@
 
 (defn transact!
   [repo tx-data tx-meta]
-  (when-let [conn (get-conn repo)]
-    (d/transact! conn tx-data tx-meta)))
+  (if-let [conn (get-conn repo)]
+    (d/transact! conn tx-data tx-meta)
+    (throw (ex-info (str "Failed to transact! No db connection found for " repo) {}))))

+ 3 - 1
src/main/frontend/persist_db/browser.cljs

@@ -82,7 +82,9 @@
           tx-meta' (pr-str tx-meta)]
       (p/do!
        (ipc/ipc :db-transact repo tx-data' tx-meta')
-       (when sqlite (.transact sqlite repo tx-data' tx-meta'))
+       (if sqlite
+         (.transact sqlite repo tx-data' tx-meta')
+         (notification/show! "Latest change was not saved! Please restart the application." :error))
        nil)))
 
   (<fetch-initial-data [_this repo _opts]