Skip to content

Commit

Permalink
fix: mealSortOrder actually filters entry types
Browse files Browse the repository at this point in the history
Fixes #66
  • Loading branch information
zanix committed Sep 3, 2024
1 parent b030694 commit 62a247b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MMM-MealieMenu.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"meal-header"
"meal-name"
"meal-description";
gap: 0 0;
gap: 0;
grid-area: meal-info;
text-align: left;
line-height: 24px;
Expand Down
6 changes: 2 additions & 4 deletions MMM-MealieMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ Module.register("MMM-MealieMenu", {
weekStartsOnMonday: this.config.weekStartsOnMonday,
currentWeek: this.config.currentWeek,
dayLimit: this.config.dayLimit,
priorDayLimit: this.config.priorDayLimit
priorDayLimit: this.config.priorDayLimit,
mealSortOrder: this.config.mealSortOrder
});
},

Expand All @@ -265,9 +266,6 @@ Module.register("MMM-MealieMenu", {
const today = moment().startOf("day");
const {mealSortOrder} = this.config;

// Filter meal types not in mealSortOrder.
meals.filter((meal) => mealSortOrder.includes(meal.entryType));

// Sort by date ascending, then by meal type order (can be user defined).
// eslint-disable-next-line id-length
meals.sort((a, b) => {
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const config = [
"max-lines-per-function": ["error", 120],
"max-lines": "off",
"max-params": "off",
"max-statements": ["error", 30],
"max-statements": ["error", 40],
"multiline-comment-style": "off",
"no-await-in-loop": "off",
"no-inline-comments": "off",
Expand Down
8 changes: 8 additions & 0 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,16 @@ module.exports = NodeHelper.create({
if (payload.groupId) {
params.append("group_id", payload.groupId);
}
if (payload.mealSortOrder && payload.mealSortOrder.length > 0) {
const mealSortOrder = payload.mealSortOrder.join("\", \"");
const entryType = `entryType in ["${mealSortOrder}"]`;
params.append("queryFilter", entryType);
}

url.search = params.toString();

Log.debug(`[${this.name}] API Mealplan query: ${url.search}`);

// Get the full list of meals from Mealie.
fetch(url, {
method: "GET",
Expand Down

0 comments on commit 62a247b

Please sign in to comment.