From 0ebbc71d5c6c1c52edb00be19501f1c9421a5667 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Thu, 16 Jun 2022 19:30:00 +0100 Subject: [PATCH] Continuing with salvage There appears to be bitrot in the JavaScript dependencies; specifically in how secretary is doing routing. I have NOT got to the bottom of this. --- README.md | 7 ++++--- project.clj | 13 +++++++----- resources/templates/app.html | 6 +++++- src/cljs/youyesyet/canvasser_app/core.cljs | 23 +++++++++++++++------- src/cljs/youyesyet/canvasser_app/gis.cljs | 5 +++-- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c37d944..bf96b96 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,10 @@ Consequently, to get a build running: 1. clone the repository, if you have not already done so; 2. within your cloned repository, check out a branch (usually `develop` or `master`); 3. if you have previously built the project within your cloned repository, run `lein clean`; -4. **this is the important bit** run `lein adl` to generate much of the application code; -5. run `lein run` to start your development server; -6. if you want to do client debugging, you'll want to run `figwheel` in a separate process, but also from the same cloned repository directory; I normally do this by opening a second terminal and invoking `lein figwheel`. +4. run `lein npm install`; +5. **this is the important bit** run `lein adl` to generate much of the application code; +6. run `lein run` to start your development server; +7. if you want to do client debugging, you'll want to run `figwheel` in a separate process, but also from the same cloned repository directory; I normally do this by opening a second terminal and invoking `lein figwheel`. ## Further Reading diff --git a/project.clj b/project.clj index d167d19..3325240 100644 --- a/project.clj +++ b/project.clj @@ -16,6 +16,8 @@ ;; [cljsjs/react-leaflet "1.6.5-0"] ;; [cljsjs/react-leaflet "2.4.0-0"] is available but doesn't seem to work fully [cljsjs/leaflet "1.5.1-0"] ;; leaflet-reagent-reframe uses this and it works with Firefox! + [cljsjs/react "16.11.0-0"] + [cljsjs/react-dom "16.11.0-0"] [cljs-ajax "0.8.0"] [com.andrewmcveigh/cljs-time "0.5.2"] [clojure.java-time "0.3.2"] @@ -46,15 +48,15 @@ [org.webjars/font-awesome "5.11.2"] [org.webjars.bower/tether "1.4.4"] [postgre-types "0.0.4"] - [re-frame "0.10.9"] - [reagent "0.8.1"] - [reagent-utils "0.3.3"] + [re-frame "1.2.0"] + [reagent "1.1.1"] + [reagent-utils "0.3.4"] [recalcitrant "0.1.2"] [ring-middleware-format "0.7.4"] [ring/ring-defaults "0.3.2"] [ring/ring-servlet "1.7.1"] [ring-webjars "0.2.0"] - [secretary "1.2.3"] + [clj-commons/secretary "1.2.4"] [selmer "1.12.40"]] :deploy-repositories [["releases" :clojars] @@ -95,7 +97,8 @@ :npm {:dependencies [[datatables.net "1.10.19"] [datatables.net-dt "1.10.19"] [jquery "3.3.1"] - [leaflet "1.3.1"] + ;; [leaflet "1.3.1"] + ;; [react "18.2.0"] [selectize "0.12.6"] [signature_pad "2.3.2"] [simplemde "1.11.2"]] diff --git a/resources/templates/app.html b/resources/templates/app.html index 9c2220f..0b45f02 100644 --- a/resources/templates/app.html +++ b/resources/templates/app.html @@ -44,7 +44,11 @@ - + + + + + diff --git a/src/cljs/youyesyet/canvasser_app/core.cljs b/src/cljs/youyesyet/canvasser_app/core.cljs index 9bf9252..8672d3f 100644 --- a/src/cljs/youyesyet/canvasser_app/core.cljs +++ b/src/cljs/youyesyet/canvasser_app/core.cljs @@ -198,14 +198,22 @@ ;; History ;; must be called after routes have been defined (defn hook-browser-navigation! - "Interceptor for the browser back button." - [] - (doto (History.) + "Interceptor for the browser back button." + [] + (try + (js/console.log "Entering `hook-browser-navigation!`") + (doto (History.) (events/listen - HistoryEventType/NAVIGATE - (fn [event] - (secretary/dispatch! (.-token event)))) - (.setEnabled true))) + HistoryEventType/NAVIGATE + (fn [event] + (js/console.log "Entering anonymous history update handler") + (try + (secretary/dispatch! (.-token event)) + (catch js/Error e (js/console.warn e))) + (js/console.log "Exiting anonymous history update handler"))) + (.setEnabled true)) + (catch js/Error e (js/console.warn e))) + (js/console.log "Exiting `hook-browser-navigation!`")) ;; ------------------------- ;; Initialize app @@ -224,6 +232,7 @@ (rf/dispatch [:fetch-followupmethods]) ;; (rf/dispatch [:dispatch-later [{:ms 60000 :dispatch [:process-queue]}]]) (load-interceptors!) + ;; TEMP: the browser navigation hook is breaking the loading of the building page, and I don't at this moment understand why. (hook-browser-navigation!) (mount-components)) diff --git a/src/cljs/youyesyet/canvasser_app/gis.cljs b/src/cljs/youyesyet/canvasser_app/gis.cljs index 48defe2..f82dcb0 100644 --- a/src/cljs/youyesyet/canvasser_app/gis.cljs +++ b/src/cljs/youyesyet/canvasser_app/gis.cljs @@ -99,8 +99,9 @@ ;; (dispatch [:set-zoom (.getZoom view)]) ;; (dispatch [:set-latitude (.-lat centre)]) ;; (dispatch [:set-longitude (.-lng centre)])) - (js/console.log (str "Navigating to " "#building/" id)) - (set! window.location.href (str "#building/" id)) + (js/console.log (str "Navigating to " "#/building/" id)) + ;; (set! window.location.href (str "#/building/" id)) + (dispatch [:set-address 262]) )