Skip to content

New feature: dismiss event from notification #781

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

gsbernstein
Copy link
Contributor

@gsbernstein gsbernstein commented Nov 20, 2024

Status

READY

Description

I often found myself wanting to dismiss events from the notification, rather than dismissing the notification and then opening the menu and then dismissing the event.

Also:

  • consolidated handling of events in the response handler
  • fixed a couple minor typos

Note:

  • for personal use, I have disabled the notification_next_meeting_dismissed_title notification triggered by dismissing. I find it more annoying than useful. This change might make that even more apparent. I'd be happy to remove that as well or add it as an option to settings.

Checklist

Steps to Test or Reproduce

  • create an event in the near future
  • await notification
  • open the notification actions
  • select "dismiss"

Summary by CodeRabbit

  • New Features
    • Added the ability to dismiss events directly from notifications.
  • Localization
    • Introduced a new localized label for the dismiss action in notifications.
  • Bug Fixes
    • Corrected typos in variable names, method names, and comments.
  • Documentation
    • Updated the changelog to reflect the new dismiss action feature.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. feature New feature or request labels Nov 20, 2024
> (released)

* Added action to dismiss the event from the notification

## Version 4.0.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I added to the changelogs as requested but they both seem out of date. Are they deprecated? Should I updated the PR template?

Copy link

coderabbitai bot commented Apr 15, 2025

Walkthrough

This update introduces a new feature allowing users to dismiss events directly from notifications. The notification categories "EVENT" and "SNOOZE_EVENT" now include a "Dismiss" action, with corresponding localization and code to handle the action. Several typos were corrected in method names, variable names, and comments. Refactoring was performed to improve code clarity, including extracting event dismissal logic into a helper method and updating notification handling. The changelog and UI were updated to document and reflect the new feature.

Changes

File(s) Change Summary
CHANGELOG.md, MeetingBar/Views/Changelog/Changelog.swift Added changelog entry and UI section for version 4.11, documenting the new dismiss event action in notifications.
MeetingBar/Notifications.swift, MeetingBar/Resources/Localization/en.lproj/Localizable.strings Added "Dismiss" notification action to "EVENT" and "SNOOZE_EVENT" categories and provided corresponding localization.
MeetingBar/AppDelegate.swift Refactored notification response handling for dismiss action, removed unused helper, fixed method name typo.
MeetingBar/I18N.swift Fixed typo in variable name (newBunldenewBundle) in language change logic.
MeetingBar/StatusBarItemController.swift Fixed comment and selector typos, extracted event dismissal logic into a new helper method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Notification
    participant AppDelegate
    participant StatusBarItemController

    User->>Notification: Taps "Dismiss" on event notification
    Notification->>AppDelegate: didReceive notification response (DISMISS_ACTION)
    AppDelegate->>StatusBarItemController: dismiss(event:)
    StatusBarItemController->>StatusBarItemController: Add event to dismissed list, update UI
Loading

Poem

A bunny bounced through code so bright,
Adding "Dismiss" with pure delight.
Now with a tap, events can go—
No more clutter, just let them flow!
Typos fixed and changelog penned,
Another hop, another mend.
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c12dfb5 and 09150f6.

📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • MeetingBar/AppDelegate.swift (3 hunks)
  • MeetingBar/I18N.swift (1 hunks)
  • MeetingBar/Notifications.swift (2 hunks)
  • MeetingBar/Resources /Localization /en.lproj/Localizable.strings (1 hunks)
  • MeetingBar/StatusBarItemController.swift (3 hunks)
  • MeetingBar/Views/Changelog/Changelog.swift (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
MeetingBar/Views/Changelog/Changelog.swift (1)
MeetingBar/Helpers.swift (1)
  • compareVersions (83-85)
MeetingBar/Notifications.swift (1)
MeetingBar/Extensions/String.swift (4)
  • loco (55-57)
  • loco (59-61)
  • loco (63-65)
  • loco (67-69)
🔇 Additional comments (24)
CHANGELOG.md (2)

5-9: LGTM: Properly documented the new feature in the changelog

The new changelog entry for version 4.11.0 is clear and concise, documenting the addition of the dismiss event action from notifications.


11-11: Consider reviewing the PR template to address changelog confusion

I see your comment about the changelogs being possibly out of date. The Changelog.md file is still being used alongside the SwiftUI Changelog view, so both should be kept in sync. Consider updating the PR template if it doesn't clearly specify that both need to be updated.

MeetingBar/Views/Changelog/Changelog.swift (1)

181-185: LGTM: Properly added the new feature to the changelog UI

The new version entry follows the same pattern as other changelog entries and correctly uses the same text as in the CHANGELOG.md file.

MeetingBar/I18N.swift (1)

26-27: Fixed typo in variable name

Good catch fixing the variable name from newBunlde to newBundle. This improves code readability and consistency.

MeetingBar/Resources /Localization /en.lproj/Localizable.strings (1)

328-328: LGTM: Added localization string for the new dismiss action

The new localization string adds support for the dismiss action in notifications, which is the core of this feature.

MeetingBar/StatusBarItemController.swift (4)

761-761: Fixed typo in comment

Good cleanup fixing the comment from "Refresh soruces" to "Refresh sources".


845-845: Fixed method name reference

Fixed the reference to the preferences window method to use the correct method name.


943-943: Good refactoring: Extracted dismiss logic to a new helper method

Moving the dismiss logic to a separate method is a good refactoring that enables code reuse for the new notification dismiss feature.


947-953: LGTM: Clean implementation of the dismiss event helper method

The newly extracted method contains the same functionality as before but makes it reusable from other code paths, including the new notification dismiss action. The code is clear and maintains the same behavior.

MeetingBar/Notifications.swift (3)

24-26: Good implementation of the new dismiss action

This new notification action allows users to dismiss events directly from notifications, aligning with the PR's main objective. The implementation follows the existing pattern for notification actions.


49-49: Properly added dismiss action to the event category

The dismiss action is correctly integrated into the event category's action array, maintaining a logical order of actions (join, dismiss, then snooze options).


55-55: Properly added dismiss action to the snooze event category

The dismiss action is correctly integrated into the snooze event category's action array, maintaining consistency with the event category implementation.

MeetingBar/AppDelegate.swift (12)

227-229: Good use of defer for completion handler

Using defer ensures the completion handler will always be called, even if there are early returns or exceptions in the function body. This is a great practice for maintaining the notification callback contract.


231-235: Well-structured guard statement for early validation

The guard statement effectively validates all required conditions upfront and provides an early return path if any condition fails. This makes the function more readable by eliminating nested conditionals.


238-238: Simplified event handling

Direct invocation of event.openMeeting() makes the code more concise and readable.


239-240: Good implementation of dismiss action handling

The new case properly handles the "DISMISS_ACTION" by calling statusBarItem.dismiss(event: event), implementing the main feature of this PR to allow dismissing events directly from notifications.


242-250: Simplified snooze handling

Direct calls to snoozeEventNotification make the code more readable and maintainable by removing an unnecessary helper method layer.


333-333: Fixed method name spelling

Corrected the spelling from "openPrefecencesWindow" to "openPreferencesWindow".


400-400: Updated call to renamed method

Correctly updated the call to use the renamed method openPreferencesWindow.


226-235: Good use of defer for ensuring completion handler execution

The refactoring with defer ensures the completion handler is always called, which prevents potential memory leaks. The guard statement also improves code readability by handling preconditions upfront rather than using nested conditionals.


238-241: Well-implemented dismiss action feature

The new "DISMISS_ACTION" case properly integrates with the StatusBarItemController's dismiss method. This successfully implements the feature allowing users to dismiss events directly from notifications, as described in the PR objectives.


242-250: Good simplification of snooze handling

Directly calling snoozeEventNotification instead of using a helper method simplifies the code and reduces unnecessary abstraction. This makes the code more maintainable and easier to understand.


333-333: Fixed method name typo

Corrected the spelling from openPrefecencesWindow to openPreferencesWindow, improving code consistency and readability.


400-400: Updated method call with corrected name

Properly updated the method call to use the corrected method name openPreferencesWindow.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant