Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4853 from corona-warn-app/fix/14149-App-Crash-whe…
Browse files Browse the repository at this point in the history
…n-scanning-Redeemed-QR-Code

Fix/14149 REVERT FIX for app crash when scanning redeemed qr code
  • Loading branch information
30mar authored Oct 20, 2022
2 parents ccb8a6f + 8d93631 commit 74fca47
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/xcode/ENA/ENA/Source/Scenes/Home/HomeTableViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class HomeTableViewModel {
riskAndTestResultsRows.append(.risk)
}

if let pcrTest = coronaTestService.pcrTest.value, pcrTest.finalTestResultReceivedDate != nil {
if let pcrTest = coronaTestService.pcrTest.value {
let testResultState: TestResultState
if pcrTest.testResult == .positive && pcrTest.positiveTestResultWasShown {
testResultState = .positiveResultWasShown
Expand All @@ -226,7 +226,7 @@ class HomeTableViewModel {
riskAndTestResultsRows.append(.pcrTestResult(testResultState))
}

if let antigenTest = coronaTestService.antigenTest.value, antigenTest.finalTestResultReceivedDate != nil {
if let antigenTest = coronaTestService.antigenTest.value {
let testResultState: TestResultState
if antigenTest.testResult == .positive && antigenTest.positiveTestResultWasShown {
testResultState = .positiveResultWasShown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,12 +976,6 @@ class CoronaTestService: CoronaTestServiceProviding {
case .pending:
completion(.success(testResult))
case .expired:
switch coronaTestType {
case .pcr:
self.pcrTest.value = nil
case .antigen:
self.antigenTest.value = nil
}
if duringRegistration {
// The .expired status is only known after the test has been registered on the server
// so we generate an error here, even if the server returned the http result 201
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@ class CoronaTestServiceTests: CWATestCase {
recycleBin: .fake(),
badgeWrapper: .fake()
)
service.pcrTest.value = UserPCRTest.mock(registrationToken: nil, finalTestResultReceivedDate: nil)
service.pcrTest.value = .mock(registrationToken: nil)

let expectation = self.expectation(description: "Expect to receive a result.")

Expand Down Expand Up @@ -2611,7 +2611,7 @@ class CoronaTestServiceTests: CWATestCase {
recycleBin: .fake(),
badgeWrapper: .fake()
)
service.antigenTest.value = UserAntigenTest.mock(registrationToken: nil, finalTestResultReceivedDate: nil)
service.antigenTest.value = .mock(registrationToken: nil)

let expectation = self.expectation(description: "Expect to receive a result.")

Expand Down Expand Up @@ -2962,8 +2962,8 @@ class CoronaTestServiceTests: CWATestCase {
waitForExpectations(timeout: .short)

XCTAssertEqual(diaryStore.coronaTests.count, 0)
XCTAssertNil(try XCTUnwrap(testService.antigenTest.value?.journalEntryCreated))
XCTAssertNil(try XCTUnwrap(testService.pcrTest.value?.journalEntryCreated))
XCTAssertFalse(try XCTUnwrap(testService.antigenTest.value?.journalEntryCreated))
XCTAssertFalse(try XCTUnwrap(testService.pcrTest.value?.journalEntryCreated))
}

func test_When_UpdateTestResultSuccessWithInvalid_Then_ContactJournalHasNoEntry() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension UserAntigenTest {
registrationDate: Date? = nil,
testedPerson: TestedPerson = TestedPerson(firstName: nil, lastName: nil, dateOfBirth: nil),
testResult: TestResult = .pending,
finalTestResultReceivedDate: Date? = Date(),
finalTestResultReceivedDate: Date? = nil,
positiveTestResultWasShown: Bool = false,
isSubmissionConsentGiven: Bool = false,
submissionTAN: String? = nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension UserPCRTest {
qrCodeHash: String? = nil,
registrationDate: Date = Date(),
testResult: TestResult = .pending,
finalTestResultReceivedDate: Date? = Date(),
finalTestResultReceivedDate: Date? = nil,
positiveTestResultWasShown: Bool = false,
isSubmissionConsentGiven: Bool = false,
submissionTAN: String? = nil,
Expand Down

0 comments on commit 74fca47

Please sign in to comment.