Skip to content

Commit

Permalink
Include campaigns in "query-sheets" results; implement :known-campaigns
Browse files Browse the repository at this point in the history
  • Loading branch information
dhleong committed Nov 17, 2018
1 parent 9ff6f93 commit 4666aba
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/cljs/wish/providers/gdrive.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,9 @@
(query-sheets [this]
(when-gapi-available
query-files
"appProperties has { key='wish-type' and value='wish-sheet' }"))
#_"appProperties has { key='wish-type' and value='wish-sheet' }"
(str "(appProperties has { key='wish-type' and value='wish-sheet' }) "
"or (appProperties has { key='wish-type' and value='wish-campaign' })")))

(register-data-source [this]
; TODO sanity checks galore
Expand Down
12 changes: 8 additions & 4 deletions src/cljs/wish/providers/gdrive/api.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,19 @@
(map
(fn [raw-file]
[(make-id :gdrive (:id raw-file))
(-> raw-file
(select-keys [:name])
(assoc :mine? (:ownedByMe raw-file)))]))))]
{:name (:name raw-file)
:mine? (:ownedByMe raw-file)
:type (-> raw-file
:appProperties
:wish-type
(subs (count "wish-"))
keyword)}]))))]

(-> js/gapi.client.drive.files
(.list #js {:q q
:pageSize page-size
:spaces "drive"
:fields "nextPageToken, files(id, name, ownedByMe)"})
:fields "nextPageToken, files(id, name, ownedByMe, appProperties)"})
(promise->chan 1 (map (fn [[err resp :as r]]
(if resp
; success!
Expand Down
2 changes: 1 addition & 1 deletion src/cljs/wish/sheets.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
:updated (.getTime (js/Date.)) ; date
:kind kind

:name sheet-name
:name campaign-name

:sources (:default-sources kind-meta)

Expand Down
21 changes: 17 additions & 4 deletions src/cljs/wish/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
:id sheet-id)))

(reg-sub
:known-sheets
::known-files
:<- [:sheets]
:<- [:my-sheets]
(fn [[sheets my-sheets] _]
Expand All @@ -164,6 +164,15 @@
(filter :name)
(sort-by :name))))

(reg-sub
:known-sheets
:<- [::known-files]
(fn [all-files _]
(->> all-files
(filter (comp (partial = :sheet)
:type))
(sort-by :name))))

(reg-sub
:filtered-known-sheets
:<- [:known-sheets]
Expand All @@ -182,9 +191,13 @@

(reg-sub
:known-campaigns
(fn [db]
; TODO
nil))
:<- [::known-files]
(fn [all-files _]
(->> all-files
(filter (comp (partial = :campaign)
:type))
(sort-by :name))))


; if a specific sheet-id is not provided, loads
; for the active sheet id
Expand Down

0 comments on commit 4666aba

Please sign in to comment.