Skip to content
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
3 changes: 3 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import WordPressShared
// Reader
case selectInterestsShown
case selectInterestsPicked
case selectInterestsSkipped
case readerDiscoverShown
case readerFollowingShown
case readerSavedListShown
Expand Down Expand Up @@ -821,6 +822,8 @@ import WordPressShared
return "select_interests_shown"
case .selectInterestsPicked:
return "select_interests_picked"
case .selectInterestsSkipped:
return "select_interests_skipped"
case .readerDiscoverShown:
return "reader_discover_shown"
case .readerFollowingShown:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ struct DebugMenuView: View {
NavigationLink(Strings.readerCssTitle) {
readerSettings
}
Button(Strings.showReaderInterests) {
presentReaderInterests()
}
Button(Strings.resetReaderInterestsPrompt) {
UserDefaults.standard.readerDidSelectInterestsKey = false
// A bare emoji notice is illegible on the notice's inverted
// background in dark mode; a text title renders legibly in both.
let notice = Notice(title: Strings.readerInterestsPromptResetNotice, feedbackType: .success)
ActionDispatcher.dispatch(NoticeAction.post(notice))
}
}

@ViewBuilder private var tipKit: some View {
Expand Down Expand Up @@ -195,6 +205,17 @@ struct DebugMenuView: View {
navigation.push(webViewController)
}

/// Presents the Reader "Discover" select-interests screen directly, bypassing
/// the `readerDidSelectInterestsKey` flag *and* the `isFollowingInterests`
/// check that normally gate it, so it can be inspected on any account.
private func presentReaderInterests() {
let interestsViewController = ReaderSelectInterestsViewController(configuration: .discover)
interestsViewController.didSaveInterests = { [weak interestsViewController] _ in
interestsViewController?.presentingViewController?.dismiss(animated: true)
}
navigation.parentViewController?.present(interestsViewController, animated: true)
}

private var readerSettings: some View {
let viewController = SettingsTextViewController(text: ReaderCSS().customAddress, placeholder: Strings.readerURLPlaceholder, hint: Strings.readerURLHint)
viewController.title = Strings.readerCssTitle
Expand Down Expand Up @@ -310,6 +331,9 @@ private enum Strings {
static let readerCssTitle = NSLocalizedString("debugMenu.readerCellTitle", value: "Reader CSS URL", comment: "Title of the screen that allows the user to change the Reader CSS URL for debug builds")
static let readerURLPlaceholder = NSLocalizedString("debugMenu.readerDefaultURL", value: "Default URL", comment: "Placeholder for the reader CSS URL")
static let readerURLHint = NSLocalizedString("debugMenu.readerHit", value: "Add a custom CSS URL here to be loaded in Reader. If you're running Calypso locally this can be something like: http://192.168.15.23:3000/calypso/reader-mobile.css", comment: "Hint for the reader CSS URL field")
static let showReaderInterests = NSLocalizedString("debugMenu.showReaderInterests", value: "Show Reader Interests Screen", comment: "Debug menu action that presents the Reader select interests screen")
static let resetReaderInterestsPrompt = NSLocalizedString("debugMenu.resetReaderInterestsPrompt", value: "Reset Reader Interests Prompt", comment: "Debug menu action that clears the flag so the Reader select interests prompt can appear again")
static let readerInterestsPromptResetNotice = NSLocalizedString("debugMenu.readerInterestsPromptReset", value: "Reader interests prompt reset", comment: "Debug menu confirmation shown after clearing the flag that suppresses the Reader select interests prompt")
static let remoteConfigTitle = NSLocalizedString("debugMenu.remoteConfig.title", value: "Remote Config", comment: "Remote Config debug menu title")
static let analyics = NSLocalizedString("debugMenu.analytics", value: "Analytics", comment: "Debug menu item title")
static let featureFlags = NSLocalizedString("debugMenu.featureFlags", value: "Feature Flags", comment: "Feature flags menu item")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class ReaderSelectInterestsViewController: UIViewController {
let button = UIButton(type: .system)
button.setTitle(Strings.skipButtonTitle, for: .normal)
button.translatesAutoresizingMaskIntoConstraints = false
button.addTarget(self, action: #selector(skipButtonTapped), for: .touchUpInside)
button.addTarget(self, action: #selector(skipButtonTapped(_:)), for: .touchUpInside)
ReaderInterestsStyleGuide.applySkipButtonStyle(button: button)

if let index = contentContainerView.arrangedSubviews.firstIndex(of: buttonContainerView) {
Expand All @@ -207,8 +207,19 @@ class ReaderSelectInterestsViewController: UIViewController {
}
}

@objc private func skipButtonTapped() {
@objc private func skipButtonTapped(_ sender: UIButton) {
// Disable on first tap so a fast double-tap can't complete the flow
// (re-triggering dismiss / stream refresh) twice, matching the primary
// button, which disables itself before dismissing.
sender.isEnabled = false

WPAnalytics.trackReader(.selectInterestsSkipped)

didSaveInterests?([])
// Keep skip symmetric with the save-success path so a flow that both
// shows the Skip button and sets `readerDiscoverFlowDelegate` still
// completes. The only current Skip flow (Discover) leaves this nil.
readerDiscoverFlowDelegate?.didCompleteReaderDiscoverFlow()
}

private func applyStyles() {
Expand Down