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

[MBL-1063] Use transcend privacy flow for user data requests #1911

Merged
merged 9 commits into from
Jan 19, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ internal final class SettingsPrivacyViewController: UITableViewController {
internal override func tableView(_: UITableView, willDisplay cell: UITableViewCell, forRowAt _: IndexPath) {
if let followCell = cell as? SettingsFollowCell {
followCell.delegate = self
} else if let requestDataCell = cell as? SettingsPrivacyRequestDataCell {
requestDataCell.delegate = self
} else if let deleteAccountCell = cell as? SettingsPrivacyDeleteAccountCell {
} else if let deleteAccountCell = cell as? SettingsPrivacyDeleteOrRequestCell {
deleteAccountCell.delegate = self
} else if let privacySwitchCell = cell as? SettingsPrivacySwitchCell {
privacySwitchCell.delegate = self
Expand Down Expand Up @@ -117,45 +115,9 @@ extension SettingsPrivacyViewController: SettingsFollowCellDelegate {
}
}

extension SettingsPrivacyViewController: SettingsRequestDataCellDelegate {
internal func settingsRequestDataCellDidPresentPrompt(
_: SettingsPrivacyRequestDataCell,
alertMessage: String
) {
let exportDataSheet = UIAlertController(
title: nil,
message: alertMessage,
preferredStyle: .actionSheet
)

let startTheRequest = UIAlertAction(
title: Strings.Request_my_data(),
style: .default,
handler: { _ in
NotificationCenter.default.post(name: Notification.Name.ksr_dataRequested, object: nil, userInfo: nil)
}
)

let dismiss = UIAlertAction(title: Strings.Cancel(), style: .cancel, handler: nil)

exportDataSheet.addAction(startTheRequest)
exportDataSheet.addAction(dismiss)

self.present(exportDataSheet, animated: true, completion: nil)
}

internal func settingsRequestDataCell(
_: SettingsPrivacyRequestDataCell,
requestedDataWith url: String
) {
guard let fileUrl = URL(string: url) else { return }
UIApplication.shared.open(fileUrl)
}
}

extension SettingsPrivacyViewController: SettingsPrivacyDeleteAccountCellDelegate {
internal func settingsPrivacyDeleteAccountCellTapped(
_: SettingsPrivacyDeleteAccountCell,
extension SettingsPrivacyViewController: SettingsPrivacyDeleteOrRequestCellDelegate {
internal func settingsPrivacyDeleteOrRequestCellTapped(
_: SettingsPrivacyDeleteOrRequestCell,
with url: URL
) {
self.goTo(url: url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ internal final class SettingsPrivacyViewControllerTests: TestCase {
super.tearDown()
}

func testSocialOptedOut_And_DownloadDataCopy() {
func testSocialOptedOut() {
let currentUser = User.template
|> \.social .~ false
let exportData = ExportDataEnvelope.template

let mockService = MockService(
fetchExportStateResponse: exportData,
fetchUserSelfResponse: currentUser
)

Expand All @@ -50,17 +48,11 @@ internal final class SettingsPrivacyViewControllerTests: TestCase {
}
}

func testSocialOptedIn_And_RequestDataCopy() {
func testSocialOptedIn() {
let currentUser = User.template
|> \.social .~ true

let exportData = .template
|> ExportDataEnvelope.lens.state .~ .expired
|> ExportDataEnvelope.lens.dataUrl .~ nil
|> ExportDataEnvelope.lens.expiresAt .~ nil

let mockService = MockService(
fetchExportStateResponse: exportData,
fetchUserSelfResponse: currentUser
)

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ internal final class SettingsPrivacyDataSource: ValueCellDataSource {
}

self.set(
values: [user],
cellClass: SettingsPrivacyRequestDataCell.self,
values: [(user: user, cellType: .request)],
cellClass: SettingsPrivacyDeleteOrRequestCell.self,
inSection: Section.requestData.rawValue
)

self.set(
values: [user],
cellClass: SettingsPrivacyDeleteAccountCell.self,
values: [(user: user, cellType: .delete)],
cellClass: SettingsPrivacyDeleteOrRequestCell.self,
inSection: Section.deleteAccount.rawValue
)
}
Expand All @@ -82,9 +82,10 @@ internal final class SettingsPrivacyDataSource: ValueCellDataSource {
cell.configureWith(value: value)
case let (cell as SettingsPrivacyRecommendationCell, value as SettingsPrivacyStaticCellValue):
cell.configureWith(value: value)
case let (cell as SettingsPrivacyRequestDataCell, value as User):
cell.configureWith(value: value)
case let (cell as SettingsPrivacyDeleteAccountCell, value as User):
case let (
cell as SettingsPrivacyDeleteOrRequestCell,
value as (user: User, cellType: SettingsPrivacyDeleteOrRequestCell.CellType)
):
cell.configureWith(value: value)
case let (cell as SettingsPrivacyStaticCell, value as String):
cell.configureWith(value: value)
Expand Down