Skip to content

Conversation

@pujitm
Copy link
Member

@pujitm pujitm commented Dec 13, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a mutation to delete archived notifications.
    • Enhanced notification deletion functionality to specify notification types (UNREAD or ARCHIVE).
  • Bug Fixes

    • Updated confirmation message for deleting notifications to clarify that only archived notifications will be deleted.
    • Renamed mutation references throughout the application to align with the new functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Walkthrough

The changes in this pull request rename the GraphQL mutation deleteAllNotifications to deleteArchivedNotifications. This mutation is specifically designed to delete only archived notifications. The implementation across the NotificationsResolver and NotificationsService classes has been updated to reflect this change, allowing for targeted deletion of notifications based on their type. Additionally, the confirmation message in the Sidebar.vue component has been revised to clarify that the deletion action pertains solely to archived notifications.

Changes

File Path Change Summary
api/src/graphql/schema/types/notifications/notifications.graphql Renamed mutation from deleteAllNotifications to deleteArchivedNotifications.
api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts Renamed method from deleteAllNotifications to deleteArchivedNotifications and updated logic to delete archived notifications only.
api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts Refactored deleteAllNotifications to call deleteNotifications for both UNREAD and ARCHIVE types; added deleteNotifications method.
web/components/Notifications/Sidebar.vue Updated confirmation message in confirmAndDeleteAll to specify deletion of archived notifications.
web/components/Notifications/graphql/notification.query.ts Renamed mutation from deleteAllNotifications to deleteArchivedNotifications.
web/composables/gql/gql.ts Updated GraphQL operation mapping to reference deleteArchivedNotifications instead of deleteAllNotifications.
web/composables/gql/graphql.ts Renamed mutation and document definitions from DeleteAllNotifications to deleteArchivedNotifications.
web/helpers/apollo-cache/index.ts Renamed cache management field from deleteAllNotifications to deleteArchivedNotifications.
web/package.json Updated versions of @graphql-codegen/cli and @graphql-codegen/client-preset.

Possibly related PRs

Suggested reviewers

  • mdatelle
  • zackspear
  • elibosley

🐇 In the meadow where notifications lay,
A new way to delete has come to play.
Archived whispers, gone with a cheer,
With a click, they vanish, no need for fear.
Confirmation now speaks clear and bright,
"Only the archived, out of sight!" 🌼


📜 Recent 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 80976c5 and d59985e.

⛔ Files ignored due to path filters (1)
  • web/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • web/package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/package.json

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

🧹 Outside diff range and nitpick comments (3)
api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts (2)

320-326: Refactor deleteAllNotifications to eliminate unnecessary recursion

The deleteAllNotifications method currently uses recursion to delete notifications when no type is provided. This can be simplified by directly calling deleteNotifications for both ARCHIVE and UNREAD types without recursion.

Apply this diff to simplify the method:

public async deleteAllNotifications(type?: NotificationType) {
    if (type) {
        await this.deleteNotifications(type);
    } else {
-       await this.deleteNotifications(NotificationType.ARCHIVE);
-       await this.deleteAllNotifications(NotificationType.UNREAD);
+       await this.deleteNotifications(NotificationType.ARCHIVE);
+       await this.deleteNotifications(NotificationType.UNREAD);
    }
    return this.getOverview();
}

711-711: Fix typo in comment

There's a typo in the comment: "non-numberS" should be "non-number".

api/src/graphql/schema/types/notifications/notifications.graphql (1)

23-23: Consider adding an optional type parameter for future flexibility.

While the current implementation specifically targets archived notifications, consider making the mutation more flexible by adding an optional type parameter, similar to other mutations in the schema. This would make it easier to extend functionality in the future without breaking changes.

-    deleteAllNotifications: NotificationOverview!
+    """
+    Deletes all notifications of the specified type. Defaults to ARCHIVE if not provided.
+    """
+    deleteAllNotifications(type: NotificationType): NotificationOverview!
📜 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 ff5fd8e and a2a81db.

⛔ Files ignored due to path filters (1)
  • api/src/graphql/generated/api/types.ts is excluded by !**/generated/**
📒 Files selected for processing (4)
  • api/src/graphql/schema/types/notifications/notifications.graphql (1 hunks)
  • api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts (2 hunks)
  • api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts (2 hunks)
  • web/components/Notifications/Sidebar.vue (1 hunks)
🔇 Additional comments (3)
api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts (1)

77-77: Ensure deleteAllNotifications deletes only archived notifications

The deleteAllNotifications mutation now specifies NotificationType.ARCHIVE, ensuring only archived notifications are deleted, which aligns with the intended functionality.

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

25-25: Confirmation message accurately reflects action

The updated confirmation message correctly specifies that only archived notifications will be permanently deleted.

api/src/graphql/schema/types/notifications/notifications.graphql (1)

20-22: LGTM! Clear documentation of the mutation's purpose.

The description accurately reflects that this mutation deletes archived notifications, aligning with the PR objective.

@github-actions
Copy link
Contributor

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/983/dynamix.unraid.net.staging.plg

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: 1

🧹 Outside diff range and nitpick comments (1)
api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts (1)

704-704: Fix typo in comment.

There's a typo in the comment: "non-numberS" should be "non-number".

-        // i.e. if unixStringSeconds is an empty string or represents a non-numberS
+        // i.e. if unixStringSeconds is an empty string or represents a non-number
📜 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 a2a81db and 1e79e1a.

⛔ Files ignored due to path filters (1)
  • api/src/graphql/generated/api/types.ts is excluded by !**/generated/**
📒 Files selected for processing (4)
  • api/src/graphql/schema/types/notifications/notifications.graphql (1 hunks)
  • api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts (2 hunks)
  • api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts (2 hunks)
  • web/components/Notifications/Sidebar.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • api/src/graphql/schema/types/notifications/notifications.graphql
  • web/components/Notifications/Sidebar.vue
  • api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts
🔇 Additional comments (1)
api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts (1)

295-310: LGTM! Well-structured implementation of type-specific notification deletion.

The method correctly handles both the file system operations and state management, ensuring that the overview stats are properly reset after deletion.

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

🧹 Outside diff range and nitpick comments (1)
api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts (1)

Line range hint 704-708: Fix typo in comment.

There's a typo in the comment: "non-numberS" should be "non-number".

Apply this diff to fix the typo:

- // i.e. if unixStringSeconds is an empty string or represents a non-numberS
+ // i.e. if unixStringSeconds is an empty string or represents a non-number
📜 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 1e79e1a and 1878d3e.

⛔ Files ignored due to path filters (1)
  • api/src/graphql/generated/api/types.ts is excluded by !**/generated/**
📒 Files selected for processing (4)
  • api/src/graphql/schema/types/notifications/notifications.graphql (1 hunks)
  • api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts (2 hunks)
  • api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts (2 hunks)
  • web/components/Notifications/Sidebar.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • web/components/Notifications/Sidebar.vue
  • api/src/graphql/schema/types/notifications/notifications.graphql
  • api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts
🔇 Additional comments (2)
api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts (2)

295-310: LGTM! Well-structured implementation of type-specific notification deletion.

The method correctly handles both the file system operations and stats reset, with proper documentation.


311-321: ⚠️ Potential issue

Implementation doesn't match PR objective.

The current implementation deletes both archived and unread notifications, but according to the PR objective, it should only delete archived notifications.

Apply this diff to align with the PR objective:

/**
- * Deletes all notifications from disk while preserving the directory structure.
+ * Deletes all archived notifications from disk while preserving the directory structure.
 * Resets overview stats to zero.
 *
 * @returns The updated notification overview stats
 */
public async deleteAllNotifications() {
    await this.deleteNotifications(NotificationType.ARCHIVE);
-   await this.deleteNotifications(NotificationType.UNREAD);
    return this.getOverview();
}

Likely invalid or redundant comment.

@github-actions
Copy link
Contributor

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/983/dynamix.unraid.net.staging.plg

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

🧹 Outside diff range and nitpick comments (3)
web/components/Notifications/graphql/notification.query.ts (1)

71-73: Update GraphQL operation name to match mutation name

The exported constant has been correctly renamed to deleteArchivedNotifications, but the GraphQL operation name is still DeleteAllNotifications. For better maintainability and consistency, consider updating the operation name as well.

export const deleteArchivedNotifications = graphql(/* GraphQL */ `
-  mutation DeleteAllNotifications {
+  mutation DeleteArchivedNotifications {
    deleteArchivedNotifications {
web/composables/gql/gql.ts (1)

23-23: Maintain consistency with operation name change

Related to the operation name change suggested in notification.query.ts, update the operation name here as well for consistency.

"\n  mutation DeleteAllNotifications {\n    deleteArchivedNotifications {\n
+"\n  mutation DeleteArchivedNotifications {\n    deleteArchivedNotifications {\n

Also applies to: 76-76

web/composables/gql/graphql.ts (1)

1700-1700: Maintain consistency with operation name change

Related to the operation name changes suggested in notification.query.ts and gql.ts, update the operation name here as well for consistency. Also consider renaming the type from DeleteAllNotificationsMutation to DeleteArchivedNotificationsMutation to better reflect its purpose.

-export type DeleteAllNotificationsMutation = { __typename?: 'Mutation',
+export type DeleteArchivedNotificationsMutation = { __typename?: 'Mutation',

Also applies to: 1760-1760

📜 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 1878d3e and b0386e6.

⛔ Files ignored due to path filters (1)
  • api/src/graphql/generated/api/types.ts is excluded by !**/generated/**
📒 Files selected for processing (6)
  • api/src/graphql/schema/types/notifications/notifications.graphql (1 hunks)
  • api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts (2 hunks)
  • web/components/Notifications/Sidebar.vue (2 hunks)
  • web/components/Notifications/graphql/notification.query.ts (1 hunks)
  • web/composables/gql/gql.ts (2 hunks)
  • web/composables/gql/graphql.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • web/components/Notifications/Sidebar.vue
  • api/src/graphql/schema/types/notifications/notifications.graphql
  • api/src/unraid-api/graph/resolvers/notifications/notifications.resolver.ts

@github-actions
Copy link
Contributor

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/983/dynamix.unraid.net.staging.plg

@pujitm pujitm requested a review from elibosley December 13, 2024 19:15
elibosley
elibosley previously approved these changes Dec 13, 2024
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

🧹 Outside diff range and nitpick comments (1)
web/helpers/apollo-cache/index.ts (1)

Line range hint 188-193: Add documentation for consistency with other mutation fields.

The implementation looks good and follows the established patterns in the codebase. However, for consistency with other mutation fields like archiveAll and deleteNotification, consider adding documentation that explains the cache behavior.

Add documentation above the merge function:

 deleteArchivedNotifications: {
+          /**
+           * Clears the notifications cache when archived notifications are deleted
+           * to ensure that notification queries are invalidated and refetched.
+           *
+           * @param _ - Existing cache value (unused)
+           * @param incoming - Result from the server
+           * @param context - Apollo context containing cache instance
+           * @returns The incoming result to be cached
+           */
           merge(_, incoming, { cache }) {
             cache.evict({ fieldName: 'notifications' });
             cache.gc();
             return incoming;
           },
         },
📜 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 b8c2f0e and f2e4564.

📒 Files selected for processing (1)
  • web/helpers/apollo-cache/index.ts (1 hunks)

@github-actions
Copy link
Contributor

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/983/dynamix.unraid.net.staging.plg

@github-actions
Copy link
Contributor

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/983/dynamix.unraid.net.staging.plg

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