fix: extract notification utility functions for better code organizat… #29

Merged
uz1mani merged 1 commits from staging into main 2026-02-16 19:55:13 +00:00
uz1mani commented 2026-02-16 19:55:07 +00:00 (Migrated from github.com)

fix: extract notification utility functions for better code organization and reuse in NotificationsPage and NotificationCenter

fix: extract notification utility functions for better code organization and reuse in NotificationsPage and NotificationCenter
greptile-apps[bot] commented 2026-02-16 19:57:04 +00:00 (Migrated from github.com)

Greptile Summary

This PR extracts duplicated notification utility functions (formatTimeAgo and getTypeIcon) from NotificationsPage and NotificationCenter into a shared utility file at lib/utils/notifications.tsx. This reduces code duplication and improves maintainability. Additionally, it fixes missing dependencies in React Hook dependency arrays in OrganizationSettings.tsx, which resolves potential stale closure issues.

Key changes:

  • Created new utility file lib/utils/notifications.tsx with formatTimeAgo and getTypeIcon functions
  • Updated NotificationsPage and NotificationCenter to import utilities instead of duplicating code
  • Fixed React Hook dependency warnings in OrganizationSettings by adding user?.role and handleTabChange to dependency arrays

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The refactoring is straightforward - extracting duplicate functions to a shared utility file with no logic changes. The React Hook dependency fixes address potential bugs. All changes are clean, well-structured, and follow best practices.
  • No files require special attention

Important Files Changed

Filename Overview
lib/utils/notifications.tsx created new utility file with extracted formatTimeAgo and getTypeIcon functions, improving code reusability
app/notifications/page.tsx removed duplicate utility functions and imported them from the new shared utility file
components/notifications/NotificationCenter.tsx removed duplicate utility functions and imported them from the new shared utility file
components/settings/OrganizationSettings.tsx fixed React Hook dependency arrays by adding missing dependencies, improving hooks stability

Flowchart

flowchart TD
    A[lib/utils/notifications.tsx] -->|exports| B[formatTimeAgo]
    A -->|exports| C[getTypeIcon]
    B -->|imported by| D[app/notifications/page.tsx]
    B -->|imported by| E[components/notifications/NotificationCenter.tsx]
    C -->|imported by| D
    C -->|imported by| E
    
    style A fill:#22c55e,stroke:#16a34a,color:#fff
    style B fill:#3b82f6,stroke:#2563eb,color:#fff
    style C fill:#3b82f6,stroke:#2563eb,color:#fff
    style D fill:#8b5cf6,stroke:#7c3aed,color:#fff
    style E fill:#8b5cf6,stroke:#7c3aed,color:#fff

Last reviewed commit: 3b9f33b

<h3>Greptile Summary</h3> This PR extracts duplicated notification utility functions (`formatTimeAgo` and `getTypeIcon`) from `NotificationsPage` and `NotificationCenter` into a shared utility file at `lib/utils/notifications.tsx`. This reduces code duplication and improves maintainability. Additionally, it fixes missing dependencies in React Hook dependency arrays in `OrganizationSettings.tsx`, which resolves potential stale closure issues. Key changes: - Created new utility file `lib/utils/notifications.tsx` with `formatTimeAgo` and `getTypeIcon` functions - Updated `NotificationsPage` and `NotificationCenter` to import utilities instead of duplicating code - Fixed React Hook dependency warnings in `OrganizationSettings` by adding `user?.role` and `handleTabChange` to dependency arrays <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with no issues found - The refactoring is straightforward - extracting duplicate functions to a shared utility file with no logic changes. The React Hook dependency fixes address potential bugs. All changes are clean, well-structured, and follow best practices. - No files require special attention <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | lib/utils/notifications.tsx | created new utility file with extracted `formatTimeAgo` and `getTypeIcon` functions, improving code reusability | | app/notifications/page.tsx | removed duplicate utility functions and imported them from the new shared utility file | | components/notifications/NotificationCenter.tsx | removed duplicate utility functions and imported them from the new shared utility file | | components/settings/OrganizationSettings.tsx | fixed React Hook dependency arrays by adding missing dependencies, improving hooks stability | </details> </details> <h3>Flowchart</h3> ```mermaid flowchart TD A[lib/utils/notifications.tsx] -->|exports| B[formatTimeAgo] A -->|exports| C[getTypeIcon] B -->|imported by| D[app/notifications/page.tsx] B -->|imported by| E[components/notifications/NotificationCenter.tsx] C -->|imported by| D C -->|imported by| E style A fill:#22c55e,stroke:#16a34a,color:#fff style B fill:#3b82f6,stroke:#2563eb,color:#fff style C fill:#3b82f6,stroke:#2563eb,color:#fff style D fill:#8b5cf6,stroke:#7c3aed,color:#fff style E fill:#8b5cf6,stroke:#7c3aed,color:#fff ``` <sub>Last reviewed commit: 3b9f33b</sub>
Sign in to join this conversation.
No description provided.