Skip to content

Conversation

@pujitm
Copy link
Member

@pujitm pujitm commented Jan 6, 2025

Clears notification indicator in upc after opening sidebar (including warning/alert state). Comes back if new notifications arrive.


Summary by CodeRabbit

  • New Features

    • Enhanced notification tracking with a new seen state
    • Added ability to track whether user has viewed notifications
  • Bug Fixes

    • Improved notification visibility logic to prevent unnecessary indicator displays
  • Refactor

    • Updated notification component to provide more precise rendering conditions

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

Walkthrough

The pull request introduces a new seen property to the Notifications Indicator component, enhancing the tracking of user interaction with notifications. In the Sidebar component, a reactive reference hasSeenNotifications is added to manage the viewed state of notifications. This change modifies the rendering logic of notification indicators and adds a new method to prepare for viewing notifications, providing more granular control over notification visibility and user interaction.

Changes

File Changes
web/components/Notifications/Indicator.vue - Added optional seen boolean prop
- Updated rendering conditions for unread indicator and icon
web/components/Notifications/Sidebar.vue - Added hasSeenNotifications reactive reference
- Created prepareToViewNotifications method
- Modified SheetTrigger click event
- Added :seen prop to NotificationsIndicator

Sequence Diagram

sequenceDiagram
    participant User
    participant Sidebar
    participant Indicator
    
    User->>Sidebar: Click Notifications
    Sidebar->>Sidebar: prepareToViewNotifications()
    Sidebar->>Indicator: Pass seen=true
    Indicator->>Indicator: Update visibility
Loading

Possibly related PRs

  • /api#968: Modifies the Indicator.vue component, sharing similar changes to notification rendering logic

Poem

🐰 Notifications dance and play,
With seen prop, they find their way!
A rabbit's tale of UI delight,
Tracking views with logic bright 🔔
Sidebar and Indicator in sync today! 🎉

Warning

Review ran into problems

🔥 Problems

GitHub Actions: Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository.

Please grant the required permissions to the CodeRabbit GitHub App under the organization or repository settings.


🪧 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. (Beta)
  • @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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
web/components/Notifications/Indicator.vue (1)

6-6: Ensure a default for the new boolean prop.
If the seen prop remains undefined, !seen will evaluate to true, which might incorrectly display the indicator. Consider a default value of false or making the prop required.

-const props = defineProps<{ overview?: OverviewQuery['notifications']['overview'], seen?: boolean }>();
+const props = defineProps<{
+  overview?: OverviewQuery['notifications']['overview'];
+  seen?: boolean;
+}>({
+  seen: {
+    type: Boolean,
+    default: false
+  }
+});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 03e2fee and 5c69a37.

📒 Files selected for processing (2)
  • web/components/Notifications/Indicator.vue (2 hunks)
  • web/components/Notifications/Sidebar.vue (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build and Test API
  • GitHub Check: Build Web App
🔇 Additional comments (6)
web/components/Notifications/Indicator.vue (2)

45-45: Conditional logic for the unread indicator looks correct.
No issues identified; the condition effectively avoids displaying the badge if notifications have been seen or if there are no unread notifications.


50-50: Good fallback for the icon.
The v-else-if logic ensures that when the indicator is not an unread badge but is a warning/alert, it will still display, provided seen is false. This approach is straightforward and clear.

web/components/Notifications/Sidebar.vue (4)

42-45: Excellent approach to track notification visibility.
Defining a reactive ref hasSeenNotifications elegantly captures whether the user has viewed their notifications.


46-55: Watch logic effectively resets the seen state.
When new unread notifications arrive, hasSeenNotifications is promptly reset to false. This is a solid approach, but please confirm you’ve considered scenarios where unread might decrease and then increase again.


57-60: Well-named function to prepare the UI for viewing.
prepareToViewNotifications() is clear in intent. The sequence of calling determineTeleportTarget() before marking notifications as seen seems logical.


65-67: Prop binding aligns with new indicator logic.
Passing :seen="hasSeenNotifications" to the NotificationsIndicator completes the feature, ensuring the indicator immediately reflects whether notifications have been viewed.

@pujitm pujitm requested a review from elibosley January 6, 2025 15:58
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2025

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL: https://preview.dl.unraid.net/unraid-api/pr/1001/dynamix.unraid.net.staging.plg

Copy link
Member

@elibosley elibosley left a comment

Choose a reason for hiding this comment

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

This is great!

@pujitm pujitm merged commit 68958d1 into main Jan 8, 2025
9 checks passed
@pujitm pujitm deleted the feat/unread-notif-ux branch January 8, 2025 15:48
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.

3 participants