Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: yield not set calculation error #2099

Merged
merged 3 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
[#2015](https://github.com/nextcloud/cookbook/pull/2015) @seyfeb
- Prevent recalculation algorithm if no yield is given
[#2003](https://github.com/nextcloud/cookbook/pull/2003) @j0hannesr0th
- Fix yield not set calculation error
[#2099](https://github.com/nextcloud/cookbook/pull/2099) @j0hannesr0th

### Documentation
- Improve structure of `README.md`
Expand Down
2 changes: 1 addition & 1 deletion src/components/RecipeView/RecipeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<span class="icon-error" />
{{
// prettier-ignore
t("cookbook", "The ingredient cannot be recalculated due to incorrect syntax. Please change it to this syntax: amount unit ingredient. Examples: 200 g carrots or 1 pinch of salt")
t("cookbook", "The ingredient cannot be recalculated due to incorrect syntax. Please ensure the syntax follows this format: amount unit ingredient and that a specific number of portions is set for this function to work correctly. Examples: 200 g carrots or 1 pinch of salt.")
}}
</div>
</section>
Expand Down
4 changes: 4 additions & 0 deletions src/js/yieldCalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ function recalculateIngredients(ingredients, currentYield, originalYield) {
return ingredient;
}

if (!Number.isInteger(originalYield) || originalYield < 1) {
return ingredient;
}

const matches = ingredient.match(fractionRegExp);

if (matches) {
Expand Down
Loading