docs(p2.1): Fix baseline tag drift and create method-service mapping
Fixed baseline tag drift issue: - docs/00-INDEX.md now references docs/progress/00-STATUS.md as canonical baseline - docs/progress/00-STATUS.md marked as canonical baseline authority Created Priority 2.1 mapping and batch planning: - docs/progress/P2.1-METHOD-SERVICE-MAP.md: Complete method-to-service mapping - docs/progress/P2.1-BATCH-1.md: First batch (pure delegation, ~15 methods) - docs/progress/P2.1-BATCH-2.md: Second batch (validation + delegation, ~20 methods) Batch 1 focuses on read-only operations (lowest risk). Batch 2 focuses on validation + delegation (medium risk). Expected reduction: ~1,650-2,000 lines across both platforms. Verification: - Baseline authority fixed ✅ - Method mapping complete ✅ - Batch plans created ✅
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
**Purpose:** Single navigation hub for active documentation; separates contracts, progress truth, guides, and archived/reference-only material.
|
||||
**Owner:** Development Team
|
||||
**Last Updated:** 2025-12-22
|
||||
**Last Updated:** 2025-12-23
|
||||
**Status:** active
|
||||
**Baseline Tag:** `v1.0.11-p0-p1.4-complete`
|
||||
**Baseline:** See `docs/progress/00-STATUS.md` for current baseline tag
|
||||
|
||||
This index provides organized access to all documentation in the repository. For a complete audit trail of file movements, see [CONSOLIDATION_SOURCE_MAP.md](./CONSOLIDATION_SOURCE_MAP.md).
|
||||
|
||||
|
||||
230
docs/progress/P2.1-BATCH-1.md
Normal file
230
docs/progress/P2.1-BATCH-1.md
Normal file
@@ -0,0 +1,230 @@
|
||||
# Priority 2.1: Batch 1 - Pure Delegation Methods
|
||||
|
||||
**Purpose:** First refactoring batch focusing on pure delegation (lowest risk).
|
||||
**Owner:** Development Team
|
||||
**Last Updated:** 2025-12-23
|
||||
**Status:** planned
|
||||
**Baseline:** See `docs/progress/00-STATUS.md`
|
||||
|
||||
---
|
||||
|
||||
## Batch 1 Scope
|
||||
|
||||
**Goal:** Refactor methods that are pure delegation (no transformation, minimal validation).
|
||||
|
||||
**Risk Level:** ⭐ Low (read-only operations, no state mutation)
|
||||
|
||||
**Estimated Impact:** ~15-20 methods across both platforms
|
||||
|
||||
---
|
||||
|
||||
## Android Methods
|
||||
|
||||
### Status & Health (Read-Only)
|
||||
|
||||
1. **`getNotificationStatus()`**
|
||||
- **Current:** Direct implementation in plugin
|
||||
- **Target:** `NotificationStatusChecker.getComprehensiveStatus()`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~45 lines → ~5 lines)
|
||||
|
||||
2. **`checkStatus()`**
|
||||
- **Current:** Alias for `getNotificationStatus()`
|
||||
- **Target:** `NotificationStatusChecker.getComprehensiveStatus()`
|
||||
- **Change:** Delegate to same service method
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~55 lines → ~5 lines)
|
||||
|
||||
### Permission Checks (Read-Only)
|
||||
|
||||
3. **`checkPermissionStatus()`**
|
||||
- **Current:** Direct implementation in plugin
|
||||
- **Target:** `PermissionManager.checkNotificationPermission()`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~53 lines → ~5 lines)
|
||||
|
||||
4. **`checkPermissions()`** (override)
|
||||
- **Current:** Direct implementation in plugin
|
||||
- **Target:** `PermissionManager.checkAllPermissions()`
|
||||
- **Change:** Delegate to manager
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~43 lines → ~5 lines)
|
||||
|
||||
### Exact Alarm Status (Read-Only)
|
||||
|
||||
5. **`getExactAlarmStatus()`**
|
||||
- **Current:** Direct implementation in plugin
|
||||
- **Target:** `DailyNotificationExactAlarmManager.getStatus()`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~43 lines → ~5 lines)
|
||||
|
||||
6. **`checkExactAlarmPermission()`**
|
||||
- **Current:** Direct implementation in plugin
|
||||
- **Target:** `DailyNotificationExactAlarmManager.checkPermission()`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~23 lines → ~5 lines)
|
||||
|
||||
### Channel Status (Read-Only)
|
||||
|
||||
7. **`isChannelEnabled()`**
|
||||
- **Current:** Direct implementation in plugin
|
||||
- **Target:** `ChannelManager.isChannelEnabled(channelId)`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~77 lines → ~5 lines)
|
||||
|
||||
### Scheduling Queries (Read-Only)
|
||||
|
||||
8. **`isAlarmScheduled()`**
|
||||
- **Current:** Direct implementation in plugin
|
||||
- **Target:** `DailyNotificationScheduler.isScheduled(...)`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~24 lines → ~5 lines)
|
||||
|
||||
9. **`getNextAlarmTime()`**
|
||||
- **Current:** Direct implementation in plugin
|
||||
- **Target:** `DailyNotificationScheduler.getNextAlarmTime()`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~26 lines → ~5 lines)
|
||||
|
||||
### Content Cache (Read-Only)
|
||||
|
||||
10. **`getContentCache()`**
|
||||
- **Current:** Direct database access in plugin
|
||||
- **Target:** `DailyNotificationStorage.getContentCache(id)`
|
||||
- **Change:** Replace database access with storage service call
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~31 lines → ~5 lines)
|
||||
|
||||
---
|
||||
|
||||
## iOS Methods
|
||||
|
||||
### Permission Status (Read-Only)
|
||||
|
||||
1. **`getNotificationPermissionStatus()`**
|
||||
- **Current:** Direct `UNUserNotificationCenter` access
|
||||
- **Target:** Create `PermissionService.getStatus()` (or use existing pattern)
|
||||
- **Change:** Extract to service, delegate
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~37 lines → ~5 lines)
|
||||
|
||||
### Background Task Status (Read-Only)
|
||||
|
||||
2. **`getBackgroundTaskStatus()`**
|
||||
- **Current:** Direct `BGTaskScheduler` access
|
||||
- **Target:** `DailyNotificationBackgroundTaskManager.getStatus()`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~18 lines → ~5 lines)
|
||||
|
||||
### Scheduling Queries (Read-Only)
|
||||
|
||||
3. **`getNextScheduledNotificationTime()`**
|
||||
- **Current:** Direct scheduler access
|
||||
- **Target:** `DailyNotificationScheduler.getNextTime()`
|
||||
- **Change:** Replace implementation with service call
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~29 lines → ~5 lines)
|
||||
|
||||
### Content & History (Read-Only)
|
||||
|
||||
4. **`getLastNotification()`**
|
||||
- **Current:** Direct storage access
|
||||
- **Target:** `DailyNotificationStorage.getLastNotification()`
|
||||
- **Change:** Replace storage access with service call
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~38 lines → ~5 lines)
|
||||
|
||||
5. **`getScheduledReminders()`**
|
||||
- **Current:** Direct UserDefaults access
|
||||
- **Target:** `DailyNotificationStorage.getReminders()`
|
||||
- **Change:** Replace UserDefaults access with storage service call
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~24 lines → ~5 lines)
|
||||
|
||||
---
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### Step 1: Verify Service Methods Exist
|
||||
|
||||
- [ ] Check `NotificationStatusChecker.getComprehensiveStatus()` exists
|
||||
- [ ] Check `PermissionManager.checkNotificationPermission()` exists
|
||||
- [ ] Check `DailyNotificationExactAlarmManager.getStatus()` exists
|
||||
- [ ] Check `ChannelManager.isChannelEnabled()` exists
|
||||
- [ ] Check `DailyNotificationScheduler.isScheduled()` exists
|
||||
- [ ] Check `DailyNotificationScheduler.getNextAlarmTime()` exists
|
||||
- [ ] Check `DailyNotificationStorage.getContentCache()` exists
|
||||
- [ ] Check iOS service methods exist or need creation
|
||||
|
||||
### Step 2: Create Service Instances (if needed)
|
||||
|
||||
- [ ] Ensure plugin has service instances as private properties
|
||||
- [ ] Initialize services in `load()` method
|
||||
- [ ] Add null checks where appropriate
|
||||
|
||||
### Step 3: Refactor Android Methods
|
||||
|
||||
- [ ] Replace `getNotificationStatus()` implementation
|
||||
- [ ] Replace `checkStatus()` implementation
|
||||
- [ ] Replace `checkPermissionStatus()` implementation
|
||||
- [ ] Replace `checkPermissions()` implementation
|
||||
- [ ] Replace `getExactAlarmStatus()` implementation
|
||||
- [ ] Replace `checkExactAlarmPermission()` implementation
|
||||
- [ ] Replace `isChannelEnabled()` implementation
|
||||
- [ ] Replace `isAlarmScheduled()` implementation
|
||||
- [ ] Replace `getNextAlarmTime()` implementation
|
||||
- [ ] Replace `getContentCache()` implementation
|
||||
|
||||
### Step 4: Refactor iOS Methods
|
||||
|
||||
- [ ] Replace `getNotificationPermissionStatus()` implementation
|
||||
- [ ] Replace `getBackgroundTaskStatus()` implementation
|
||||
- [ ] Replace `getNextScheduledNotificationTime()` implementation
|
||||
- [ ] Replace `getLastNotification()` implementation
|
||||
- [ ] Replace `getScheduledReminders()` implementation
|
||||
|
||||
### Step 5: Testing
|
||||
|
||||
- [ ] Run Android unit tests
|
||||
- [ ] Run iOS unit tests
|
||||
- [ ] Run integration tests
|
||||
- [ ] Manual smoke test on both platforms
|
||||
- [ ] Verify no behavior changes
|
||||
|
||||
### Step 6: Verification
|
||||
|
||||
- [ ] Run `./ci/run.sh` (must pass)
|
||||
- [ ] Check plugin class line count reduction
|
||||
- [ ] Verify service methods are being called
|
||||
- [ ] Update progress docs
|
||||
|
||||
---
|
||||
|
||||
## Expected Outcomes
|
||||
|
||||
### Metrics
|
||||
|
||||
- **Android plugin:** ~400-500 lines removed
|
||||
- **iOS plugin:** ~150-200 lines removed
|
||||
- **Total reduction:** ~550-700 lines across both platforms
|
||||
- **Test coverage:** Maintained (no behavior changes)
|
||||
|
||||
### Benefits
|
||||
|
||||
- ✅ Plugin classes become thinner
|
||||
- ✅ Business logic moves to testable services
|
||||
- ✅ No breaking API changes
|
||||
- ✅ Lower risk (read-only operations)
|
||||
|
||||
---
|
||||
|
||||
## Rollback Plan
|
||||
|
||||
If issues arise:
|
||||
|
||||
1. Revert commits for this batch
|
||||
2. Service methods remain unchanged (no risk)
|
||||
3. Plugin methods can be restored from git history
|
||||
|
||||
---
|
||||
|
||||
## Next Batch
|
||||
|
||||
After Batch 1 completes successfully:
|
||||
|
||||
- **Batch 2:** Validation + Delegation methods (input validation, then delegate)
|
||||
- **Batch 3:** Glue methods (orchestration across multiple services)
|
||||
|
||||
309
docs/progress/P2.1-BATCH-2.md
Normal file
309
docs/progress/P2.1-BATCH-2.md
Normal file
@@ -0,0 +1,309 @@
|
||||
# Priority 2.1: Batch 2 - Validation + Delegation Methods
|
||||
|
||||
**Purpose:** Second refactoring batch focusing on methods that validate input then delegate.
|
||||
**Owner:** Development Team
|
||||
**Last Updated:** 2025-12-23
|
||||
**Status:** planned
|
||||
**Baseline:** See `docs/progress/00-STATUS.md`
|
||||
|
||||
---
|
||||
|
||||
## Batch 2 Scope
|
||||
|
||||
**Goal:** Refactor methods that validate input, then delegate to services.
|
||||
|
||||
**Risk Level:** ⭐⭐ Medium (input validation must be preserved, then delegation)
|
||||
|
||||
**Estimated Impact:** ~20-25 methods across both platforms
|
||||
|
||||
**Prerequisites:** Batch 1 must be complete and verified
|
||||
|
||||
---
|
||||
|
||||
## Android Methods
|
||||
|
||||
### Permission Requests (Validation + Delegation)
|
||||
|
||||
1. **`requestNotificationPermissions()`**
|
||||
- **Current:** Direct implementation with validation
|
||||
- **Target:** `PermissionManager.requestNotificationPermission()`
|
||||
- **Change:** Extract validation, delegate to manager
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~53 lines → ~10 lines)
|
||||
|
||||
2. **`requestPermissions()`** (override)
|
||||
- **Current:** Direct implementation with validation
|
||||
- **Target:** `PermissionManager.requestAllPermissions()`
|
||||
- **Change:** Extract validation, delegate to manager
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~8 lines → ~5 lines)
|
||||
|
||||
3. **`requestExactAlarmPermission()`**
|
||||
- **Current:** Direct implementation with validation
|
||||
- **Target:** `DailyNotificationExactAlarmManager.requestPermission()`
|
||||
- **Change:** Extract validation, delegate to manager
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~75 lines → ~10 lines)
|
||||
|
||||
### Settings Navigation (Validation + Delegation)
|
||||
|
||||
4. **`openExactAlarmSettings()`**
|
||||
- **Current:** Direct implementation with activity check
|
||||
- **Target:** `DailyNotificationExactAlarmManager.openSettings()`
|
||||
- **Change:** Extract activity validation, delegate
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~18 lines → ~5 lines)
|
||||
|
||||
5. **`openChannelSettings()`**
|
||||
- **Current:** Direct implementation with activity check
|
||||
- **Target:** `ChannelManager.openSettings(channelId)`
|
||||
- **Change:** Extract activity validation, delegate
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~83 lines → ~5 lines)
|
||||
|
||||
### Schedule Management CRUD (Validation + Delegation)
|
||||
|
||||
6. **`createSchedule()`**
|
||||
- **Current:** Direct database access with validation
|
||||
- **Target:** `DailyNotificationStorage.createSchedule(...)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~25 lines → ~10 lines)
|
||||
|
||||
7. **`updateSchedule()`**
|
||||
- **Current:** Direct database access with validation
|
||||
- **Target:** `DailyNotificationStorage.updateSchedule(...)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~39 lines → ~10 lines)
|
||||
|
||||
8. **`deleteSchedule()`**
|
||||
- **Current:** Direct database access with validation
|
||||
- **Target:** `DailyNotificationStorage.deleteSchedule(id)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~15 lines → ~5 lines)
|
||||
|
||||
9. **`enableSchedule()`**
|
||||
- **Current:** Direct database access with validation
|
||||
- **Target:** `DailyNotificationStorage.enableSchedule(id, enabled)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~15 lines → ~5 lines)
|
||||
|
||||
### Scheduling Operations (Validation + Delegation)
|
||||
|
||||
10. **`scheduleDailyNotification()`**
|
||||
- **Current:** Direct scheduler access with validation
|
||||
- **Target:** `DailyNotificationScheduler.schedule(...)`
|
||||
- **Change:** Extract validation, delegate to scheduler
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~181 lines → ~15 lines)
|
||||
|
||||
11. **`scheduleUserNotification()`**
|
||||
- **Current:** Direct scheduler access with validation
|
||||
- **Target:** `DailyNotificationScheduler.scheduleUserNotification(...)`
|
||||
- **Change:** Extract validation, delegate to scheduler
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~92 lines → ~15 lines)
|
||||
|
||||
12. **`scheduleDailyReminder()`**
|
||||
- **Current:** Direct reminder manager access with validation
|
||||
- **Target:** `DailyReminderManager.schedule(...)`
|
||||
- **Change:** Extract validation, delegate to manager
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~13 lines → ~5 lines)
|
||||
|
||||
13. **`testAlarm()`**
|
||||
- **Current:** Direct scheduler access with validation
|
||||
- **Target:** `DailyNotificationScheduler.scheduleTest(...)`
|
||||
- **Change:** Extract validation, delegate to scheduler
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~34 lines → ~10 lines)
|
||||
|
||||
### Callbacks (Validation + Delegation)
|
||||
|
||||
14. **`registerCallback()`**
|
||||
- **Current:** Direct storage access with validation
|
||||
- **Target:** `DailyNotificationStorage.registerCallback(...)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~31 lines → ~10 lines)
|
||||
|
||||
### Test Helpers (Validation + Delegation)
|
||||
|
||||
15. **`injectInvalidTestData()`**
|
||||
- **Current:** Direct database access with validation
|
||||
- **Target:** `DailyNotificationStorage.injectTestData(...)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.kt` (~94 lines → ~10 lines)
|
||||
|
||||
---
|
||||
|
||||
## iOS Methods
|
||||
|
||||
### Permission Requests (Validation + Delegation)
|
||||
|
||||
1. **`requestNotificationPermissions()`**
|
||||
- **Current:** Direct `UNUserNotificationCenter` access with async handling
|
||||
- **Target:** Create `PermissionService.requestPermissions()` or use existing pattern
|
||||
- **Change:** Extract async handling, delegate to service
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~97 lines → ~10 lines)
|
||||
|
||||
2. **`requestNotificationPermission()`**
|
||||
- **Current:** Direct `UNUserNotificationCenter` access with async handling
|
||||
- **Target:** Create `PermissionService.requestPermission()` or use existing pattern
|
||||
- **Change:** Extract async handling, delegate to service
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~29 lines → ~10 lines)
|
||||
|
||||
### Settings Navigation (Validation + Delegation)
|
||||
|
||||
3. **`openNotificationSettings()`**
|
||||
- **Current:** Direct `UIApplication` access
|
||||
- **Target:** Create `SettingsService.openNotificationSettings()` or utility
|
||||
- **Change:** Extract app context check, delegate
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~32 lines → ~5 lines)
|
||||
|
||||
4. **`openBackgroundAppRefreshSettings()`**
|
||||
- **Current:** Direct `UIApplication` access
|
||||
- **Target:** Create `SettingsService.openBackgroundRefreshSettings()` or utility
|
||||
- **Change:** Extract app context check, delegate
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~32 lines → ~5 lines)
|
||||
|
||||
5. **`openChannelSettings()`**
|
||||
- **Current:** Direct `UIApplication` access
|
||||
- **Target:** Create `SettingsService.openChannelSettings()` or utility
|
||||
- **Change:** Extract app context check, delegate
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~34 lines → ~5 lines)
|
||||
|
||||
### Schedule Management CRUD (Validation + Delegation)
|
||||
|
||||
6. **`scheduleDailyReminder()`**
|
||||
- **Current:** Direct UserDefaults access with validation
|
||||
- **Target:** `DailyNotificationStorage.storeReminder(...)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~90 lines → ~15 lines)
|
||||
|
||||
7. **`cancelDailyReminder()`**
|
||||
- **Current:** Direct UserDefaults access with validation
|
||||
- **Target:** `DailyNotificationStorage.removeReminder(id)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~17 lines → ~5 lines)
|
||||
|
||||
8. **`updateDailyReminder()`**
|
||||
- **Current:** Direct UserDefaults access with validation
|
||||
- **Target:** `DailyNotificationStorage.updateReminder(...)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~97 lines → ~15 lines)
|
||||
|
||||
### Scheduling Operations (Validation + Delegation)
|
||||
|
||||
9. **`scheduleContentFetch()`**
|
||||
- **Current:** Direct scheduler access with validation
|
||||
- **Target:** `DailyNotificationScheduler.scheduleFetch(...)`
|
||||
- **Change:** Extract validation, delegate to scheduler
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~17 lines → ~5 lines)
|
||||
|
||||
10. **`scheduleUserNotification()`**
|
||||
- **Current:** Direct scheduler access with validation
|
||||
- **Target:** `DailyNotificationScheduler.scheduleUserNotification(...)`
|
||||
- **Change:** Extract validation, delegate to scheduler
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~17 lines → ~5 lines)
|
||||
|
||||
11. **`scheduleDailyNotification()`**
|
||||
- **Current:** Direct scheduler access with validation
|
||||
- **Target:** `DailyNotificationScheduler.schedule(...)`
|
||||
- **Change:** Extract validation, delegate to scheduler
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~135 lines → ~15 lines)
|
||||
|
||||
### Configuration (Validation + Delegation)
|
||||
|
||||
12. **`configure()`**
|
||||
- **Current:** Direct storage access with validation
|
||||
- **Target:** `DailyNotificationStorage.configure(...)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~75 lines → ~10 lines)
|
||||
|
||||
13. **`updateSettings()`**
|
||||
- **Current:** Direct storage access with validation
|
||||
- **Target:** `DailyNotificationStorage.updateSettings(...)`
|
||||
- **Change:** Extract validation, delegate to storage
|
||||
- **Files:** `DailyNotificationPlugin.swift` (~60 lines → ~10 lines)
|
||||
|
||||
---
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### Step 1: Verify Service Methods Exist or Create Them
|
||||
|
||||
- [ ] Verify `PermissionManager.requestNotificationPermission()` exists (Android)
|
||||
- [ ] Verify `DailyNotificationExactAlarmManager.requestPermission()` exists (Android)
|
||||
- [ ] Verify `DailyNotificationStorage.createSchedule()` exists (Android)
|
||||
- [ ] Verify `DailyNotificationScheduler.schedule()` exists (Android)
|
||||
- [ ] Create or verify iOS `PermissionService` methods
|
||||
- [ ] Create or verify iOS `SettingsService` methods (or utility class)
|
||||
|
||||
### Step 2: Extract Validation Logic
|
||||
|
||||
- [ ] Document current validation rules for each method
|
||||
- [ ] Create validation helper methods in services (if needed)
|
||||
- [ ] Ensure validation errors map to plugin errors correctly
|
||||
|
||||
### Step 3: Refactor Android Methods
|
||||
|
||||
- [ ] Refactor permission request methods
|
||||
- [ ] Refactor settings navigation methods
|
||||
- [ ] Refactor schedule CRUD methods
|
||||
- [ ] Refactor scheduling operations
|
||||
- [ ] Refactor callback registration
|
||||
- [ ] Refactor test helpers
|
||||
|
||||
### Step 4: Refactor iOS Methods
|
||||
|
||||
- [ ] Refactor permission request methods
|
||||
- [ ] Refactor settings navigation methods
|
||||
- [ ] Refactor schedule CRUD methods
|
||||
- [ ] Refactor scheduling operations
|
||||
- [ ] Refactor configuration methods
|
||||
|
||||
### Step 5: Testing
|
||||
|
||||
- [ ] Run Android unit tests (focus on validation)
|
||||
- [ ] Run iOS unit tests (focus on validation)
|
||||
- [ ] Test invalid input handling
|
||||
- [ ] Test valid input flows
|
||||
- [ ] Manual smoke test on both platforms
|
||||
- [ ] Verify error messages are preserved
|
||||
|
||||
### Step 6: Verification
|
||||
|
||||
- [ ] Run `./ci/run.sh` (must pass)
|
||||
- [ ] Check plugin class line count reduction
|
||||
- [ ] Verify validation logic is preserved
|
||||
- [ ] Verify service methods handle validation correctly
|
||||
- [ ] Update progress docs
|
||||
|
||||
---
|
||||
|
||||
## Expected Outcomes
|
||||
|
||||
### Metrics
|
||||
|
||||
- **Android plugin:** ~600-700 lines removed
|
||||
- **iOS plugin:** ~500-600 lines removed
|
||||
- **Total reduction:** ~1,100-1,300 lines across both platforms
|
||||
- **Test coverage:** Maintained (validation logic preserved)
|
||||
|
||||
### Benefits
|
||||
|
||||
- ✅ Plugin classes become significantly thinner
|
||||
- ✅ Validation logic moves to services (testable)
|
||||
- ✅ No breaking API changes
|
||||
- ✅ Error handling preserved
|
||||
|
||||
---
|
||||
|
||||
## Rollback Plan
|
||||
|
||||
If issues arise:
|
||||
|
||||
1. Revert commits for this batch
|
||||
2. Service methods remain unchanged (no risk)
|
||||
3. Plugin methods can be restored from git history
|
||||
4. Validation logic can be re-extracted if needed
|
||||
|
||||
---
|
||||
|
||||
## Next Batch
|
||||
|
||||
After Batch 2 completes successfully:
|
||||
|
||||
- **Batch 3:** Glue methods (orchestration across multiple services)
|
||||
- **Batch 4:** Complex initialization and lifecycle methods
|
||||
|
||||
222
docs/progress/P2.1-METHOD-SERVICE-MAP.md
Normal file
222
docs/progress/P2.1-METHOD-SERVICE-MAP.md
Normal file
@@ -0,0 +1,222 @@
|
||||
# Priority 2.1: Method → Service Mapping
|
||||
|
||||
**Purpose:** Map plugin methods to existing services for delegation refactoring.
|
||||
**Owner:** Development Team
|
||||
**Last Updated:** 2025-12-23
|
||||
**Status:** mapping
|
||||
**Baseline:** See `docs/progress/00-STATUS.md`
|
||||
|
||||
---
|
||||
|
||||
## Mapping Structure
|
||||
|
||||
For each plugin method, document:
|
||||
|
||||
- **Plugin Method**: Method name and signature
|
||||
- **Target Service**: Existing service class
|
||||
- **Service Method**: Method to call (or create if needed)
|
||||
- **Delegation Type**: `pure` | `validation` | `glue` | `needs-service`
|
||||
- **Notes**: Special considerations, state requirements, edge cases
|
||||
|
||||
---
|
||||
|
||||
## Android: `DailyNotificationPlugin.kt`
|
||||
|
||||
### Configuration & Setup
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `configure()` | `TimeSafariIntegrationManager` | `configure(...)` | glue | Needs integration manager setup |
|
||||
| `load()` | Multiple | Various | glue | Initialization orchestration |
|
||||
| `getDatabase()` | `DailyNotificationDatabase` | `getDatabase(context)` | pure | Direct access, keep as-is |
|
||||
|
||||
### Permissions
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `checkPermissionStatus()` | `PermissionManager` | `checkNotificationPermission()` | pure | Direct delegation |
|
||||
| `checkPermissions()` | `PermissionManager` | `checkAllPermissions()` | pure | Override, delegate to manager |
|
||||
| `requestNotificationPermissions()` | `PermissionManager` | `requestNotificationPermission()` | pure | Direct delegation |
|
||||
| `requestPermissions()` | `PermissionManager` | `requestAllPermissions()` | pure | Override, delegate to manager |
|
||||
| `handleRequestPermissionsResult()` | `PermissionManager` | `handlePermissionResult()` | pure | Delegate result handling |
|
||||
|
||||
### Exact Alarm (Android 12+)
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `getExactAlarmStatus()` | `DailyNotificationExactAlarmManager` | `getStatus()` | pure | Direct delegation |
|
||||
| `checkExactAlarmPermission()` | `DailyNotificationExactAlarmManager` | `checkPermission()` | pure | Direct delegation |
|
||||
| `requestExactAlarmPermission()` | `DailyNotificationExactAlarmManager` | `requestPermission()` | validation | May need activity context |
|
||||
| `openExactAlarmSettings()` | `DailyNotificationExactAlarmManager` | `openSettings()` | validation | Needs activity context |
|
||||
| `canScheduleExactAlarms()` | `DailyNotificationExactAlarmManager` | `canSchedule()` | pure | Private helper, move to service |
|
||||
| `canRequestExactAlarmPermission()` | `DailyNotificationExactAlarmManager` | `canRequest()` | pure | Private helper, move to service |
|
||||
|
||||
### Notification Channels
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `isChannelEnabled()` | `ChannelManager` | `isChannelEnabled(channelId)` | pure | Direct delegation |
|
||||
| `openChannelSettings()` | `ChannelManager` | `openSettings(channelId)` | validation | Needs activity context |
|
||||
|
||||
### Status & Health
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `getNotificationStatus()` | `NotificationStatusChecker` | `getComprehensiveStatus()` | pure | Direct delegation |
|
||||
| `checkStatus()` | `NotificationStatusChecker` | `getComprehensiveStatus()` | pure | Alias, delegate to checker |
|
||||
|
||||
### Scheduling
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `scheduleContentFetch()` | `TimeSafariIntegrationManager` | `scheduleFetch(...)` | glue | Integration orchestration |
|
||||
| `scheduleDailyNotification()` | `DailyNotificationScheduler` | `schedule(...)` | validation | Input validation, then delegate |
|
||||
| `scheduleUserNotification()` | `DailyNotificationScheduler` | `scheduleUserNotification(...)` | validation | Input validation, then delegate |
|
||||
| `scheduleDualNotification()` | `TimeSafariIntegrationManager` | `scheduleDual(...)` | glue | Complex orchestration |
|
||||
| `getDualScheduleStatus()` | `TimeSafariIntegrationManager` | `getDualStatus(...)` | pure | Direct delegation |
|
||||
| `scheduleDailyReminder()` | `DailyReminderManager` | `schedule(...)` | validation | Input validation, then delegate |
|
||||
| `isAlarmScheduled()` | `DailyNotificationScheduler` | `isScheduled(...)` | pure | Direct delegation |
|
||||
| `getNextAlarmTime()` | `DailyNotificationScheduler` | `getNextAlarmTime()` | pure | Direct delegation |
|
||||
| `testAlarm()` | `DailyNotificationScheduler` | `scheduleTest(...)` | validation | Test helper, validate input |
|
||||
|
||||
### Content & Cache
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `getContentCache()` | `DailyNotificationStorage` | `getContentCache(id)` | pure | Direct delegation |
|
||||
| `configureNativeFetcher()` | `NativeNotificationContentFetcher` | `registerNativeFetcher(...)` | pure | Static registry, keep as-is |
|
||||
|
||||
### Schedule Management (CRUD)
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `getSchedules()` | `DailyNotificationStorage` | `getAllSchedules()` | pure | Direct delegation |
|
||||
| `getSchedule(id)` | `DailyNotificationStorage` | `getSchedule(id)` | pure | Direct delegation |
|
||||
| `getSchedulesWithStatus()` | `DailyNotificationStorage` | `getSchedulesWithStatus()` | glue | Combines storage + scheduler status |
|
||||
| `createSchedule()` | `DailyNotificationStorage` | `createSchedule(...)` | validation | Validate input, delegate |
|
||||
| `updateSchedule()` | `DailyNotificationStorage` | `updateSchedule(...)` | validation | Validate input, delegate |
|
||||
| `deleteSchedule()` | `DailyNotificationStorage` | `deleteSchedule(id)` | validation | Validate input, delegate |
|
||||
| `enableSchedule()` | `DailyNotificationStorage` | `enableSchedule(id, enabled)` | validation | Validate input, delegate |
|
||||
|
||||
### Callbacks
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `registerCallback()` | `DailyNotificationStorage` | `registerCallback(...)` | validation | Validate input, delegate |
|
||||
|
||||
### Utilities
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `cancelAllNotifications()` | `DailyNotificationScheduler` | `cancelAll()` | pure | Direct delegation |
|
||||
| `updateStarredPlans()` | `TimeSafariIntegrationManager` | `updateStarredPlans(...)` | glue | Integration-specific |
|
||||
| `injectInvalidTestData()` | `DailyNotificationStorage` | `injectTestData(...)` | validation | Test helper, validate input |
|
||||
|
||||
---
|
||||
|
||||
## iOS: `DailyNotificationPlugin.swift`
|
||||
|
||||
### Configuration & Setup
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `configure()` | `DailyNotificationStorage` | `configure(...)` | validation | Validate input, delegate |
|
||||
| `load()` | Multiple | Various | glue | Initialization orchestration |
|
||||
| `setupBackgroundTasks()` | `DailyNotificationBackgroundTaskManager` | `registerTasks()` | pure | Direct delegation |
|
||||
|
||||
### Permissions
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `checkPermissionStatus()` | `UNUserNotificationCenter` | `getNotificationSettings()` | validation | Parse settings, format response |
|
||||
| `requestNotificationPermissions()` | `UNUserNotificationCenter` | `requestAuthorization(...)` | validation | Handle async result |
|
||||
| `getNotificationPermissionStatus()` | `UNUserNotificationCenter` | `getNotificationSettings()` | validation | Parse settings, format response |
|
||||
| `requestNotificationPermission()` | `UNUserNotificationCenter` | `requestAuthorization(...)` | validation | Handle async result |
|
||||
|
||||
### Background Tasks
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `getBackgroundTaskStatus()` | `DailyNotificationBackgroundTaskManager` | `getStatus()` | pure | Direct delegation |
|
||||
| `handleBackgroundFetch()` | `DailyNotificationBackgroundTaskManager` | `handleFetch(task)` | glue | Task completion handling |
|
||||
| `handleBackgroundNotify()` | `DailyNotificationBackgroundTaskManager` | `handleNotify(task)` | glue | Task completion handling |
|
||||
| `checkForMissedBGTask()` | `DailyNotificationBackgroundTaskManager` | `checkMissed()` | pure | Direct delegation |
|
||||
| `scheduleBackgroundFetch(config)` | `DailyNotificationBackgroundTaskManager` | `scheduleFetch(...)` | validation | Validate config, delegate |
|
||||
| `scheduleBackgroundFetch(time)` | `DailyNotificationBackgroundTaskManager` | `scheduleFetch(time)` | pure | Direct delegation |
|
||||
|
||||
### Scheduling
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `scheduleContentFetch()` | `DailyNotificationScheduler` | `scheduleFetch(...)` | validation | Validate input, delegate |
|
||||
| `scheduleUserNotification()` | `DailyNotificationScheduler` | `scheduleUserNotification(...)` | validation | Validate input, delegate |
|
||||
| `scheduleDualNotification()` | `DailyNotificationScheduler` | `scheduleDual(...)` | glue | Complex orchestration |
|
||||
| `getDualScheduleStatus()` | `DailyNotificationScheduler` | `getDualStatus(...)` | pure | Direct delegation |
|
||||
| `scheduleDailyReminder()` | `DailyNotificationStorage` | `storeReminder(...)` | validation | Validate input, delegate |
|
||||
| `cancelDailyReminder()` | `DailyNotificationStorage` | `removeReminder(id)` | validation | Validate input, delegate |
|
||||
| `getScheduledReminders()` | `DailyNotificationStorage` | `getReminders()` | pure | Direct delegation |
|
||||
| `updateDailyReminder()` | `DailyNotificationStorage` | `updateReminder(...)` | validation | Validate input, delegate |
|
||||
| `scheduleDailyNotification()` | `DailyNotificationScheduler` | `schedule(...)` | validation | Validate input, delegate |
|
||||
| `getNextScheduledNotificationTime()` | `DailyNotificationScheduler` | `getNextTime()` | pure | Direct delegation |
|
||||
| `calculateNextScheduledTime()` | `DailyNotificationScheduler` | `calculateNextTime(...)` | pure | Private helper, move to service |
|
||||
|
||||
### Content & History
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `getLastNotification()` | `DailyNotificationStorage` | `getLastNotification()` | pure | Direct delegation |
|
||||
| `getPendingNotifications()` | `UNUserNotificationCenter` | `getPendingNotificationRequests()` | validation | Parse requests, format response |
|
||||
|
||||
### Status & Health
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `getNotificationStatus()` | `DailyNotificationStateActor` | `getStatus()` | glue | Combines multiple sources |
|
||||
| `getHealthStatus()` | `DailyNotificationStateActor` | `getHealthStatus()` | pure | Private helper, move to service |
|
||||
|
||||
### Settings & Channels
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `isChannelEnabled()` | `UNUserNotificationCenter` | `getNotificationSettings()` | validation | Parse settings, check channel |
|
||||
| `openChannelSettings()` | `UIApplication` | `openSettingsURLString` | validation | Needs app context |
|
||||
| `openNotificationSettings()` | `UIApplication` | `openSettingsURLString` | validation | Needs app context |
|
||||
| `openBackgroundAppRefreshSettings()` | `UIApplication` | `openSettingsURLString` | validation | Needs app context |
|
||||
| `updateSettings()` | `DailyNotificationStorage` | `updateSettings(...)` | validation | Validate input, delegate |
|
||||
|
||||
### Utilities
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `cancelAllNotifications()` | `UNUserNotificationCenter` | `removeAllPendingNotificationRequests()` | pure | Direct delegation |
|
||||
| `handleNotificationDelivery()` | `DailyNotificationReactivationManager` | `handleDelivery(...)` | glue | Notification observer |
|
||||
| `processRollover()` | `DailyNotificationReactivationManager` | `processRollover(...)` | glue | Private helper, move to service |
|
||||
| `formatTime()` | Utility | `formatTime(timestamp)` | pure | Private helper, move to utility |
|
||||
|
||||
### Storage Helpers (UserDefaults)
|
||||
|
||||
| Plugin Method | Target Service | Service Method | Type | Notes |
|
||||
|--------------|---------------|----------------|------|-------|
|
||||
| `storeReminderInUserDefaults()` | `DailyNotificationStorage` | `storeReminder(...)` | pure | Private helper, delegate |
|
||||
| `removeReminderFromUserDefaults()` | `DailyNotificationStorage` | `removeReminder(id)` | pure | Private helper, delegate |
|
||||
| `getRemindersFromUserDefaults()` | `DailyNotificationStorage` | `getReminders()` | pure | Private helper, delegate |
|
||||
| `updateReminderInUserDefaults()` | `DailyNotificationStorage` | `updateReminder(...)` | pure | Private helper, delegate |
|
||||
|
||||
---
|
||||
|
||||
## Delegation Type Definitions
|
||||
|
||||
- **pure**: Direct delegation, no transformation needed
|
||||
- **validation**: Input validation required before delegation
|
||||
- **glue**: Orchestrates multiple services or handles platform-specific wiring
|
||||
- **needs-service**: Service method doesn't exist yet, needs to be created
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. ✅ Mapping complete (this document)
|
||||
2. ⏭️ Review mapping for accuracy
|
||||
3. ⏭️ Identify first two refactor batches (see `P2.1-BATCH-1.md` and `P2.1-BATCH-2.md`)
|
||||
4. ⏭️ Begin Batch 1 implementation
|
||||
|
||||
Reference in New Issue
Block a user