Skip to content

Commit

Permalink
Merge dev into main #536
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-b-m authored Feb 16, 2024
2 parents 2c174f5 + 4e800c3 commit 643d317
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Config.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_DISPLAY_NAME = iAPS
APP_VERSION = 3.0.1
APP_VERSION = 3.0.2
APP_BUILD_NUMBER = 1
COPYRIGHT_NOTICE =
DEVELOPER_TEAM = ##TEAM_ID##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
/* No comment provided by engineer. */
"Scan for new sensor" = "Načítať nový senzor";

/* No comment provided by engineer. */
"Scan for new sensor" = "Načítať nový senzor";

/* title for g7 settings connection status when scanning */
"Scanning" = "Skenuje sa";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Listen for 2 beeps.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Lyt efter 2 bip.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Listen for 2 beeps.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Listen for 2 beeps.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Listen for 2 beeps.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Écoutez deux bips.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Listen for 2 beeps.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Listen for 2 beeps.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Listen for 2 beeps.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@
/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 1 of pair pod instructions */
"Remove the Pod's blue needle cap and check cannula. Then remove paper backing." = "Remove the Pod's blue needle cap and check cannula. Then remove paper backing.";

/* Label text for step 2 of pair pod instructions */
"Listen for 2 beeps." = "Listen for 2 beeps.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,6 @@
/* Description for BeepPreference.extended */
"Confidence reminders will sound when the app automatically adjusts delivery as well as for commands you initiate." = "Нагадування про довіру лунатимуть, коли Loop автоматично регулює доставку, а також для команд, які ви ініціюєте.";

/* Description for BeepPreference.extended */
"Confidence reminders will sound when the app automatically adjusts delivery as well as for commands you initiate." = "Нагадування про довіру лунатимуть, коли Loop автоматично регулює доставку, а також для команд, які ви ініціюєте.";
>>>>>>> 7f4d47c8 (Crowdin (#334))

/* Label text for temporary basal rate summary */
"Rate" = "Швидкість";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@
/* Description for BeepPreference.extended */
"Confidence reminders will sound when the app automatically adjusts delivery as well as for commands you initiate." = "Доверенные звуковые сигналы сработают даже тогда, когда петля автоматически изменит подачу инсулина, а также для команд, которые Вы инициируете.";

/* Description for BeepPreference.extended */
"Confidence reminders will sound when the app automatically adjusts delivery as well as for commands you initiate." = "Доверенные звуковые сигналы сработают даже тогда, когда петля автоматически изменит подачу инсулина, а также для команд, которые Вы инициируете.";
>>>>>>> 420dc4ed (Crowdin (#362))

/* The title for AlarmCode.other notification */
"Critical Pod Error" = "Критическая ошибка пода";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@
/* Description for BeepPreference.extended */
"Confidence reminders will sound when the app automatically adjusts delivery as well as for commands you initiate." = "Нагадування про довіру лунатимуть, коли Loop автоматично регулює доставку, а також для команд, які ви ініціюєте.";

/* Description for BeepPreference.extended */
"Confidence reminders will sound when the app automatically adjusts delivery as well as for commands you initiate." = "Нагадування про довіру лунатимуть, коли Loop автоматично регулює доставку, а також для команд, які ви ініціюєте.";
>>>>>>> 7f4d47c8 (Crowdin (#334))

/* The title for AlarmCode.other notification */
"Critical Pod Error" = "Критична Помилка";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,6 @@

/* Alert message body for confirm pod attachment */
"Your Pod may still be delivering Insulin.\nRemove it from your body, then tap “Continue.“" = "Ваш Pod може все ще подавати інсулін.\nЗніміть його зі свого тіла, а потім натисніть «Продовжити»";
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> Crowdin

/* Title string for SilencePodPreference.enabled */
"Silenced" = "Сповіщення вимкнено";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,6 @@ Enact a temp Basal or a temp target */
/* Delete insulin from pump history and Nightscout */
"Delete Insulin?" = "Delete Insulin?";

/* Delete insulin from pump history and Nightscout */
"Delete Insulin?" = "Delete Insulin?";
>>>>>>> Crowdin

/* Treatments list */
"Treatments" = "Tedaviler";

Expand Down
43 changes: 25 additions & 18 deletions FreeAPS/Sources/Services/HealthKit/HealthKitManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,24 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
events.isNotEmpty
else { return }

func save(bolusToModify: [InsulinBolus], bolus: [InsulinBolus], basal: [InsulinBasal]) {
// first step : delete the HK value
// second step : recreate with the new value !
bolusToModify.forEach { syncID in
func delete(syncIds: [String]?) {
syncIds?.forEach { syncID in
let predicate = HKQuery.predicateForObjects(
withMetadataKey: HKMetadataKeySyncIdentifier,
operatorType: .equalTo,
value: syncID
)

self.healthKitStore.deleteObjects(of: sampleType, predicate: predicate) { _, _, error in
if let error = error {
warning(.service, "Cannot delete sample with syncID: \(syncID)", error: error)
}
}
}
let bolusTotal = bolus + bolusToModify
let bolusSamples = bolusTotal
}

func save(bolus: [InsulinBolus], basal: [InsulinBasal]) {
let bolusSamples = bolus
.map {
HKQuantitySample(
type: sampleType,
Expand Down Expand Up @@ -290,22 +291,30 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
}
}
}

// delete existing event in HK where the amount is not the last value in the pumphistory
loadSamplesFromHealth(sampleType: sampleType, withIDs: events.map(\.id))
.receive(on: processQueue)
.compactMap { samples -> ([InsulinBolus], [InsulinBolus], [InsulinBasal]) in
.compactMap { samples -> [String] in
let sampleIDs = samples.compactMap(\.syncIdentifier)
let bolusToModify = events
let bolusToDelete = events
.filter { $0.type == .bolus && sampleIDs.contains($0.id) }
.compactMap { event -> InsulinBolus? in
.compactMap { event -> String? in
guard let amount = event.amount else { return nil }
guard let sampleAmount = samples.first(where: { $0.syncIdentifier == event.id }) as? HKQuantitySample
else { return nil }
if Double(amount) != sampleAmount.quantity.doubleValue(for: .internationalUnit()) {
return InsulinBolus(id: sampleAmount.syncIdentifier!, amount: amount, date: event.timestamp)
return sampleAmount.syncIdentifier
} else { return nil }
}
return bolusToDelete
}
.sink(receiveValue: delete)
.store(in: &lifetime)

loadSamplesFromHealth(sampleType: sampleType, withIDs: events.map(\.id))
.receive(on: processQueue)
.compactMap { samples -> ([InsulinBolus], [InsulinBasal]) in
let sampleIDs = samples.compactMap(\.syncIdentifier)
let bolus = events
.filter { $0.type == .bolus && !sampleIDs.contains($0.id) }
.compactMap { event -> InsulinBolus? in
Expand Down Expand Up @@ -350,7 +359,7 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
endDelivery: nextBasalEvent.timestamp
)
}
return (bolusToModify, bolus, basal)
return (bolus, basal)
}
.sink(receiveValue: save)
.store(in: &lifetime)
Expand Down Expand Up @@ -409,14 +418,13 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P

/// Try to load samples from Health store
private func loadSamplesFromHealth(
sampleType: HKQuantityType,
limit: Int = 100
sampleType: HKQuantityType
) -> Future<[HKSample], Never> {
Future { promise in
let query = HKSampleQuery(
sampleType: sampleType,
predicate: nil,
limit: limit,
limit: 100,
sortDescriptors: nil
) { _, results, _ in
promise(.success((results as? [HKQuantitySample]) ?? []))
Expand All @@ -428,8 +436,7 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
/// Try to load samples from Health store with id and do some work
private func loadSamplesFromHealth(
sampleType: HKQuantityType,
withIDs ids: [String],
limit: Int = 100
withIDs ids: [String]
) -> Future<[HKSample], Never> {
Future { promise in
let predicate = HKQuery.predicateForObjects(
Expand All @@ -440,7 +447,7 @@ final class BaseHealthKitManager: HealthKitManager, Injectable, CarbsObserver, P
let query = HKSampleQuery(
sampleType: sampleType,
predicate: predicate,
limit: limit,
limit: 100,
sortDescriptors: nil
) { _, results, _ in
promise(.success((results as? [HKQuantitySample]) ?? []))
Expand Down

0 comments on commit 643d317

Please sign in to comment.