Skip to content

Commit b32ba6f

Browse files
authored
Merge pull request #18519 from wordpress-mobile/task/18389-all-tours-complete-notice
Quick Start for Existing Users: All tour complete notice
2 parents 444a8fe + 719cc9f commit b32ba6f

4 files changed

Lines changed: 37 additions & 28 deletions

File tree

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/BlogDashboardViewController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,16 @@ extension BlogDashboardViewController {
256256

257257
private func showNoticeAsNeeded() {
258258
let quickStartGuide = QuickStartTourGuide.shared
259+
259260
guard let tourToSuggest = quickStartGuide.tourToSuggest(for: blog) else {
261+
quickStartGuide.showCongratsNoticeIfNeeded(for: blog)
260262
return
261263
}
262264

263265
if quickStartGuide.tourInProgress {
264266
// If tour is in progress, show notice regardless of quickstart is shown in dashboard or my site
265267
quickStartGuide.suggest(tourToSuggest, for: blog)
266-
}
267-
else {
268+
} else {
268269
guard shouldShowQuickStartChecklist() else {
269270
return
270271
}

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+FancyAlerts.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ extension BlogDetailsViewController {
6464

6565
private func showNoticeAsNeeded() {
6666
let quickStartGuide = QuickStartTourGuide.shared
67+
6768
guard let tourToSuggest = quickStartGuide.tourToSuggest(for: blog) else {
69+
quickStartGuide.showCongratsNoticeIfNeeded(for: blog)
6870
return
6971
}
7072

7173
if quickStartGuide.tourInProgress {
7274
// If tour is in progress, show notice regardless of quickstart is shown in dashboard or my site
7375
quickStartGuide.suggest(tourToSuggest, for: blog)
74-
}
75-
else {
76+
} else {
7677
guard shouldShowQuickStartChecklist() else {
7778
return
7879
}

WordPress/Classes/ViewRelated/Blog/QuickStartTourGuide.swift

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ open class QuickStartTourGuide: NSObject {
2323
/// A flag indicating if the user is currently going through a tour or not.
2424
private(set) var tourInProgress = false
2525

26+
/// A flag indidcating whether we should show the congrats notice or not.
27+
private var shouldShowCongratsNotice = false
28+
2629
/// Represents the current entry point.
2730
@objc var currentEntryPoint: QuickStartTourEntryPoint = .unknown
2831

@@ -229,6 +232,24 @@ open class QuickStartTourGuide: NSObject {
229232
completed(tour: tour, for: blog, postNotification: postNotification)
230233
}
231234

235+
func showCongratsNoticeIfNeeded(for blog: Blog) {
236+
guard allToursCompleted(for: blog), shouldShowCongratsNotice else {
237+
return
238+
}
239+
240+
shouldShowCongratsNotice = false
241+
242+
let noticeStyle = QuickStartNoticeStyle(attributedMessage: nil, isDismissable: true)
243+
let notice = Notice(title: Strings.congratulationsTitle,
244+
message: Strings.congratulationsMessage,
245+
style: noticeStyle,
246+
tag: noticeTag)
247+
248+
ActionDispatcher.dispatch(NoticeAction.post(notice))
249+
250+
WPAnalytics.track(.quickStartCongratulationsViewed)
251+
}
252+
232253
// we have this because poor stupid ObjC doesn't know what the heck an optional is
233254
@objc func currentElementInt() -> Int {
234255
return currentWaypoint()?.element.rawValue ?? NSNotFound
@@ -289,7 +310,10 @@ open class QuickStartTourGuide: NSObject {
289310

290311
let noticeStyle = QuickStartNoticeStyle(attributedMessage: taskCompleteDescription, isDismissable: true)
291312
let notice = Notice(title: "", style: noticeStyle, tag: noticeTag)
292-
ActionDispatcher.dispatch(NoticeAction.post(notice))
313+
314+
DispatchQueue.main.asyncAfter(deadline: .now() + Constants.quickStartDelay) {
315+
ActionDispatcher.dispatch(NoticeAction.post(notice))
316+
}
293317
}
294318

295319
private func showNextStep(_ nextStep: TourState) {
@@ -344,15 +368,11 @@ private extension QuickStartTourGuide {
344368
recentlyTouredBlog = nil
345369
}
346370

347-
guard !(tour is QuickStartCongratulationsTour) else {
348-
WPAnalytics.track(.quickStartCongratulationsViewed)
349-
return
350-
}
351-
352371
if allToursCompleted(for: blog) {
353372
WPAnalytics.track(.quickStartAllToursCompleted)
354373
grantCongratulationsAward(for: blog)
355374
tourInProgress = false
375+
shouldShowCongratsNotice = true
356376
} else {
357377
if let nextTour = tourToSuggest(for: blog) {
358378
PushNotificationsManager.shared.postNotification(for: nextTour)
@@ -448,6 +468,11 @@ private extension QuickStartTourGuide {
448468
static let quickStartDelay: DispatchTimeInterval = .milliseconds(500)
449469
static let nextStepDelay: DispatchTimeInterval = .milliseconds(1000)
450470
}
471+
472+
private enum Strings {
473+
static let congratulationsTitle = NSLocalizedString("Congrats! You know your way around", comment: "Title shown when all tours have been completed.")
474+
static let congratulationsMessage = NSLocalizedString("Doesn't it feel good to cross things off a list?", comment: "Message shown when all tours have been completed")
475+
}
451476
}
452477

453478
internal extension NSNotification.Name {

WordPress/Classes/ViewRelated/Blog/QuickStartTours.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -371,24 +371,6 @@ struct QuickStartNotificationsTour: QuickStartTour {
371371
let accessibilityHintText = NSLocalizedString("Guides you through the process of checking your notifications.", comment: "This value is used to set the accessibility hint text for viewing the user's notifications.")
372372
}
373373

374-
private let congratsTitle = NSLocalizedString("Congrats on finishing Quick Start 🎉", comment: "Title of a Quick Start Tour")
375-
private let congratsDescription = NSLocalizedString("doesn’t it feel good to cross things off a list?", comment: "subhead shown to users when they complete all Quick Start items")
376-
struct QuickStartCongratulationsTour: QuickStartTour {
377-
let key = "quick-start-congratulations-tour"
378-
let analyticsKey = "congratulations"
379-
let title = congratsTitle
380-
let titleMarkedCompleted = "" // Not applicable for this tour type
381-
let description = congratsDescription
382-
let icon = UIImage.gridicon(.plus)
383-
let suggestionNoText = Strings.notNow
384-
let suggestionYesText = Strings.yesShowMe
385-
let possibleEntryPoints: Set<QuickStartTourEntryPoint> = [.blogDetails, .blogDashboard]
386-
387-
var waypoints: [QuickStartTour.WayPoint] = [(element: .congratulations, description: NSAttributedString(string: congratsTitle))]
388-
389-
let accessibilityHintText = "" // Not applicable for this tour type
390-
}
391-
392374
private extension String {
393375
func highlighting(phrase: String, icon: UIImage?) -> NSAttributedString {
394376
let normalParts = components(separatedBy: "%@")

0 commit comments

Comments
 (0)