@ -115,7 +115,10 @@ import { useRouter } from 'vue-router'
import { useAppStore } from '@/stores/app'
import ActionCard from '@/components/cards/ActionCard.vue'
import StatusCard from '@/components/cards/StatusCard.vue'
/ / N o t e : N a t i v e f e t c h e r c o n f i g u r a t i o n m o v e d t o A p p . v u e m o u n t e d ( ) h o o k
import { Capacitor } from '@capacitor/core'
import { DailyNotification } from '@timesafari/daily-notification-plugin'
import { TEST_USER_ZERO_CONFIG , generateEndorserJWT } from '@/config/test-user-zero'
import { logger } from '@/lib/logger'
const router = useRouter ( )
const appStore = useAppStore ( )
@ -123,6 +126,7 @@ const appStore = useAppStore()
const isScheduling = ref ( false )
const isCheckingStatus = ref ( false )
const isRequestingPermissions = ref ( false )
const nativeFetcherConfigured = ref ( false )
const platformName = computed ( ( ) => {
const platform = appStore . platform
@ -430,10 +434,102 @@ const openConsole = (): void => {
alert ( '📖 Console Logs\n\nOpen your browser\'s Developer Tools (F12) and check the Console tab for detailed diagnostic information.' )
}
/ / I n i t i a l i z e s y s t e m s t a t u s w h e n c o m p o n e n t m o u n t s
/ / N o t e : N a t i v e f e t c h e r c o n f i g u r a t i o n i s h a n d l e d i n A p p . v u e m o u n t e d ( ) h o o k
/ / C o n f i g u r e n a t i v e f e t c h e r f o r b a c k g r o u n d w o r k e r s
const configureNativeFetcher = async ( ) : Promise < void > => {
/ / O n l y c o n f i g u r e o n c e
if ( nativeFetcherConfigured . value ) {
console . log ( '⏭️ HomeView: Native fetcher already configured, skipping' )
return
}
/ / O n l y c o n f i g u r e o n n a t i v e p l a t f o r m s
if ( ! Capacitor . isNativePlatform ( ) ) {
console . log ( '⏭️ HomeView: Web platform - skipping native fetcher configuration' )
return
}
try {
console . log ( '🚀 HomeView: Starting native fetcher configuration...' )
logger . info ( 'Configuring native fetcher from HomeView...' )
/ / G e t A P I s e r v e r U R L
const apiBaseUrl = TEST_USER_ZERO_CONFIG . getApiServerUrl ( )
console . log ( '🔧 HomeView: API Base URL:' , apiBaseUrl )
console . log ( '🔧 HomeView: Server Mode:' , TEST_USER_ZERO_CONFIG . api . serverMode )
/ / S k i p c o n f i g u r a t i o n i f i n m o c k m o d e
if ( TEST_USER_ZERO_CONFIG . api . serverMode === 'mock' ) {
console . log ( '⏭️ HomeView: Mock mode - skipping configuration' )
logger . warn ( 'Mock mode enabled - native fetcher will not be configured' )
nativeFetcherConfigured . value = true / / M a r k a s " c o n f i g u r e d " t o p r e v e n t r e t r i e s
return
}
console . log ( '🔧 HomeView: Generating ES256K JWT token...' )
/ / G e n e r a t e J W T t o k e n f o r a u t h e n t i c a t i o n
const jwtToken = await generateEndorserJWT ( )
console . log ( '✅ HomeView: JWT token generated, length:' , jwtToken . length )
console . log ( '🔧 HomeView: Calling configureNativeFetcher with:' , {
apiBaseUrl ,
activeDid : TEST_USER_ZERO_CONFIG . identity . did . substring ( 0 , 30 ) + '...' ,
jwtTokenLength : jwtToken . length
} )
/ / C o n f i g u r e n a t i v e f e t c h e r w i t h c r e d e n t i a l s
await DailyNotification . configureNativeFetcher ( {
apiBaseUrl : apiBaseUrl ,
activeDid : TEST_USER_ZERO_CONFIG . identity . did ,
jwtToken : jwtToken
} )
console . log ( '✅ HomeView: Native fetcher configured successfully!' )
logger . info ( 'Native fetcher configured successfully' , {
apiBaseUrl : apiBaseUrl . substring ( 0 , 50 ) + '...' ,
activeDid : TEST_USER_ZERO_CONFIG . identity . did . substring ( 0 , 30 ) + '...'
} )
/ / U p d a t e s t a r r e d p l a n I D s f r o m c o n f i g ( n o n - b l o c k i n g - i f t h i s f a i l s , f e t c h e r i s s t i l l c o n f i g u r e d )
try {
console . log ( '🔧 HomeView: Updating starred plan IDs...' )
const planIds = [ ... TEST_USER_ZERO_CONFIG . starredProjects . planIds ]
console . log ( '🔧 HomeView: Plan IDs to update:' , planIds . length , 'plans' )
console . log ( '🔧 HomeView: Plan IDs array:' , JSON . stringify ( planIds ) )
const updateResult = await DailyNotification . updateStarredPlans ( {
planIds : planIds
} )
console . log ( '✅ HomeView: Starred plans updated:' , {
count : updateResult . planIdsCount ,
updatedAt : new Date ( updateResult . updatedAt ) . toISOString ( )
} )
} catch ( starredPlansError ) {
/ / N o n - c r i t i c a l e r r o r - n a t i v e f e t c h e r i s a l r e a d y c o n f i g u r e d
console . warn ( '⚠️ HomeView: Failed to update starred plans (non-critical):' , starredPlansError )
logger . warn ( 'Starred plans update failed (native fetcher is still configured)' , {
error : starredPlansError instanceof Error ? starredPlansError . message : String ( starredPlansError )
} )
}
/ / M a r k a s c o n f i g u r e d t o p r e v e n t d u p l i c a t e c o n f i g u r a t i o n
nativeFetcherConfigured . value = true
} catch ( error ) {
console . error ( '❌ HomeView: Failed to configure native fetcher:' , error )
console . error ( '❌ HomeView: Error details:' , error instanceof Error ? error . stack : String ( error ) )
logger . error ( 'Failed to configure native fetcher from HomeView:' , error )
/ / D o n ' t m a r k a s c o n f i g u r e d o n e r r o r , s o i t c a n r e t r y o n n e x t m o u n t
}
}
/ / I n i t i a l i z e s y s t e m s t a t u s a n d n a t i v e f e t c h e r w h e n c o m p o n e n t m o u n t s
onMounted ( async ( ) => {
console . log ( '🏠 HomeView mounted - checking initial system status...' )
console . log ( '🏠 HomeView mounted - checking initial system status and configuring native fetcher...' )
/ / C o n f i g u r e n a t i v e f e t c h e r f i r s t ( n e e d e d f o r b a c k g r o u n d w o r k e r s )
await configureNativeFetcher ( )
/ / T h e n c h e c k s y s t e m s t a t u s
await checkSystemStatus ( )
} )
< / script >