Journal UI: write and read season notes where you're already looking (#53) (#67)
Build image / build-and-push (push) Successful in 11s
Build image / build-and-push (push) Successful in 11s
Co-authored-by: Steve Dudenhoeffer <[email protected]>
This commit was merged in pull request #67.
This commit is contained in:
@@ -71,6 +71,27 @@ func (h *handlers) listJournal(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, journalResponse{Entries: entries, HasMore: hasMore})
|
||||
}
|
||||
|
||||
// getJournalCounts powers the "there are notes about this bed" indicator, which
|
||||
// has to work while the journal panel is closed — exactly when nothing else has
|
||||
// loaded the entries. Key "0" is the garden itself.
|
||||
func (h *handlers) getJournalCounts(c *gin.Context) {
|
||||
gardenID, ok := parseIDParam(c, "id")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
counts, err := h.svc.JournalCounts(c.Request.Context(), mustActor(c).ID, gardenID)
|
||||
if err != nil {
|
||||
writeServiceError(c, err)
|
||||
return
|
||||
}
|
||||
// JSON object keys are strings; the client parses them back to ids.
|
||||
out := make(map[string]int, len(counts))
|
||||
for id, n := range counts {
|
||||
out[strconv.FormatInt(id, 10)] = n
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"counts": out})
|
||||
}
|
||||
|
||||
func (h *handlers) createJournalEntry(c *gin.Context) {
|
||||
gardenID, ok := parseIDParam(c, "id")
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user