diff --git a/src/looped_in/background.cljs b/src/looped_in/background.cljs index 087db90..526ded1 100644 --- a/src/looped_in/background.cljs +++ b/src/looped_in/background.cljs @@ -1,6 +1,5 @@ (ns looped-in.background - (:require [clojure.core.match :refer [match]] - [cljs.core.async :refer [go js/browser + (.-runtime) + (.sendMessage (clj->js {:type "objectIds" + :ids @object-ids}))) (set-badge-text! (str num-comments))))) -(defn handle-message [msg] - (match (.-type msg) - "popupOpened" (channel->promise (go @object-ids)) - x (log/error "Unknown popup message type" x))) - (defn handle-browser-action [tab] (-> js/browser (.-sidebarAction) (.open))) @@ -72,11 +70,6 @@ (.-onUpdated) (.addListener handle-tab-update)) -(-> js/browser - (.-runtime) - (.-onMessage) - (.addListener handle-message)) - (-> js/browser (.-browserAction) (.-onClicked) diff --git a/src/looped_in/sidebar.cljs b/src/looped_in/sidebar.cljs index 95f1aac..ac9c3b9 100644 --- a/src/looped_in/sidebar.cljs +++ b/src/looped_in/sidebar.cljs @@ -3,7 +3,8 @@ [goog.html.sanitizer.HtmlSanitizer :as Sanitizer] [cljs.core.async :refer [go channel]]) + [looped-in.promises :refer [promise->channel]] + [looped-in.logging :as log]) (:import (goog.ui Zippy))) (defn log [& args] @@ -62,12 +63,19 @@ (log items) (dom/append $storiesContainer $stories))) -(go (-> js/browser - (.-runtime) - (.sendMessage #js {:type "popupOpened"}) - (promise->channel) - ( ids + (hn/fetch-items) + ( js/browser + (.-runtime) + (.-onMessage) + (.addListener handle-message))