Skip to content

Commit

Permalink
Fix toggle report not showing after user decides to send a report (#1220
Browse files Browse the repository at this point in the history
)

Task/Issue URL:
https://app.asana.com/0/1201048563534612/1209117117981111
What kind of version bump will this require?: Patch

**Description**:
On macOS we were incorrectly recording user's choice to send a breakage
report as dismissal.

**Steps to test this PR**:
1. Open any webpage
2. Tap on a protection shield and toggle off protections
3. You should see the prompt asking you to send a report, do so!
4. On macOS only, you should see thank you note! Dismiss it by tapping
on it or anywhere else.
5. Open privacy dashboard again and switch protection ON.
6. Open privacy dashboard again and switch protection OFF.
7. You should see the prompt asking you to send a report. Dismiss it
now.
8. Repeat steps 5 and 6.
9. You shouldn't see the prompt anymore, because you dismissed once.
  • Loading branch information
jaceklyp authored Feb 8, 2025
1 parent 8b7cb16 commit eafeda3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sources/PrivacyDashboard/ToggleReportingFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ final class ToggleReportingFlow {

let entryPoint: EntryPoint

// We need to know if the user chose to send a report. On macOS browser, the "Thank You" prompt is shown afterward.
// If the user dismisses that prompt, handleDismissal is triggered,
// but calling recordDismissal within it would be incorrect at that stage.
private var didSendReport = false

init(entryPoint: EntryPoint,
toggleReportingManager: ToggleReportingManaging,
controller: PrivacyDashboardController?) {
Expand All @@ -74,7 +79,9 @@ final class ToggleReportingFlow {
}

private func handleDismissal(isUserAction: Bool = false) {
toggleReportingManager.recordDismissal(date: Date())
if !didSendReport {
toggleReportingManager.recordDismissal(date: Date())
}
switch entryPoint {
case .appMenuProtectionsOff(let completionHandler):
completionHandler(false)
Expand All @@ -89,6 +96,7 @@ final class ToggleReportingFlow {
private func handleSendReport() {
privacyDashboardController?.didRequestSubmitToggleReport(with: entryPoint.source)
toggleReportingManager.recordPrompt(date: Date())
didSendReport = true
switch entryPoint {
case .appMenuProtectionsOff(let completionHandler):
completionHandler(true)
Expand Down

0 comments on commit eafeda3

Please sign in to comment.