summaryrefslogtreecommitdiff
path: root/internal/models
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-02-05 10:43:19 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-02-05 10:43:19 -1000
commit1eab4d59454fa5999675d51b99e77ac6580aba95 (patch)
tree6b653e39d33fd879f29f769cdf3bd3f6bfcd3f05 /internal/models
parent5ddb419137b814481a208d1dd0d18ac36ed554ea (diff)
Improve session handling, shopping UI, and cleanup
Session improvements: - Extend session lifetime to 7 days for mobile convenience - Add idle timeout to extend session on activity - Use standard cookie name for better compatibility Shopping model: - Add FlattenItemsForStore helper for extracting store items - Add StoreNames helper for store list - Improve shopping-tab.html with inline add forms Frontend: - Add WebSocket reconnection and agent approval UI to app.js - Simplify timeline calendar JS (move event positioning to CSS) - Update login page styling Deployment: - Remove unused git checkout step from deploy.sh - Update apache.conf WebSocket proxy settings Documentation: - Add Agent Context API feature spec to issues/ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/models')
-rw-r--r--internal/models/types.go35
1 files changed, 34 insertions, 1 deletions
diff --git a/internal/models/types.go b/internal/models/types.go
index ab06ea2..8ec2095 100644
--- a/internal/models/types.go
+++ b/internal/models/types.go
@@ -1,6 +1,10 @@
package models
-import "time"
+import (
+ "sort"
+ "strings"
+ "time"
+)
// Task represents a task from Todoist
type Task struct {
@@ -60,6 +64,35 @@ type ShoppingCategory struct {
Items []UnifiedShoppingItem
}
+// FlattenItemsForStore extracts all items for a specific store, sorted by checked status then name
+func FlattenItemsForStore(stores []ShoppingStore, storeName string) []UnifiedShoppingItem {
+ var items []UnifiedShoppingItem
+ for _, store := range stores {
+ if strings.EqualFold(store.Name, storeName) {
+ for _, cat := range store.Categories {
+ items = append(items, cat.Items...)
+ }
+ }
+ }
+ // Sort: unchecked first, then by name
+ sort.Slice(items, func(i, j int) bool {
+ if items[i].Checked != items[j].Checked {
+ return !items[i].Checked
+ }
+ return items[i].Name < items[j].Name
+ })
+ return items
+}
+
+// StoreNames returns the names of all stores
+func StoreNames(stores []ShoppingStore) []string {
+ names := make([]string, len(stores))
+ for i, store := range stores {
+ names[i] = store.Name
+ }
+ return names
+}
+
// List represents a Trello list
type List struct {
ID string `json:"id"`