# 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)

