Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 2.32 KB

2020-07-21.md

File metadata and controls

48 lines (32 loc) · 2.32 KB

Learning Clojure in Public - Week 5 Day 2 (30/35)

Expectations

I decided to rebuild my wheel from scratch (part of my decide-wheel clone). I am completely bike-shedding here, but if I can turn this into something I'll use (yes, I use the decide wheel often), it is still an interesting experience (not really, I am lying, it's CSS). Therefore I don't expect any interesting update on that (or a very beautiful wheel, who knows!).

On the other hand the expectation is to make good progress on page deletion in Athens.

What I learned

Deleting pages in Athens

There is currently a button to delete a page within the drop down on the page itself (where you can also add a page to your favorites), so the first step is to add a re-frame event handler, in events.cljs:

(reg-event-fx
 :page/delete
 (fn [_ [_ uid]]
   (js/console.log uid)
   {:transact! [[:db/retract [:block/uid uid] :block/uid]]}))

We then need to call this event handler on click on that button in the dropdown, in node_page.cljs:

-              [button {:disabled true}
+              [button {:on-click #(dispatch [:page/delete uid])}
               [:<> [:> mui-icons/Delete] [:span "Delete Page"]]]]])

Upon deleting the page, we remain on the same url hash, and the 404 message is displayed. We should instead redirect to another page, like All Pages:

-              [button {:on-click #(dispatch [:page/delete uid])}
+              [button {:on-click #(do
+                                    (navigate :pages)
+                                    (dispatch [:page/delete uid]))}

We redirect first to avoid showing the 404 and then redirecting. You can still see it, sadly, so this solution needs to be perfected.

The team then had a call, to try to write an algorithm to recursively delete pages. We decided a breath first search was probably the best idea. I will sleep on that and learn more about loop and recur tomorrow to and write the recursive solution.

The wheel

Regarding the wheel, most of the progress is with the CSS, it does look much better right now, but not very interesting in relations to Clojure, so here is just a picture for now: