Commit 45b785c8 authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

Updated re-frame calls to the approach used by 0.8.0

parent 8a097464
......@@ -14,7 +14,7 @@
[khroma.tabs :as tabs]
[khroma.runtime :as runtime]
[khroma.windows :as windows]
[re-frame.core :refer [dispatch register-sub register-handler subscribe dispatch-sync]]
[re-frame.core :refer [dispatch reg-event-db subscribe dispatch-sync]]
[khroma.extension :as ext]
[khroma.browser-action :as browser]
[khroma.storage :as storage])
......@@ -113,7 +113,7 @@
;;;;-------------------------------------
(register-handler
(reg-event-db
::initialize
(fn [_]
(go
......@@ -133,7 +133,7 @@
{:app-state {}}))
(register-handler
(reg-event-db
:data-load
(fn [app-state [_ data settings]]
(let [migrated (migrations/migrate-to-latest data)
......@@ -174,7 +174,7 @@
(register-handler
(reg-event-db
:data-set
(fn [app-state [_ key item]]
(let [new-state (assoc-in app-state [:data key] item)]
......@@ -182,7 +182,7 @@
new-state)))
(register-handler
(reg-event-db
:delete-url
(fn [app-state [_ url]]
(let [data (:data app-state)
......@@ -199,7 +199,7 @@
(assoc app-state :data new-data))))
(register-handler
(reg-event-db
:handle-activation
(fn [app-state [_ tab start-time]]
; (console/trace "Handling activation" tab)
......@@ -213,7 +213,7 @@
app-state)))
(register-handler
(reg-event-db
:handle-deactivation
(fn
;; We get two parameters: the tab, and optionally the time at which it
......@@ -226,7 +226,7 @@
app-state))
(register-handler
(reg-event-db
:idle-state-change
(fn [app-state [_ message]]
(let [state (:newState message)
......@@ -251,7 +251,7 @@
(register-handler
(reg-event-db
::on-alarm
(fn [app-state [_ {:keys [alarm]}]]
(when (= window-alarm (:name alarm))
......@@ -259,7 +259,7 @@
app-state))
(register-handler
(reg-event-db
::on-clicked-button
(fn [app-state [_ {:keys [tab]}]]
;; Force it to track the time up until now
......@@ -270,14 +270,14 @@
app-state))
(register-handler
(reg-event-db
::on-clicked-menu
(fn [app-state [_ {:keys [info tab]}]]
(dispatch [(keyword (:menuItemId info)) tab])
app-state))
(register-handler
(reg-event-db
::on-message
(fn [app-state [_ payload]]
(let [{:keys [message sender]} (keywordize-keys payload)
......@@ -293,21 +293,21 @@
(register-handler
(reg-event-db
:on-relevance-show-data
(fn [app-state [_]]
(open-results-tab)
app-state))
(register-handler
(reg-event-db
:on-relevance-sort-tabs
(fn [app-state [_ tab]]
(sort-tabs! (:windowId tab) app-state)
app-state))
(register-handler
(reg-event-db
:suspend
;; The message itself is not relevant, we only care that we are being suspended
(fn [app-state [_]]
......@@ -316,7 +316,7 @@
app-state))
(register-handler
(reg-event-db
::tab-activated
(fn [app-state [_ {:keys [activeInfo]}]]
(let [{:keys [tabId windowId]} activeInfo
......@@ -331,7 +331,7 @@
(register-handler
(reg-event-db
::tab-updated
(fn [app-state [_ {:keys [tabId tab]}]]
(let [active-tab (:active-tab app-state)
......@@ -354,7 +354,7 @@
(register-handler
(reg-event-db
:track-time
(fn [app-state [_ tab time]]
(let [data (:data app-state)
......@@ -366,7 +366,7 @@
(assoc app-state :data new-data))))
(register-handler
(reg-event-db
::window-focus
(fn [app-state [_ {:keys [windowId]}]]
; (console/trace "Current window" windowId)
......
(ns relevance.shared-handlers
(:require [khroma.log :as console]
[re-frame.core :refer [register-handler]]))
[re-frame.core :refer [reg-event-db]]))
(register-handler
(reg-event-db
:log-content
(fn [app-state [_ content]]
(console/log "Log event:" content)
......
......@@ -11,7 +11,7 @@
[khroma.runtime :as runtime]
[khroma.storage :as storage]
[reagent.core :as reagent]
[re-frame.core :refer [dispatch register-sub register-handler subscribe dispatch-sync]]
[re-frame.core :refer [dispatch reg-sub reg-event-db subscribe dispatch-sync]]
[relevance.io :as io]
[relevance.utils :as utils]
[relevance.settings :refer [default-settings]])
......@@ -27,15 +27,15 @@
(defn general-query
[db path]
(reaction (get-in @db path)))
(get-in db path))
;; Application data, will be saved
(register-sub :data general-query)
(register-sub :settings general-query)
(register-sub :raw-data general-query)
(reg-sub :data general-query)
(reg-sub :settings general-query)
(reg-sub :raw-data general-query)
;; Transient data items
(register-sub :ui-state general-query)
(register-sub :app-state general-query)
(reg-sub :ui-state general-query)
(reg-sub :app-state general-query)
;;;;----------------------------
......@@ -56,7 +56,7 @@
;;;; Handlers
;;;;----------------------------
(register-handler
(reg-event-db
:app-state-item
(fn [app-state [_ path item]]
(when (= [:ui-state :section] path)
......@@ -64,7 +64,7 @@
(assoc-in app-state path item)))
(register-handler
(reg-event-db
:data-import
(fn [app-state [_ transit-data]]
;; We actually just need to save it, since ::storage-changed takes care
......@@ -76,7 +76,7 @@
(register-handler
(reg-event-db
::initialize
(fn [_]
(go
......@@ -91,12 +91,12 @@
:site-page 0}}))
(register-handler
(reg-event-db
:modal-info-set
(fn [app-state [_ info]]
(assoc-in app-state [:ui-state :modal-info] info)))
(register-handler
(reg-event-db
:settings-parse
(fn [app-state [_ settings]]
(let [ignore-set (utils/to-string-set (:ignore-set settings))]
......@@ -105,7 +105,7 @@
app-state)))
(register-handler
(reg-event-db
:settings-set
(fn [app-state [_ settings save?]]
; (console/log "Saving" settings save?)
......@@ -117,7 +117,7 @@
(assoc app-state :settings settings)))
(register-handler
(reg-event-db
::storage-changed
(fn [app-state [_ message]]
(let [new-value (get-in message [:changes :data :newValue])
......@@ -266,8 +266,8 @@
(fn []
[:div {:class "row"}
[:p "If you wish to delete an item, hover the mouse over the listing. You'll see a "
[:i {:class "fa fa-remove"
:style {:color "red"}}]
[:i {:class "fa fa-remove"
:style {:color "red"}}]
" appear besides the last visit time. Click it to remove the row."]
[:p "Total: " @total " URLs."]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment