Skip to content

Commit

Permalink
Implement tab bar remote message
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaemepereira committed Dec 12, 2024
1 parent 13fd870 commit e879230
Show file tree
Hide file tree
Showing 13 changed files with 408 additions and 8 deletions.
20 changes: 20 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2853,6 +2853,8 @@
B6FA893F269C424500588ECD /* PrivacyDashboardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FA893E269C424500588ECD /* PrivacyDashboardViewController.swift */; };
B6FA8941269C425400588ECD /* PrivacyDashboardPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FA8940269C425400588ECD /* PrivacyDashboardPopover.swift */; };
BB0346F52CEB80B400D23E05 /* DownloadsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB0346F42CEB80B400D23E05 /* DownloadsTests.swift */; };
BB3229052D08644400DA92E9 /* TabBarRemoteMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3229042D08643700DA92E9 /* TabBarRemoteMessageView.swift */; };
BB3229062D08644400DA92E9 /* TabBarRemoteMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3229042D08643700DA92E9 /* TabBarRemoteMessageView.swift */; };
BB4339DB2C7F9606005D7ED7 /* PinnedTabsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB4339DA2C7F9606005D7ED7 /* PinnedTabsTests.swift */; };
BB470EBB2C5A66D6002EE91D /* BookmarkManagementDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB470EBA2C5A66D6002EE91D /* BookmarkManagementDetailViewModel.swift */; };
BB470EBC2C5A66D6002EE91D /* BookmarkManagementDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB470EBA2C5A66D6002EE91D /* BookmarkManagementDetailViewModel.swift */; };
Expand All @@ -2861,6 +2863,8 @@
BB731F312CDBA6360023D2E4 /* FireWindowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB731F302CDBA6320023D2E4 /* FireWindowTests.swift */; };
BB7B5F982C4ED73800BA4AF8 /* BookmarksSearchAndSortMetrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7B5F972C4ED73800BA4AF8 /* BookmarksSearchAndSortMetrics.swift */; };
BB7B5F992C4ED73800BA4AF8 /* BookmarksSearchAndSortMetrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7B5F972C4ED73800BA4AF8 /* BookmarksSearchAndSortMetrics.swift */; };
BB9BDD492D09BAA80069E9EF /* TabBarRemoteMessageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9BDD482D09BA9D0069E9EF /* TabBarRemoteMessageViewModel.swift */; };
BB9BDD4A2D09BAA80069E9EF /* TabBarRemoteMessageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9BDD482D09BA9D0069E9EF /* TabBarRemoteMessageViewModel.swift */; };
BBB881882C4029BA001247C6 /* BookmarkListTreeControllerSearchDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB881872C4029BA001247C6 /* BookmarkListTreeControllerSearchDataSource.swift */; };
BBB881892C4029BA001247C6 /* BookmarkListTreeControllerSearchDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB881872C4029BA001247C6 /* BookmarkListTreeControllerSearchDataSource.swift */; };
BBBB65402C77BB9400E69AC6 /* BookmarkSearchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBBB653F2C77BB9400E69AC6 /* BookmarkSearchTests.swift */; };
Expand Down Expand Up @@ -4820,12 +4824,14 @@
B6FA893E269C424500588ECD /* PrivacyDashboardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyDashboardViewController.swift; sourceTree = "<group>"; };
B6FA8940269C425400588ECD /* PrivacyDashboardPopover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyDashboardPopover.swift; sourceTree = "<group>"; };
BB0346F42CEB80B400D23E05 /* DownloadsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadsTests.swift; sourceTree = "<group>"; };
BB3229042D08643700DA92E9 /* TabBarRemoteMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarRemoteMessageView.swift; sourceTree = "<group>"; };
BB4339DA2C7F9606005D7ED7 /* PinnedTabsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PinnedTabsTests.swift; sourceTree = "<group>"; };
BB470EBA2C5A66D6002EE91D /* BookmarkManagementDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkManagementDetailViewModel.swift; sourceTree = "<group>"; };
BB5789712B2CA70F0009DFE2 /* DataBrokerProtectionSubscriptionEventHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataBrokerProtectionSubscriptionEventHandler.swift; sourceTree = "<group>"; };
BB5F46A22C8751F6005F72DF /* BookmarkSortTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkSortTests.swift; sourceTree = "<group>"; };
BB731F302CDBA6320023D2E4 /* FireWindowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FireWindowTests.swift; sourceTree = "<group>"; };
BB7B5F972C4ED73800BA4AF8 /* BookmarksSearchAndSortMetrics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksSearchAndSortMetrics.swift; sourceTree = "<group>"; };
BB9BDD482D09BA9D0069E9EF /* TabBarRemoteMessageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarRemoteMessageViewModel.swift; sourceTree = "<group>"; };
BBB881872C4029BA001247C6 /* BookmarkListTreeControllerSearchDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkListTreeControllerSearchDataSource.swift; sourceTree = "<group>"; };
BBBB653F2C77BB9400E69AC6 /* BookmarkSearchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkSearchTests.swift; sourceTree = "<group>"; };
BBBEE1BE2C4FF63600035ABA /* SortBookmarksViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SortBookmarksViewModelTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -8270,6 +8276,7 @@
AA86491124D8318F001BABEE /* TabBar */ = {
isa = PBXGroup;
children = (
BB68B6542D0B1E9200CEC812 /* TabBarRemoteMessaging */,
AA86491224D831A1001BABEE /* View */,
AA8EDF1F2491FCC10071C2E8 /* ViewModel */,
AA9FF95724A1ECE20039E328 /* Model */,
Expand Down Expand Up @@ -9470,6 +9477,15 @@
path = View;
sourceTree = "<group>";
};
BB68B6542D0B1E9200CEC812 /* TabBarRemoteMessaging */ = {
isa = PBXGroup;
children = (
BB3229042D08643700DA92E9 /* TabBarRemoteMessageView.swift */,
BB9BDD482D09BA9D0069E9EF /* TabBarRemoteMessageViewModel.swift */,
);
path = TabBarRemoteMessaging;
sourceTree = "<group>";
};
BD7090D42C540C0D009EED82 /* MetadataCollectors */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -11637,6 +11653,7 @@
C1C405882C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift in Sources */,
B6E1491029A5C30500AAFBE8 /* ContentBlockingTabExtension.swift in Sources */,
3706FB82293F65D500E42796 /* PasswordManagementNoteItemView.swift in Sources */,
BB9BDD492D09BAA80069E9EF /* TabBarRemoteMessageViewModel.swift in Sources */,
4BF97AD82B43C5B300EB4240 /* NetworkProtectionAppEvents.swift in Sources */,
3706FEC5293F6F0600E42796 /* BWInstallationService.swift in Sources */,
BDBA85972C5D256C00BC54F5 /* VPNFeedbackFormView.swift in Sources */,
Expand Down Expand Up @@ -11925,6 +11942,7 @@
F1B33DF32BAD929D001128B3 /* SubscriptionAppStoreRestorer.swift in Sources */,
3706FC1F293F65D500E42796 /* BookmarksBarViewController.swift in Sources */,
1DDC85042B83903E00670238 /* PreferencesWebTrackingProtectionView.swift in Sources */,
BB3229062D08644400DA92E9 /* TabBarRemoteMessageView.swift in Sources */,
3706FC20293F65D500E42796 /* PreferencesAutofillView.swift in Sources */,
CD2AB5C22C8222F50019EB49 /* MaliciousSiteProtectionPreferences.swift in Sources */,
3706FC21293F65D500E42796 /* UserText+PasswordManager.swift in Sources */,
Expand Down Expand Up @@ -13104,6 +13122,7 @@
37D0469F2C7D0EDD00AEAA50 /* CustomBackground.swift in Sources */,
B684592225C93BE000DC17B6 /* Publisher.asVoid.swift in Sources */,
4B9DB01D2A983B24000927DB /* Waitlist.swift in Sources */,
BB9BDD4A2D09BAA80069E9EF /* TabBarRemoteMessageViewModel.swift in Sources */,
AAA0CC33252F181A0079BC96 /* NavigationButtonMenuDelegate.swift in Sources */,
1DA84D2F2C11989D0011C80F /* Update.swift in Sources */,
AAC30A2A268E239100D2D9CD /* CrashReport.swift in Sources */,
Expand Down Expand Up @@ -13714,6 +13733,7 @@
4B59024826B3673600489384 /* ThirdPartyBrowser.swift in Sources */,
B60C6F7729B0E286007BFAA8 /* SearchNonexistentDomainNavigationResponder.swift in Sources */,
B65E6B9E26D9EC0800095F96 /* CircularProgressView.swift in Sources */,
BB3229052D08644400DA92E9 /* TabBarRemoteMessageView.swift in Sources */,
56A053FC2C19E8F7007D8FAB /* OnboardingActionsManager.swift in Sources */,
EEE50C292C38249C003DD7FF /* OptionalExtension.swift in Sources */,
AABEE69C24A902BB0043105B /* SuggestionContainer.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Response-DDG-Question-96x96.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ extension URL {
return URL(string: "https://duckduckgo.com/updates")!
}

static var survey: URL {
return URL(string: "https://selfserve.decipherinc.com/survey/selfserve/32ab/241004?list=2")!
}

static var webTrackingProtection: URL {
return URL(string: "https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/")!
}
Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/HomePage/View/HomePageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ extension HomePage.Views {

@ViewBuilder
func remoteMessage() -> some View {
if let remoteMessage = activeRemoteMessageModel.remoteMessage, let modelType = remoteMessage.content, modelType.isSupported {
if let remoteMessage = activeRemoteMessageModel.remoteMessage,
!remoteMessage.isForTabBar,
let modelType = remoteMessage.content,
modelType.isSupported {
ZStack {
RemoteMessageView(viewModel: .init(
messageId: remoteMessage.id,
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -64606,4 +64606,4 @@
}
},
"version" : "1.0"
}
}
2 changes: 1 addition & 1 deletion DuckDuckGo/MainWindow/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final class MainViewController: NSViewController {
self.isBurner = tabCollectionViewModel.isBurner
self.featureFlagger = featureFlagger

tabBarViewController = TabBarViewController.create(tabCollectionViewModel: tabCollectionViewModel)
tabBarViewController = TabBarViewController.create(tabCollectionViewModel: tabCollectionViewModel, activeRemoteMessageModel: NSApp.delegateTyped.activeRemoteMessageModel)
bookmarksBarVisibilityManager = BookmarksBarVisibilityManager(selectedTabPublisher: tabCollectionViewModel.$selectedTabViewModel.eraseToAnyPublisher())

let networkProtectionPopoverManager: NetPPopoverManager = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import RemoteMessaging

extension ActiveRemoteMessageModel: NewTabPageActiveRemoteMessageProviding {
var remoteMessagePublisher: AnyPublisher<RemoteMessageModel?, Never> {
$remoteMessage.dropFirst().eraseToAnyPublisher()
$remoteMessage
.dropFirst()
.filter { $0?.isForTabBar == true }
.eraseToAnyPublisher()
}

func isMessageSupported(_ message: RemoteMessageModel) -> Bool {
Expand Down
7 changes: 7 additions & 0 deletions DuckDuckGo/RemoteMessaging/ActiveRemoteMessageModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,10 @@ extension RemoteMessageModelType {
}
}
}

extension RemoteMessageModel {

var isForTabBar: Bool {
return id == TabBarRemoteMessage.tabBarPermanentSurveyRemoteMessageId
}
}
2 changes: 1 addition & 1 deletion DuckDuckGo/RemoteMessaging/RemoteMessagingClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class RemoteMessagingClient: RemoteMessagingProcessing {
static let minimumConfigurationRefreshInterval: TimeInterval = 60 * 30
static let endpoint: URL = {
#if DEBUG
URL(string: "https://raw.githubusercontent.com/duckduckgo/remote-messaging-config/main/samples/ios/sample1.json")!
URL(string: "https://www.jsonblob.com/api/1316017217598578688")!
#else
URL(string: "https://staticcdn.duckduckgo.com/remotemessaging/config/v1/macos-config.json")!
#endif
Expand Down
Loading

0 comments on commit e879230

Please sign in to comment.