mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Avoid race conditions between the home screen's crash alert and Sentry's onLastRunStatusDetermined
By converting the `lastCrashEventID` to a publisher that the VM can just listen to instead of relying on start to match a pre-set event
This commit is contained in:
@@ -26,7 +26,7 @@ class BugReportService: NSObject, BugReportServiceProtocol {
|
||||
rageshakeURL != .disabled
|
||||
}
|
||||
|
||||
var lastCrashEventID: String?
|
||||
let lastCrashEventIDSubject = CurrentValueSubject<String?, Never>(nil)
|
||||
|
||||
init(rageshakeURLPublisher: CurrentValuePublisher<RageshakeConfiguration, Never>,
|
||||
applicationID: String,
|
||||
@@ -48,10 +48,6 @@ class BugReportService: NSObject, BugReportServiceProtocol {
|
||||
|
||||
// MARK: - BugReportServiceProtocol
|
||||
|
||||
var crashedLastRun: Bool {
|
||||
SentrySDK.lastRunStatus == .didCrash
|
||||
}
|
||||
|
||||
// swiftlint:disable:next cyclomatic_complexity
|
||||
func submitBugReport(_ bugReport: BugReport,
|
||||
progressListener: CurrentValueSubject<Double, Never>) async -> Result<SubmitBugReportResponse, BugReportServiceError> {
|
||||
@@ -81,7 +77,7 @@ class BugReportService: NSObject, BugReportServiceProtocol {
|
||||
params.append(.init(key: "device_keys", type: .text(value: compactKeys)))
|
||||
}
|
||||
|
||||
if let crashEventID = lastCrashEventID {
|
||||
if let crashEventID = lastCrashEventIDSubject.value {
|
||||
params.append(MultipartFormData(key: "crash_report", type: .text(value: "<https://sentry.tools.element.io/organizations/element/issues/?project=44&query=\(crashEventID)>")))
|
||||
bugReport.githubLabels.append("crash")
|
||||
}
|
||||
@@ -155,7 +151,7 @@ class BugReportService: NSObject, BugReportServiceProtocol {
|
||||
let decoder = JSONDecoder()
|
||||
let uploadResponse = try decoder.decode(SubmitBugReportResponse.self, from: data)
|
||||
|
||||
lastCrashEventID = nil
|
||||
lastCrashEventIDSubject.send(nil)
|
||||
|
||||
MXLog.info("Feedback submitted.")
|
||||
|
||||
|
||||
@@ -50,9 +50,8 @@ enum BugReportServiceError: LocalizedError {
|
||||
// sourcery: AutoMockable
|
||||
protocol BugReportServiceProtocol: AnyObject {
|
||||
var isEnabled: Bool { get }
|
||||
var crashedLastRun: Bool { get }
|
||||
|
||||
var lastCrashEventID: String? { get set }
|
||||
var lastCrashEventIDSubject: CurrentValueSubject<String?, Never> { get }
|
||||
|
||||
func submitBugReport(_ bugReport: BugReport,
|
||||
progressListener: CurrentValueSubject<Double, Never>) async -> Result<SubmitBugReportResponse, BugReportServiceError>
|
||||
|
||||
Reference in New Issue
Block a user