Skip to content

Commit

Permalink
Merge pull request #545 from aug0211/big-fix-false-0-bg-delta
Browse files Browse the repository at this point in the history
Bug fix for false +0 (or +0.0 mmol) bg deltas
  • Loading branch information
paulplant authored Sep 25, 2024
2 parents a06623b + cbd6f88 commit 74248cd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions xDrip Watch App/DataModels/WatchStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ final class WatchStateModel: NSObject, ObservableObject {
// quickly check "value" and prevent "-0mg/dl" or "-0.0mmol/l" being displayed
// show unitized zero deltas as +0 or +0.0 as per Nightscout format
if (isMgDl) {
if (deltaChangeInMgDl > -1) && (deltaChangeInMgDl < 1) {
if (deltaChangeInMgDl == 0) {
return "+0"
} else {
return deltaSign + valueAsString
}
} else {
if (deltaChangeInMgDl > -0.1) && (deltaChangeInMgDl < 0.1) {
if (deltaChangeInMgDl == 0.0) {
return "+0.0"
} else {
return deltaSign + valueAsString
Expand Down
4 changes: 2 additions & 2 deletions xDrip Watch Complication/XDripWatchComplication+Entry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ extension XDripWatchComplication.Entry {
// quickly check "value" and prevent "-0mg/dl" or "-0.0mmol/l" being displayed
// show unitized zero deltas as +0 or +0.0 as per Nightscout format
if (isMgDl) {
return (deltaChangeInMgDl > -1 && deltaChangeInMgDl < 1) ? "+0" : (deltaSign + valueAsString)
return (deltaChangeInMgDl == 0) ? "+0" : (deltaSign + valueAsString)
} else {
return (deltaChangeInMgDl > -0.1 && deltaChangeInMgDl < 0.1) ? "+0.0" : (deltaSign + valueAsString)
return (deltaChangeInMgDl == 0.0) ? "+0.0" : (deltaSign + valueAsString)
}
}
return ""
Expand Down
4 changes: 2 additions & 2 deletions xDrip Widget/DataModels/XDripWidgetAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ struct XDripWidgetAttributes: ActivityAttributes {
// quickly check "value" and prevent "-0mg/dl" or "-0.0mmol/l" being displayed
// show unitized zero deltas as +0 or +0.0 as per Nightscout format
if (isMgDl) {
return (deltaChangeInMgDl > -1 && deltaChangeInMgDl < 1) ? "+0" : (deltaSign + valueAsString)
return (deltaChangeInMgDl == 0) ? "+0" : (deltaSign + valueAsString)
} else {
return (deltaChangeInMgDl > -0.1 && deltaChangeInMgDl < 0.1) ? "+0.0" : (deltaSign + valueAsString)
return (deltaChangeInMgDl == 0.0) ? "+0.0" : (deltaSign + valueAsString)
}
} else {
return isMgDl ? "-" : "-.-"
Expand Down
4 changes: 2 additions & 2 deletions xDrip Widget/XDripWidget+Entry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ extension XDripWidget.Entry {
// quickly check "value" and prevent "-0mg/dl" or "-0.0mmol/l" being displayed
// show unitized zero deltas as +0 or +0.0 as per Nightscout format
if (isMgDl) {
return (deltaChangeInMgDl > -1 && deltaChangeInMgDl < 1) ? "+0" : (deltaSign + valueAsString)
return (deltaChangeInMgDl == 0) ? "+0" : (deltaSign + valueAsString)
} else {
return (deltaChangeInMgDl > -0.1 && deltaChangeInMgDl < 0.1) ? "+0.0" : (deltaSign + valueAsString)
return (deltaChangeInMgDl == 0.0) ? "+0.0" : (deltaSign + valueAsString)
}
} else {
return isMgDl ? "-" : "-.-"
Expand Down
4 changes: 2 additions & 2 deletions xdrip/Core Data/classes/BgReading+CoreDataClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ public class BgReading: NSManagedObject {
// quickly check "value" and prevent "-0mg/dl" or "-0.0mmol/l" being displayed
// show unitized zero deltas as +0 or +0.0 as per Nightscout format
if (mgdl) {
if (value > -1) && (value < 1) {
if (value == 0) {
return "+0" + (showUnit ? (" " + Texts_Common.mgdl):"");
} else {
return deltaSign + valueAsString + (showUnit ? (" " + Texts_Common.mgdl):"");
}
} else {
if (value > -0.1) && (value < 0.1) {
if (value == 0.0) {
return "+0.0" + (showUnit ? (" " + Texts_Common.mmol):"");
} else {
return deltaSign + valueAsString + (showUnit ? (" " + Texts_Common.mmol):"");
Expand Down

0 comments on commit 74248cd

Please sign in to comment.