Skip to content

Commit

Permalink
feat(dashboard): updating feedback form (#533)
Browse files Browse the repository at this point in the history
* new privacy dashboard

* exact

* lint

* released dashboard version

---------

Co-authored-by: Shane Osbourne <[email protected]>
  • Loading branch information
shakyShane and Shane Osbourne authored Oct 23, 2023
1 parent c427dc6 commit dd595d9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
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)

Check failure on line 30 in Sources/PrivacyDashboard/PrivacyDashboardController.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Line should be 150 characters or less; currently it has 153 characters (line_length)
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

0 comments on commit dd595d9

Please sign in to comment.