@ -13,6 +13,7 @@ import {
CapacitorSQLite ,
CapacitorSQLite ,
DBSQLiteValues ,
DBSQLiteValues ,
} from "@capacitor-community/sqlite" ;
} from "@capacitor-community/sqlite" ;
import { DailyNotification } from "@timesafari/daily-notification-plugin" ;
import { runMigrations } from "@/db-sql/migration" ;
import { runMigrations } from "@/db-sql/migration" ;
import { QueryExecResult } from "@/interfaces/database" ;
import { QueryExecResult } from "@/interfaces/database" ;
@ -1421,9 +1422,8 @@ export class CapacitorPlatformService
* /
* /
async getDailyNotificationStatus ( ) : Promise < NotificationStatus | null > {
async getDailyNotificationStatus ( ) : Promise < NotificationStatus | null > {
try {
try {
// Dynamic import to avoid build issues if plugin unavailable
logger . debug (
const { DailyNotification } = await import (
"[CapacitorPlatformService] Getting daily notification status..." ,
"@timesafari/daily-notification-plugin"
) ;
) ;
const pluginStatus = await DailyNotification . getNotificationStatus ( ) ;
const pluginStatus = await DailyNotification . getNotificationStatus ( ) ;
@ -1463,10 +1463,16 @@ export class CapacitorPlatformService
} ,
} ,
} ;
} ;
} catch ( error ) {
} catch ( error ) {
const errorMessage =
error instanceof Error ? error.message : String ( error ) ;
logger . error (
logger . error (
"[CapacitorPlatformService] Failed to get notification status:" ,
"[CapacitorPlatformService] Failed to get notification status:" ,
errorMessage ,
error ,
error ,
) ;
) ;
logger . warn (
"[CapacitorPlatformService] Daily notification section will be hidden - plugin may not be installed or available" ,
) ;
return null ;
return null ;
}
}
}
}
@ -1477,10 +1483,6 @@ export class CapacitorPlatformService
* /
* /
async checkNotificationPermissions ( ) : Promise < PermissionStatus | null > {
async checkNotificationPermissions ( ) : Promise < PermissionStatus | null > {
try {
try {
const { DailyNotification } = await import (
"@timesafari/daily-notification-plugin"
) ;
const permissions = await DailyNotification . checkPermissions ( ) ;
const permissions = await DailyNotification . checkPermissions ( ) ;
// Log the raw permission state for debugging
// Log the raw permission state for debugging
@ -1530,10 +1532,6 @@ export class CapacitorPlatformService
* /
* /
async requestNotificationPermissions ( ) : Promise < PermissionResult | null > {
async requestNotificationPermissions ( ) : Promise < PermissionResult | null > {
try {
try {
const { DailyNotification } = await import (
"@timesafari/daily-notification-plugin"
) ;
logger . info (
logger . info (
` [CapacitorPlatformService] Requesting notification permissions... ` ,
` [CapacitorPlatformService] Requesting notification permissions... ` ,
) ;
) ;
@ -1571,10 +1569,6 @@ export class CapacitorPlatformService
* /
* /
async scheduleDailyNotification ( options : ScheduleOptions ) : Promise < void > {
async scheduleDailyNotification ( options : ScheduleOptions ) : Promise < void > {
try {
try {
const { DailyNotification } = await import (
"@timesafari/daily-notification-plugin"
) ;
await DailyNotification . scheduleDailyNotification ( {
await DailyNotification . scheduleDailyNotification ( {
time : options.time ,
time : options.time ,
title : options.title ,
title : options.title ,
@ -1601,10 +1595,6 @@ export class CapacitorPlatformService
* /
* /
async cancelDailyNotification ( ) : Promise < void > {
async cancelDailyNotification ( ) : Promise < void > {
try {
try {
const { DailyNotification } = await import (
"@timesafari/daily-notification-plugin"
) ;
await DailyNotification . cancelAllNotifications ( ) ;
await DailyNotification . cancelAllNotifications ( ) ;
logger . info ( "[CapacitorPlatformService] Cancelled daily notification" ) ;
logger . info ( "[CapacitorPlatformService] Cancelled daily notification" ) ;
@ -1670,10 +1660,6 @@ export class CapacitorPlatformService
config : NativeFetcherConfig ,
config : NativeFetcherConfig ,
) : Promise < void | null > {
) : Promise < void | null > {
try {
try {
const { DailyNotification } = await import (
"@timesafari/daily-notification-plugin"
) ;
// Step 1: Get activeDid from database (single source of truth)
// Step 1: Get activeDid from database (single source of truth)
// This ensures we're using the correct user identity for authentication
// This ensures we're using the correct user identity for authentication
const activeIdentity = await this . getActiveIdentity ( ) ;
const activeIdentity = await this . getActiveIdentity ( ) ;
@ -1740,10 +1726,6 @@ export class CapacitorPlatformService
* /
* /
async updateStarredPlans ( plans : { planIds : string [ ] } ) : Promise < void | null > {
async updateStarredPlans ( plans : { planIds : string [ ] } ) : Promise < void | null > {
try {
try {
const { DailyNotification } = await import (
"@timesafari/daily-notification-plugin"
) ;
await DailyNotification . updateStarredPlans ( {
await DailyNotification . updateStarredPlans ( {
planIds : plans.planIds ,
planIds : plans.planIds ,
} ) ;
} ) ;