Skip to content

Commit

Permalink
Ony upload profiles when changed, fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-b-m committed Oct 23, 2023
1 parent 535e0d9 commit dbb832b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions FreeAPS/Sources/Services/Network/NightscoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -521,25 +521,25 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
NSLog("NightscoutManager Settings, settings unchanged")
} else { uploadSettings(settings) }

// UPLOAD Profiles WHEN CHANGED
if let uploadedProfile = storage.retrieve(OpenAPS.Nightscout.uploadedProfile, as: NightscoutProfileStore.self),
(uploadedProfile.store["default"]?.rawJSON ?? "").sorted() == ps.rawJSON.sorted(), !force
{
NSLog("NightscoutManager uploadProfile, no profile change")
return
}

processQueue.async {
nightscout.uploadProfile(p)
.sink { completion in
switch completion {
case .finished:
self.storage.save(p, as: OpenAPS.Nightscout.uploadedProfile)
debug(.nightscout, "Profile uploaded")
case let .failure(error):
debug(.nightscout, error.localizedDescription)
}
} receiveValue: {}
.store(in: &self.lifetime)
} else {
processQueue.async {
nightscout.uploadProfile(p)
.sink { completion in
switch completion {
case .finished:
self.storage.save(p, as: OpenAPS.Nightscout.uploadedProfile)
debug(.nightscout, "Profile uploaded")
case let .failure(error):
debug(.nightscout, error.localizedDescription)
}
} receiveValue: {}
.store(in: &self.lifetime)
}
}
}

Expand Down

0 comments on commit dbb832b

Please sign in to comment.