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

Bugfix, show delta string with +- sign in notifications #367

Merged
merged 1 commit into from
Jan 29, 2025
Merged

Conversation

bjorkert
Copy link
Contributor

Solves #320

The ‘+’ sign was missing in notifications, fixed in this PR.

@bjorkert bjorkert requested a review from marionbarker January 28, 2025 20:32
Copy link
Collaborator

@marionbarker marionbarker left a comment

Choose a reason for hiding this comment

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

Code Review:

This fixes Issue #320
An optional change is offered for your consideration (remove the + from in front of 0 delta).
I do note that Nightscout uses +0 for their delta, so you may choose to be consistent with NS.

Tests

Test - PR as written

Observe Deltas with this PR using mg/dL, starting value of glucose was 110

110 +0
109 -1
111 +2

Test - PR with optional modification

Switch to mmol/L display. Rebuild with optional modification.
Initial value was 111 mg/dL or 6.2 mmol/L
Show 3 numbers below: mg/dL uploaded to NS, mmol/L displayed, delta displayed
Note that the delta is correct, but user may be confused by 6.2 followed by 6.4 showing delta of +0.3

116 6.4 +0.3
110 6.1 -0.3
110 6.1  0.0
109 6.0 -0.1
111 6.2 +0.1

@marionbarker
Copy link
Collaborator

I evidently did not include the optional change when I submitted my review.
Here's the diff I tested.

diff --git a/LoopFollow/Controllers/Nightscout/BGData.swift b/LoopFollow/Controllers/Nightscout/BGData.swift
index 3e0064e..ec6b3a0 100644
--- a/LoopFollow/Controllers/Nightscout/BGData.swift
+++ b/LoopFollow/Controllers/Nightscout/BGData.swift
@@ -245,7 +245,8 @@ extension MainViewController {
             // Delta handling
             if deltaBG < 0 {
                 self.latestDeltaString = Localizer.toDisplayUnits(String(deltaBG))
-
+            } else if deltaBG == 0 {
+                self.latestDeltaString = Localizer.toDisplayUnits(String(deltaBG))
             } else {
                 self.latestDeltaString = "+" + Localizer.toDisplayUnits(String(deltaBG))
             }

@bjorkert
Copy link
Contributor Author

Thanks for the review! I personally think keeping the + sign even before a 0 makes sense, as it clearly indicates that this value represents a delta. A standalone 0 could be confusing without that context.

Additionally, this aligns with how the delta is displayed within the app (on the main screen and snooze screen). Previously, only the notification behaved differently, so this change improves consistency across the app.

@bjorkert bjorkert merged commit 5260225 into dev Jan 29, 2025
@marionbarker marionbarker deleted the delta-sign branch January 30, 2025 16:24
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.

2 participants