Switch repo should re-render multiple pages

pull/645/head
Tienson Qin 2020-05-10 21:15:13 +08:00
parent 6b5e42d762
commit 3c50444b8f
4 changed files with 24 additions and 22 deletions

View File

@ -1,21 +1,21 @@
(ns frontend.components.agenda
(:require [rum.core :as rum]
[frontend.format.block :as block]
[clojure.string :as string]
[frontend.components.sidebar :as sidebar]
[frontend.components.content :as content]
[frontend.components.hiccup :as hiccup]
[frontend.state :as state]
[frontend.db :as db]))
(rum/defc agenda < rum/reactive
[]
(let [tasks (db/get-agenda)]
[:div#agenda
[:h1.title "Agenda"]
[:div#agenda
[:h1.title "Agenda"]
(let [current-repo (state/sub :git/current-repo)
tasks (db/get-agenda current-repo)]
(if (seq tasks)
[:div.ml-1
(let [tasks (block/sort-tasks tasks)
id "agenda"]
(content/content id :org
{:hiccup (hiccup/->hiccup tasks {:id id})}))]
"Empty")]))
"Empty"))])

View File

@ -24,12 +24,13 @@
[:div.flex-1
[:h1.title
"All files"]
(let [files (db/get-files (state/get-current-repo))]
(for [file files]
(let [file-id (util/url-encode file)]
[:div {:key file-id}
[:a {:href (str "/file/" file-id)}
file]])))])
(when-let [current-repo (state/sub :git/current-repo)]
(let [files (db/get-files current-repo)]
(for [file files]
(let [file-id (util/url-encode file)]
[:div {:key file-id}
[:a {:href (str "/file/" file-id)}
file]]))))])
(rum/defcs file < rum/reactive
[state]

View File

@ -72,9 +72,10 @@
[:div.flex-1
[:h1.title
"All Pages"]
(let [pages (db/get-pages (state/get-current-repo))]
(for [page pages]
(let [page-id (util/url-encode page)]
[:div {:key page-id}
[:a {:href (str "/page/" page-id)}
page]])))])
(when-let [current-repo (state/sub :git/current-repo)]
(let [pages (db/get-pages current-repo)]
(for [page pages]
(let [page-id (util/url-encode page)]
[:div {:key page-id}
[:a {:href (str "/page/" page-id)}
page]]))))])

View File

@ -560,9 +560,9 @@
;; time duration
;; TODO: posh doesn't support or query
(defn get-agenda
([]
(get-agenda :week))
([time]
([repo]
(get-agenda (state/get-current-repo) :week))
([repo time]
;; TODO:
(let [duration (case time
:today []
@ -576,7 +576,7 @@
:where
[?h :heading/marker ?marker]
[(?pred $ ?marker)]]
(get-conn (state/get-current-repo) false)
(get-conn repo false)
pred)
react
seq-flatten