287 lines
6.0 KiB
Markdown
287 lines
6.0 KiB
Markdown
# Implementation Checklist: Unified Refresh System
|
|
|
|
## 📋 Step-by-Step Implementation Guide
|
|
|
|
### Phase 1: Foundation (Day 1) ⚡ CRITICAL
|
|
|
|
#### ✅ Step 1.1: Create Refresh Manager
|
|
- [ ] Create `lib/services/refresh-manager.ts`
|
|
- [ ] Test singleton pattern
|
|
- [ ] Test register/unregister
|
|
- [ ] Test start/stop
|
|
- [ ] Test deduplication logic
|
|
|
|
**Estimated Time**: 2-3 hours
|
|
|
|
---
|
|
|
|
#### ✅ Step 1.2: Create Request Deduplication
|
|
- [ ] Create `lib/utils/request-deduplication.ts`
|
|
- [ ] Test deduplication with same key
|
|
- [ ] Test TTL expiration
|
|
- [ ] Test cleanup
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 1.3: Create Constants
|
|
- [ ] Create `lib/constants/refresh-intervals.ts`
|
|
- [ ] Define all intervals
|
|
- [ ] Export helper function
|
|
|
|
**Estimated Time**: 30 minutes
|
|
|
|
---
|
|
|
|
#### ✅ Step 1.4: Create Unified Hook
|
|
- [ ] Create `hooks/use-unified-refresh.ts`
|
|
- [ ] Test registration on mount
|
|
- [ ] Test cleanup on unmount
|
|
- [ ] Test manual refresh
|
|
|
|
**Estimated Time**: 1-2 hours
|
|
|
|
---
|
|
|
|
### Phase 2: Fix Critical Issues (Day 1-2) 🔴 URGENT
|
|
|
|
#### ✅ Step 2.1: Fix Redis KEYS → SCAN
|
|
- [ ] Update `lib/services/notifications/notification-service.ts` line 293
|
|
- [ ] Replace `redis.keys()` with `redis.scan()`
|
|
- [ ] Test with large key sets
|
|
|
|
**Estimated Time**: 30 minutes
|
|
|
|
---
|
|
|
|
#### ✅ Step 2.2: Fix Notification Hook Memory Leak
|
|
- [ ] Fix `hooks/use-notifications.ts` useEffect cleanup
|
|
- [ ] Remove function dependencies
|
|
- [ ] Test cleanup on unmount
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 2.3: Fix Notification Badge Double Fetch
|
|
- [ ] Update `components/notification-badge.tsx`
|
|
- [ ] Remove duplicate useEffect hooks
|
|
- [ ] Add request deduplication
|
|
- [ ] Test single fetch per action
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
### Phase 3: Refactor Notifications (Day 2) 🟡 HIGH PRIORITY
|
|
|
|
#### ✅ Step 3.1: Refactor useNotifications Hook
|
|
- [ ] Integrate unified refresh
|
|
- [ ] Add request deduplication
|
|
- [ ] Remove manual polling
|
|
- [ ] Test all functionality
|
|
|
|
**Estimated Time**: 2-3 hours
|
|
|
|
---
|
|
|
|
#### ✅ Step 3.2: Update Notification Badge
|
|
- [ ] Remove manual fetch logic
|
|
- [ ] Use hook's refresh function
|
|
- [ ] Test UI interactions
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
### Phase 4: Refactor Widgets (Day 3-4) 🟢 MEDIUM PRIORITY
|
|
|
|
#### ✅ Step 4.1: Refactor Calendar Widget
|
|
- [ ] Update `components/calendar.tsx`
|
|
- [ ] Use unified refresh hook
|
|
- [ ] Add request deduplication
|
|
- [ ] Test refresh functionality
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 4.2: Refactor Parole Widget
|
|
- [ ] Update `components/parole.tsx`
|
|
- [ ] Use unified refresh hook
|
|
- [ ] Remove manual interval
|
|
- [ ] Test chat updates
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 4.3: Refactor News Widget
|
|
- [ ] Update `components/news.tsx`
|
|
- [ ] Use unified refresh hook
|
|
- [ ] Add auto-refresh (was manual only)
|
|
- [ ] Test news updates
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 4.4: Refactor Email Widget
|
|
- [ ] Update `components/email.tsx`
|
|
- [ ] Use unified refresh hook
|
|
- [ ] Add auto-refresh (was manual only)
|
|
- [ ] Test email updates
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 4.5: Refactor Duties Widget
|
|
- [ ] Update `components/flow.tsx`
|
|
- [ ] Use unified refresh hook
|
|
- [ ] Add auto-refresh (was manual only)
|
|
- [ ] Test task updates
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 4.6: Refactor Navigation Bar Time
|
|
- [ ] Create `components/main-nav-time.tsx`
|
|
- [ ] Update `components/main-nav.tsx` to use new component
|
|
- [ ] Use unified refresh hook (1 second interval)
|
|
- [ ] Test time updates correctly
|
|
- [ ] Verify cleanup on unmount
|
|
|
|
**Estimated Time**: 30 minutes
|
|
|
|
---
|
|
|
|
### Phase 5: Testing & Validation (Day 5) ✅ FINAL
|
|
|
|
#### ✅ Step 5.1: Memory Leak Testing
|
|
- [ ] Open DevTools Memory tab
|
|
- [ ] Monitor memory over 10 minutes
|
|
- [ ] Verify no memory leaks
|
|
- [ ] Check interval cleanup
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 5.2: API Call Reduction Testing
|
|
- [ ] Open DevTools Network tab
|
|
- [ ] Monitor API calls for 5 minutes
|
|
- [ ] Verify deduplication works
|
|
- [ ] Count total calls (should be ~60% less)
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 5.3: Performance Testing
|
|
- [ ] Test page load time
|
|
- [ ] Test widget refresh times
|
|
- [ ] Test with multiple tabs open
|
|
- [ ] Verify no performance degradation
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
#### ✅ Step 5.4: User Experience Testing
|
|
- [ ] Test all widgets refresh correctly
|
|
- [ ] Test manual refresh buttons
|
|
- [ ] Test notification updates
|
|
- [ ] Verify smooth UX
|
|
|
|
**Estimated Time**: 1 hour
|
|
|
|
---
|
|
|
|
## 🎯 Daily Progress Tracking
|
|
|
|
### Day 1 Target:
|
|
- [x] Phase 1: Foundation (Steps 1.1-1.4)
|
|
- [x] Phase 2: Critical Fixes (Steps 2.1-2.3)
|
|
|
|
**Status**: ⏳ In Progress
|
|
|
|
---
|
|
|
|
### Day 2 Target:
|
|
- [ ] Phase 3: Notifications (Steps 3.1-3.2)
|
|
|
|
**Status**: ⏸️ Pending
|
|
|
|
---
|
|
|
|
### Day 3 Target:
|
|
- [ ] Phase 4: Widgets Part 1 (Steps 4.1-4.2)
|
|
|
|
**Status**: ⏸️ Pending
|
|
|
|
---
|
|
|
|
### Day 4 Target:
|
|
- [ ] Phase 4: Widgets Part 2 (Steps 4.3-4.5)
|
|
|
|
**Status**: ⏸️ Pending
|
|
|
|
---
|
|
|
|
### Day 5 Target:
|
|
- [ ] Phase 5: Testing (Steps 5.1-5.4)
|
|
|
|
**Status**: ⏸️ Pending
|
|
|
|
---
|
|
|
|
## 🐛 Known Issues to Watch For
|
|
|
|
1. **Race Conditions**: Monitor for duplicate requests
|
|
2. **Memory Leaks**: Watch for uncleaned intervals
|
|
3. **Performance**: Monitor API call frequency
|
|
4. **User Experience**: Ensure smooth refresh transitions
|
|
|
|
---
|
|
|
|
## 📊 Success Criteria
|
|
|
|
### Must Have:
|
|
- ✅ No memory leaks
|
|
- ✅ 60%+ reduction in API calls
|
|
- ✅ All widgets refresh correctly
|
|
- ✅ No duplicate requests
|
|
|
|
### Nice to Have:
|
|
- ✅ Configurable refresh intervals
|
|
- ✅ Pause/resume functionality
|
|
- ✅ Refresh status monitoring
|
|
- ✅ Error recovery
|
|
|
|
---
|
|
|
|
## 🔄 Rollback Plan
|
|
|
|
If issues arise:
|
|
|
|
1. **Keep old code**: Don't delete old implementations immediately
|
|
2. **Feature flag**: Use environment variable to toggle new/old system
|
|
3. **Gradual migration**: Migrate one widget at a time
|
|
4. **Monitor**: Watch for errors in production
|
|
|
|
---
|
|
|
|
## 📝 Notes
|
|
|
|
- All new code should be backward compatible
|
|
- Test each phase before moving to next
|
|
- Document any deviations from plan
|
|
- Update this checklist as you progress
|
|
|
|
---
|
|
|
|
*Last Updated: Implementation Checklist v1.0*
|