Commit 68c99cc8 authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

Implemented removing individual items from the history
parent d6d77a14
......@@ -43,9 +43,7 @@
:optimizations :whitespace
:pretty-print true}}
:chromebuild {:resource-paths ["resources/js"
......@@ -15,6 +15,7 @@
<!-- Light Bootstrap Table core CSS -->
<link href="light-bootstrap-dashboard.css" rel="stylesheet"/>
<link href="relevance.css" rel="stylesheet"/>
<!-- Fonts and icons -->
<link href="" rel="stylesheet">
.has_on_hover span.show_on_hover {
visibility: hidden;
.has_on_hover:hover span.show_on_hover {
visibility: visible;
\ No newline at end of file
(ns relevance.background
(:require [cljs.core.async :refer [>! <!]]
[clojure.walk :refer [keywordize-keys]]
[ :as data]
[ :as io]
[relevance.migrations :as migrations]
......@@ -37,6 +38,16 @@
;;;; Functions
(defn accumulate-preserve-icons
"Accumulates all site times from url-times while preserving the
icons stored on site-data"
[url-times site-data]
;; Accumulate site times but preserve the icons we had before
(data/accumulate-site-times url-times)
(map #(vector (key %)
(assoc (val %) :icon (get-in site-data [(key %) :icon]))))
(into {})))
(defn check-window-status
"Checks if we have any focused window, and compares it against the
......@@ -84,7 +95,6 @@
(tabs/create {:url ext-url})))))
(defn time-score [tab url-times site-times]
(let [url (:url tab)
idx (:index tab)
......@@ -148,12 +158,7 @@
(data/clean-up-ignored ignore-set))
site-data (:site-times migrated)
new-sites (if (not= new-urls (:url-times migrated))
;; Accumulate site times but preserve the icons we had before
(data/accumulate-site-times new-urls)
(map #(vector (key %)
(assoc (val %) :icon (get-in site-data [(key %) :icon]))))
(into {}))
(accumulate-preserve-icons new-urls site-data)
new-data (assoc migrated :url-times new-urls :site-times new-sites)]
; (console/trace "Data load" data "migrated" new-data)
......@@ -185,6 +190,23 @@
(fn [app-state [_ url]]
(let [data (:data app-state)
old-times (:url-times data)
new-times (dissoc old-times (url-key url))
changed? (not= old-times new-times)
new-data (if changed?
(assoc data :url-times new-times
:site-times (accumulate-preserve-icons new-times (:site-times data)))
(when changed?
(io/save :data new-data))
(assoc app-state :data new-data)
(fn [app-state [_ tab start-time]]
......@@ -265,10 +287,16 @@
(fn [app-state [_ {:keys [message sender]}]]
; (console/log "GOT INTERNAL MESSAGE" message "from" sender)
(condp = (keyword message)
:reload-data (go (dispatch [:data-load (<! (io/load :data)) (<! (io/load :settings))])))
(fn [app-state [_ payload]]
(let [{:keys [message sender]} (keywordize-keys payload)
{:keys [action data]} message]
; (console/log "GOT INTERNAL MESSAGE" message "from" sender)
(condp = (keyword action)
:reload-data (go (dispatch [:data-load (<! (io/load :data)) (<! (io/load :settings))]))
:delete-url (dispatch [:delete-url data])
(console/error "Nothing matched" message)
......@@ -59,8 +59,7 @@
(fn [app-state [_ path item]]
(when (= [:ui-state :section] path)
(js/ga "send" "screenview" #js {:screenName (name item)})
#_(js/ga "send" "screenview" #js {:screenName (name item)}))
(assoc-in app-state path item)))
......@@ -69,7 +68,7 @@
(fn [app-state [_ transit-data]]
;; We actually just need to save it, since ::storage-changed takes care
;; of loading it and importing it.
(io/save-raw :data transit-data #(runtime/send-message :reload-data))
(io/save-raw :data transit-data #(runtime/send-message {:action :reload-data}))
(-> app-state
(assoc-in [:ui-state :section] :url-times)
(assoc-in [:app-state :import] nil))
......@@ -111,7 +110,7 @@
(when save?
;; We tell the backend to reload the data after saving the settings, since
;; they can have an effect on behavior.
(io/save :settings settings #(runtime/send-message :reload-data))
(io/save :settings settings #(runtime/send-message {:action :reload-data}))
(dispatch [:app-state-item [:ui-state :section] :url-times])
(assoc app-state :settings settings)))
......@@ -228,7 +227,7 @@
^{:key i}
[:tr {:class "has_on_hover"}
[:td {:class "col-sm-1"}
(time-display (:time tab))]
[:td {:class "col-sm-9"}
......@@ -240,8 +239,13 @@
:height 16}])
[:td {:class "col-sm-2"}
[:i (merge {:class "fa fa-circle" :style {:color color}})]
(time-display (quot age-ms 1000))]
[:i {:class "fa fa-circle" :style {:color color}}]
(time-display (quot age-ms 1000))
[:span {:class "show_on_hover" :style {:text-align "right"}}
[:i {:class "fa fa-remove"
:style {:color "red"}
:on-click #(runtime/send-message {:action :delete-url
:data url})}]]]
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