Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): updating feedback form #533

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"revision" : "51e2b46f413bf3ef18afefad631ca70f2c25ef70",
"version" : "1.4.0"
"revision" : "b4ac92a444e79d5651930482623b9f6dc9265667",
"version" : "2.0.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let package = Package(
.package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.2.0"),
.package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "2.1.0"),
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "4.40.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "1.4.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "2.0.0"),
.package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"),
.package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"),
.package(url: "https://github.com/duckduckgo/wireguard-apple", exact: "1.1.1")
Expand Down
6 changes: 3 additions & 3 deletions Sources/PrivacyDashboard/PrivacyDashboardController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public enum PrivacyDashboardOpenSettingsTarget: String {
}

public protocol PrivacyDashboardControllerDelegate: AnyObject {
func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didChangeProtectionSwitch isEnabled: Bool)
func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didChangeProtectionSwitch protectionState: ProtectionState)
func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController, didRequestOpenUrlInNewTab url: URL)
func privacyDashboardController(_ privacyDashboardController: PrivacyDashboardController,
didRequestOpenSettings target: PrivacyDashboardOpenSettingsTarget)
Expand Down Expand Up @@ -239,8 +239,8 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate {
delegate?.privacyDashboardController(self, didRequestOpenSettings: settingsTarget)
}

func userScript(_ userScript: PrivacyDashboardUserScript, didChangeProtectionStateTo isProtected: Bool) {
delegate?.privacyDashboardController(self, didChangeProtectionSwitch: isProtected)
func userScript(_ userScript: PrivacyDashboardUserScript, didChangeProtectionState protectionState: ProtectionState) {
delegate?.privacyDashboardController(self, didChangeProtectionSwitch: protectionState)
}

func userScript(_ userScript: PrivacyDashboardUserScript, didRequestOpenUrlInNewTab url: URL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import Foundation
import WebKit
import TrackerRadarKit
import UserScript
import Common

protocol PrivacyDashboardUserScriptDelegate: AnyObject {
func userScript(_ userScript: PrivacyDashboardUserScript, didChangeProtectionStateTo protectionState: Bool)
func userScript(_ userScript: PrivacyDashboardUserScript, didChangeProtectionState protectionState: ProtectionState)
func userScript(_ userScript: PrivacyDashboardUserScript, setHeight height: Int)
func userScriptDidRequestClosing(_ userScript: PrivacyDashboardUserScript)
func userScriptDidRequestShowReportBrokenSite(_ userScript: PrivacyDashboardUserScript)
Expand All @@ -38,6 +39,20 @@ public enum PrivacyDashboardTheme: String, Encodable {
case dark
}

public struct ProtectionState: Decodable {
public let isProtected: Bool
public let eventOrigin: EventOrigin

public struct EventOrigin: Decodable {
public let screen: EventOriginScreen
}

public enum EventOriginScreen: String, Decodable {
case primaryScreen
case breakageForm
}
}

final class PrivacyDashboardUserScript: NSObject, StaticUserScript {

enum MessageNames: String, CaseIterable {
Expand Down Expand Up @@ -91,12 +106,13 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
// MARK: - JS message handlers

private func handleSetProtection(message: WKScriptMessage) {
guard let isProtected = message.body as? Bool else {
assertionFailure("privacyDashboardSetProtection: expected Bool")

guard let protectionState: ProtectionState = DecodableHelper.decode(from: message.messageBody) else {
assertionFailure("privacyDashboardSetProtection: expected ProtectionState")
return
}

delegate?.userScript(self, didChangeProtectionStateTo: isProtected)
delegate?.userScript(self, didChangeProtectionState: protectionState)
}

private func handleSetSize(message: WKScriptMessage) {
Expand Down