mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: navigate back to previous route after deleting a page
This commit is contained in:
@@ -139,10 +139,12 @@
|
||||
(page-handler/<create! page-name opts)))
|
||||
|
||||
(defmethod handle :page/deleted [[_ repo page-name file-path tx-meta]]
|
||||
(page-common-handler/after-page-deleted! repo page-name file-path tx-meta))
|
||||
(when-not (util/mobile?)
|
||||
(page-common-handler/after-page-deleted! repo page-name file-path tx-meta)))
|
||||
|
||||
(defmethod handle :page/renamed [[_ repo data]]
|
||||
(page-common-handler/after-page-renamed! repo data))
|
||||
(when-not (util/mobile?)
|
||||
(page-common-handler/after-page-renamed! repo data)))
|
||||
|
||||
(defmethod handle :page/create-today-journal [[_ _repo]]
|
||||
(p/let [_ (page-handler/create-today-journal!)]
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
(let [ids (map (fn [id] (:db/id (db/entity [:block/uuid id]))) deleted-block-uuids)]
|
||||
(state/sidebar-remove-deleted-block! ids))
|
||||
(when-let [block-id (state/get-current-page)]
|
||||
(when (contains? (set (map str deleted-block-uuids)) block-id)
|
||||
(when (and (contains? (set (map str deleted-block-uuids)) block-id)
|
||||
(not (util/mobile?)))
|
||||
(let [parent (:block/parent (ldb/get-page (db/get-db) block-id))]
|
||||
(if parent
|
||||
(route-handler/redirect-to-page! (:block/uuid parent))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns mobile.components.header
|
||||
"App top header"
|
||||
(:require [clojure.string :as string]
|
||||
(:require ["@capacitor/dialog" :refer [Dialog]]
|
||||
[clojure.string :as string]
|
||||
[frontend.common.missionary :as c.m]
|
||||
[frontend.components.repo :as repo]
|
||||
[frontend.components.rtc.indicator :as rtc-indicator]
|
||||
@@ -132,22 +133,27 @@
|
||||
"Copy"])
|
||||
|
||||
(ui/menu-link
|
||||
{:on-click #(-> (shui/dialog-confirm!
|
||||
(str "⚠️ Are you sure you want to delete this "
|
||||
(if (entity-util/page? block) "page" "block")
|
||||
"?"))
|
||||
(p/then
|
||||
{:on-click
|
||||
(fn []
|
||||
(p/do!
|
||||
(shui/popup-hide!)
|
||||
(-> (.confirm ^js Dialog
|
||||
#js {:title "Confirm"
|
||||
:message (str "Are you sure to delete this "
|
||||
(if (entity-util/page? block) "page" "block")
|
||||
"?")})
|
||||
(p/then
|
||||
(fn [^js result]
|
||||
(let [value (.-value result)]
|
||||
(when value
|
||||
(some->
|
||||
(:block/uuid block)
|
||||
(page-handler/<delete!
|
||||
(fn []
|
||||
(shui/popup-hide!)
|
||||
(some->
|
||||
(:block/uuid block)
|
||||
(page-handler/<delete!
|
||||
(fn []
|
||||
;; FIXME: empty screen, wrong route state
|
||||
(mobile-state/set-tab! "home"))
|
||||
{:error-handler
|
||||
(fn [{:keys [msg]}]
|
||||
(notification/show! msg :warning))})))))}
|
||||
(js/history.back))
|
||||
{:error-handler
|
||||
(fn [{:keys [msg]}]
|
||||
(notification/show! msg :warning))})))))))))}
|
||||
[:span.text-lg.flex.gap-2.items-center.text-red-700
|
||||
(shui/tabler-icon "trash" {:class "opacity-80" :size 22})
|
||||
"Delete"])])
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
[mobile.events]
|
||||
[mobile.init :as init]
|
||||
[mobile.navigation :as mobile-nav]
|
||||
[mobile.routes :refer [routes]]
|
||||
[mobile.routes :refer [routes] :as mobile-routes]
|
||||
[mobile.state :as mobile-state]
|
||||
[promesa.core :as p]
|
||||
[reitit.frontend :as rf]
|
||||
[reitit.frontend.easy :as rfe]))
|
||||
|
||||
|
||||
@@ -40,9 +40,8 @@
|
||||
route (assoc :route route)
|
||||
(or path (.-hash js/location))
|
||||
(assoc :path (strip-fragment (or path (.-hash js/location))))))]
|
||||
(when-not (= nav-type "pop")
|
||||
(-> (.routeDidChange mobile-util/ui-local payload)
|
||||
(p/catch (fn [err]
|
||||
(log/warn :mobile-native-navigation/route-report-failed
|
||||
{:error err
|
||||
:payload payload}))))))))
|
||||
(-> (.routeDidChange mobile-util/ui-local payload)
|
||||
(p/catch (fn [err]
|
||||
(log/warn :mobile-native-navigation/route-report-failed
|
||||
{:error err
|
||||
:payload payload})))))))
|
||||
|
||||
Reference in New Issue
Block a user