Skip to content

🐛 fix: sort homepage meal plan entries by meal type start time - #4670

Open
MichaelvanLaar wants to merge 2 commits into
TandoorRecipes:developfrom
MichaelvanLaar:upstream/meal-plan-sort-order-on-homepage
Open

🐛 fix: sort homepage meal plan entries by meal type start time#4670
MichaelvanLaar wants to merge 2 commits into
TandoorRecipes:developfrom
MichaelvanLaar:upstream/meal-plan-sort-order-on-homepage

Conversation

@MichaelvanLaar

Copy link
Copy Markdown

What does this PR do?

The meal planner widget on the home page was displaying meals in creation order (the insertion order of the internal store map), rather than by the meal type starting time configured in Settings → Meal Plan.

The calendar view already shows meals in the correct order because vue-simple-calendar sorts calendar items by startDate, and the backend serializer (_apply_default_time) bakes mealType.time into fromDate at save time. The home page widget had no equivalent sorting.

Changes

vue3/src/components/display/HorizontalMealPlanWindow.vue

Added a .sort() after the .filter() in the meal_plan_grid computed property. Entries are sorted by:

  1. mealType.time (primary) — the starting time set in meal plan settings, stored as "HH:MM:SS" and sortable lexicographically
  2. mealType.order (secondary) — tiebreaker for meal types sharing the same time or without a time configured

Meal types with no time configured sort last.

How to test

  1. Create two or more meal types with different starting times in Settings → Meal Plan (e.g. Breakfast at 08:00, Lunch at 12:00, Dinner at 18:00).
  2. Add meal plan entries for today in non-chronological order (e.g. add Dinner first, then Breakfast).
  3. Open the home page — the meal planner widget should now show entries in meal type time order (Breakfast → Lunch → Dinner), matching the calendar view.

The homepage meal planner window was displaying meals in creation order
(insertion order of the store's Map) instead of by the meal type starting
time configured in settings, unlike the calendar view which sorts
implicitly via vue-simple-calendar's startDate ordering.

Adds a sort on mealType.time (primary) and mealType.order (secondary) to
the plan_entries filter in HorizontalMealPlanWindow.vue.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 9, 2026 22:27
@CLAassistant

CLAassistant commented May 9, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the home page meal planner widget ordering so that meal plan entries display in configured meal-type start-time order (instead of insertion/creation order), aligning the widget with the calendar view behavior.

Changes:

  • Sorts meal_plan_grid entries by mealType.time (primary) and mealType.order (secondary), with missing times placed last.
  • Applies consistent formatting updates in HorizontalMealPlanWindow.vue (template/script/style).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +123 to +125
const timeA = a.mealType?.time ?? "￿"
const timeB = b.mealType?.time ?? "￿"
if (timeA !== timeB) return timeA < timeB ? -1 : 1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented the fix suggested by Copilot: replaced the U+FFFF sentinel with explicit null-checks so entries without a mealType.time always sort to the end. See commit 2d73aca.

…n sort

Replace the U+FFFF sentinel character ("ï¿¿") used as a fallback for
missing mealType.time with explicit null-checks. Entries without a time
sort to the end; entries with a time sort lexicographically (correct for
"HH:MM:SS" fixed-format strings).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants