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

Implement static prompts for add to dock #3790

Merged
merged 22 commits into from
Jan 31, 2025

Conversation

jotaemepereira
Copy link
Collaborator

@jotaemepereira jotaemepereira commented Jan 27, 2025

Task/Issue URL: https://app.asana.com/0/1204006570077678/1209173259474635/f
Tech Design URL:
CC:

Description

This adds new static entry points to add to the dock. Now, the adding to dock setting can be used from the main menu, and more options menu, and also in the Settings -> Default Browser -> Shortcuts section.

In the more options menu, we will show a blue dot (both in the more options button and in the menu item), the notification dot will disappear after the user opens and closes the more options menu. If you want to check the blue dot again, I’ve added a debug menu in the Reset Data -> Reset Add To Dock more options menu notification.

Acceptance criteria

AC1 - AppStore users should not see any Add To Dock prompt
Given an AppStore user, when the user does not have DDG in the dock, then it should never see one of the prompts.

AC2 - If the user is non-AppStore, and DDG is not in the dock.
Given a non-AppStore user, when the user does not have DDG in the dock, then the user should see a 'Add to Dock' prompt on the main menu, more options, and in the Settings → Default Browser preference pane.

AC3 - If the user is non-AppStore, and DDG is in the dock.
Given a non-AppStore user, when the user does have DDG in the dock, then the user should not see the 'Add to Dock' prompt on the main menu and more options, and in Settings → Default Browser, you should see 'DuckDuckGo is in your Dock.

Definition of Done:


Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

Copy link
Contributor

github-actions bot commented Jan 27, 2025

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.
Messages
📖

You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See Localization Guidelines for more information.

Generated by 🚫 dangerJS against c32421f

@jotaemepereira jotaemepereira requested a review from ayoy January 27, 2025 18:05
@jotaemepereira jotaemepereira force-pushed the juan/implement-static-prompts-for-add-to-dock branch 2 times, most recently from 830f4fb to 9ca4c67 Compare January 29, 2025 17:57
@jotaemepereira jotaemepereira force-pushed the juan/implement-static-prompts-for-add-to-dock branch from 9ca4c67 to f64d4c1 Compare January 29, 2025 18:15
Copy link
Collaborator

@ayoy ayoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jotaemepereira! The feature works great 👏 I've left some comments in the code as I think it would be great to have it cleaned up a bit. Let me know if you have any concerns about it. Thanks!

@@ -663,6 +663,7 @@ struct UserText {
static let isAddedToDock = NSLocalizedString("preferences.is-added-to-dock", value: "DuckDuckGo is added to the Dock.", comment: "Indicates that the browser is added to the macOS system Dock")
static let isNotAddedToDock = NSLocalizedString("preferences.not-added-to-dock", value: "DuckDuckGo is not added to the Dock.", comment: "Indicate that the browser is not added to macOS system Dock")
static let addToDock = NSLocalizedString("preferences.add-to-dock", value: "Add to Dock…", comment: "Action button to add the app to the Dock")
static let addDuckDuckGoToDock = NSLocalizedString("preferences.add-to-dock", value: "Add DuckDuckGo To Dock…", comment: "Action button to add the app to the Dock")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this has been reviewed already, but usually the word to in macOS menus seems to be lowercase. Just dropping a note that we may want to change this:
Screenshot 2025-01-28 at 15 15 44

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, copy was approved, but I can bring this to their attention.

@State private var isHovered: Bool = false

var body: some View {
ZStack {
Copy link
Collaborator

@ayoy ayoy Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body of this body looks misaligned :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good eye 😬 . Fixed!

@@ -188,6 +216,16 @@ final class MoreOptionsMenu: NSMenu, NSMenuDelegate {
addItem(preferencesItem)
}

private func createMenuItemWithFeatureIndicator(title: String, image: NSImage, onTap: @escaping () -> Void) -> NSView {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great job on it. I probably wouldn't consider going with SwiftUI there :) it looks indistinguishable from a regular menu item though 💪

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I ran out of ideas of how to add the custom circle to the right, maybe something easier was out there and I missed it 😅 .

Comment on lines 43 to 44
var wasFeatureShownPublisher: AnyPublisher<Bool, Never> {
$isFeatureShownFromMoreOptionsMenu.eraseToAnyPublisher()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using present and past tense in the same context? Passive voice is a bit strange in API naming, so perhaps we could call everything didShowFeatureFromMoreOptionsMenu (and didShowPublisher)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Because I’m bad at naming 😂 . Let me user your approach.

@@ -438,6 +443,11 @@ final class MainMenu: NSMenu {
override func update() {
super.update()

#if !APPSTORE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be a pain, and I recall telling you about NSApp.isSandboxed earlier just to add to the mix...

I see that we're using #if !APPSTORE and #if SPARKLE in parts of the implementation. And then NSApp.isSandboxed in unit tests. Would it be possible to unify these approaches? Ultimately it's sandboxing that prevents us from adding to Dock so perhaps we could use NSApp.isSandboxed everywhere? Otherwise just rely on either SPARKLE or !APPSTORE.

Copy link
Collaborator Author

@jotaemepereira jotaemepereira Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not a pain at all, and I agree that we should be consistent.

The big difference between the two is that using a compilation flag does not include the code in the binary while using NSApp.isSandboxed adds it.
The compilation flag seems safer, given that the App Store build would not compile, while the second one is easier to mock, but could lead to a possible issue if something messes up the NSApp.isSandboxed

I’m going to play the safe approach and use the compilation flag, I’m going to use SPARKLE build because it easier to read that using the negative.

@jotaemepereira jotaemepereira requested a review from ayoy January 30, 2025 19:42
Copy link
Collaborator

@ayoy ayoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great now, thanks @jotaemepereira!

@jotaemepereira jotaemepereira merged commit 8080c1f into main Jan 31, 2025
20 checks passed
@jotaemepereira jotaemepereira deleted the juan/implement-static-prompts-for-add-to-dock branch January 31, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants