Skip to content

Commit

Permalink
Merge pull request #2140 from neotyk/dev/go-back-after-page-delete
Browse files Browse the repository at this point in the history
feat: Navigate back when user deletes current page
  • Loading branch information
filipesilva authored Apr 20, 2022
2 parents ca9d8f0 + 5a52db9 commit bf802ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/cljs/athens/views/app_toolbar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@
(r/atom false))
os (util/get-os)
on-left-sidebar-toggle #(rf/dispatch [:left-sidebar/toggle])
on-back #(.back js/window.history)
on-forward #(.forward js/window.history)
on-back (fn [_]
(rf/dispatch [:reporting/navigation {:source :app-toolbar
:target :back
:pane :main-pane}])
(.back js/window.history))
on-forward (fn [_]
(rf/dispatch [:reporting/navigation {:source :app-toolbar
:target :forward
:pane :main-pane}])
(.forward js/window.history))
on-daily-pages (fn [_]
(rf/dispatch [:reporting/navigation {:source :app-toolbar
:target :home
Expand Down
6 changes: 3 additions & 3 deletions src/cljs/athens/views/pages/node_page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@
;; if page being deleted is in right sidebar, remove from right sidebar
(when (contains? @(subscribe [:right-sidebar/items]) uid)
(dispatch [:right-sidebar/close-item uid]))
;; if page being deleted is open, navigate to all pages
;; if page being deleted is open, navigate to back
(when (or (= @(subscribe [:current-route/page-title]) title)
(= @(subscribe [:current-route/uid]) uid))
(rf/dispatch [:reporting/navigation {:source :page-title-delete
:target :all-pages
:target :back
:pane :main-pane}])
(router/navigate :pages))
(.back js/window.history))
;; if daily note, delete page and remove from daily notes, otherwise just delete page
(if daily-note?
(dispatch [:daily-note/delete uid title])
Expand Down

0 comments on commit bf802ec

Please sign in to comment.