-
-
Notifications
You must be signed in to change notification settings - Fork 0
Allows logging an infusion with no prior record, ensures user deletion removes related infusions, and adds robust avatar initial fallback #81
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ const logTreatment = async (req: NextApiRequest, res: NextApiResponse) => { | |
|
|
||
| if (error) throw error | ||
|
|
||
| const mostRecentInfusion = infusions[0] | ||
| const mostRecentInfusion = infusions && infusions.length > 0 ? infusions[0] : null | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Sparse array causes incorrect null check for infusionsThe check |
||
|
|
||
| try { | ||
| const { infusion, error } = await postInfusionByApiKey( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: New treatments inherit cause and sites from previous treatment
The refactored code preserves
causeandsitesvalues fromlastInfusionwhen they're non-empty, whereas the original code always reset them to empty strings. When a user logs a new treatment via API, thecauseandsitesfields from their previous treatment will now carry over unless explicitly overridden bynewInfusion. Each treatment event has its own cause and injection sites, so inheriting these from a previous treatment produces incorrect data. ThebaseInfusion.cause || ''pattern keeps existing values, but the oldObject.assignwithcause: ''always cleared them.