@ -315,17 +315,17 @@ 
			
		
	
		
			
				
					                < button  
			
		
	
		
			
				
					                  class = "block w-full text-center text-md font-bold uppercase bg-blue-600 text-white px-2 py-2 rounded-md mb-2"  
			
		
	
		
			
				
					                >  
			
		
	
		
			
				
					                  For  1  Hour  
			
		
	
		
			
				
					                  For  1  Day  
			
		
	
		
			
				
					                < / button >  
			
		
	
		
			
				
					                < button  
			
		
	
		
			
				
					                  class = "block w-full text-center text-md font-bold uppercase bg-blue-600 text-white px-2 py-2 rounded-md mb-2"  
			
		
	
		
			
				
					                >  
			
		
	
		
			
				
					                  For  8  Hour s 
			
		
	
		
			
				
					                  For  2  Day s 
			
		
	
		
			
				
					                < / button >  
			
		
	
		
			
				
					                < button  
			
		
	
		
			
				
					                  class = "block w-full text-center text-md font-bold uppercase bg-blue-600 text-white px-2 py-2 rounded-md mb-2"  
			
		
	
		
			
				
					                >  
			
		
	
		
			
				
					                  For  24  Hours  
			
		
	
		
			
				
					                  For  1  Week  
			
		
	
		
			
				
					                < / button >  
			
		
	
		
			
				
					                < button  
			
		
	
		
			
				
					                  class = "block w-full text-center text-md font-bold uppercase bg-blue-600 text-white px-2 py-2 rounded-md mb-2"  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -384,7 +384,7 @@ import axios from "axios"; 
			
		
	
		
			
				
					import  {  Vue ,  Component  }  from  "vue-facing-decorator" ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					import  {  DEFAULT_PUSH_SERVER ,  NotificationIface  }  from  "@/constants/app" ;  
			
		
	
		
			
				
					import  {  addLogMessage ,  retrieveSettingsForActiveAccount  }  from  "@/db/index" ;  
			
		
	
		
			
				
					import  {  logConsoleAndDb ,  retrieveSettingsForActiveAccount  }  from  "@/db/index" ;  
			
		
	
		
			
				
					import  *  as  libsUtil  from  "@/libs/util" ;  
			
		
	
		
			
				
					import  {  urlBase64ToUint8Array  }  from  "@/libs/crypto/vc/util" ;  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -436,19 +436,21 @@ export default class App extends Vue { 
			
		
	
		
			
				
					      }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					      if  ( pushUrl . startsWith ( "http://localhost" ) )  {  
			
		
	
		
			
				
					        console . log ( "Not checking for VAPID in this local environment." ) ;  
			
		
	
		
			
				
					        logConsoleAndDb ( "Not checking for VAPID in this local environment." ) ;  
			
		
	
		
			
				
					      }  else  {  
			
		
	
		
			
				
					        let  responseData  =  "" ;  
			
		
	
		
			
				
					        await  axios  
			
		
	
		
			
				
					          . get ( pushUrl  +  "/web-push/vapid" )  
			
		
	
		
			
				
					          . then ( ( response :  VapidResponse )  =>  {  
			
		
	
		
			
				
					            this . b64  =  response . data ? . vapidKey  ||  "" ;  
			
		
	
		
			
				
					            console . log ( "Got vapid key:" , this . b64 ) ;  
			
		
	
		
			
				
					            logConsoleAndDb ( "Got vapid key: "  + this . b64 ) ;  
			
		
	
		
			
				
					            responseData  =  JSON . stringify ( response . data ) ;  
			
		
	
		
			
				
					            navigator . serviceWorker ? . addEventListener (  
			
		
	
		
			
				
					              "controllerchange" ,  
			
		
	
		
			
				
					              ( )  =>  {  
			
		
	
		
			
				
					                console . log ( "New service worker is now controlling the page" ) ;  
			
		
	
		
			
				
					                logConsoleAndDb (  
			
		
	
		
			
				
					                  "New service worker is now controlling the page" ,  
			
		
	
		
			
				
					                ) ;  
			
		
	
		
			
				
					              } ,  
			
		
	
		
			
				
					            ) ;  
			
		
	
		
			
				
					          } ) ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -462,17 +464,23 @@ export default class App extends Vue { 
			
		
	
		
			
				
					            } ,  
			
		
	
		
			
				
					            5000 ,  
			
		
	
		
			
				
					          ) ;  
			
		
	
		
			
				
					          await  addLogMessage (  
			
		
	
		
			
				
					          logConsoleAndDb (  
			
		
	
		
			
				
					            "Error Setting Notifications: web push server response didn't have vapidKey: "  +  
			
		
	
		
			
				
					              responseData ,  
			
		
	
		
			
				
					            true ,  
			
		
	
		
			
				
					          ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					      }  
			
		
	
		
			
				
					    }  catch  ( error )  {  
			
		
	
		
			
				
					      if  ( window . location . host . startsWith ( "localhost" ) )  {  
			
		
	
		
			
				
					        console . log ( "Ignoring the error getting VAPID for local development." ) ;  
			
		
	
		
			
				
					        logConsoleAndDb (  
			
		
	
		
			
				
					          "Ignoring the error getting VAPID for local development." ,  
			
		
	
		
			
				
					        ) ;  
			
		
	
		
			
				
					      }  else  {  
			
		
	
		
			
				
					        console . error ( "Got an error initializing notifications:" ,  error ) ;  
			
		
	
		
			
				
					        logConsoleAndDb (  
			
		
	
		
			
				
					          "Got an error initializing notifications: "  +  JSON . stringify ( error ) ,  
			
		
	
		
			
				
					          true ,  
			
		
	
		
			
				
					        ) ;  
			
		
	
		
			
				
					        this . $notify (  
			
		
	
		
			
				
					          {  
			
		
	
		
			
				
					            group :  "alert" ,  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -482,10 +490,6 @@ export default class App extends Vue { 
			
		
	
		
			
				
					          } ,  
			
		
	
		
			
				
					          5000 ,  
			
		
	
		
			
				
					        ) ;  
			
		
	
		
			
				
					        await  addLogMessage (  
			
		
	
		
			
				
					          "Error Setting Notifications: some error occurred: "  +  
			
		
	
		
			
				
					            JSON . stringify ( error ) ,  
			
		
	
		
			
				
					        ) ;  
			
		
	
		
			
				
					      }  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					    / /   t h e r e   m a y   b e   a   l o n g   p a u s e   h e r e   o n   f i r s t   i n i t i a l i z a t i o n  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -519,7 +523,9 @@ export default class App extends Vue { 
			
		
	
		
			
				
					  }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					  private  askPermission ( ) :  Promise < NotificationPermission >  {  
			
		
	
		
			
				
					    console . log ( "Requesting permission for notifications:" ,  navigator ) ;  
			
		
	
		
			
				
					    logConsoleAndDb (  
			
		
	
		
			
				
					      "Requesting permission for notifications: "  +  JSON . stringify ( navigator ) ,  
			
		
	
		
			
				
					    ) ;  
			
		
	
		
			
				
					    if  (  
			
		
	
		
			
				
					      ! ( "serviceWorker"  in  navigator  &&  navigator . serviceWorker ? . controller )  
			
		
	
		
			
				
					    )  {  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -544,7 +550,9 @@ export default class App extends Vue { 
			
		
	
		
			
				
					    } ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    return  this . sendMessageToServiceWorker ( message ) . then ( ( response )  =>  {  
			
		
	
		
			
				
					      console . log ( "Response from service worker:" ,  response ) ;  
			
		
	
		
			
				
					      logConsoleAndDb (  
			
		
	
		
			
				
					        "Response from service worker: "  +  JSON . stringify ( response ) ,  
			
		
	
		
			
				
					      ) ;  
			
		
	
		
			
				
					    } ) ;  
			
		
	
		
			
				
					  }  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -647,12 +655,12 @@ export default class App extends Vue { 
			
		
	
		
			
				
					  public  async  turnOnNotifications ( )  {  
			
		
	
		
			
				
					    return  this . askPermission ( )  
			
		
	
		
			
				
					      . then ( ( permission )  =>  {  
			
		
	
		
			
				
					        console . log ( "Permission granted:" ,  permission ) ;  
			
		
	
		
			
				
					        logConsoleAndDb ( "Permission granted: "  +  JSON . stringify ( permission ) ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        / /   C a l l   t h e   f u n c t i o n   a n d   h a n d l e   p r o m i s e s  
			
		
	
		
			
				
					        this . subscribeToPush ( )  
			
		
	
		
			
				
					          . then ( ( )  =>  {  
			
		
	
		
			
				
					            console . log ( "Subscribed successfully." ) ;  
			
		
	
		
			
				
					            logConsoleAndDb ( "Subscribed successfully." ) ;  
			
		
	
		
			
				
					            return  navigator . serviceWorker ? . ready ;  
			
		
	
		
			
				
					          } )  
			
		
	
		
			
				
					          . then ( ( registration )  =>  {  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -684,7 +692,6 @@ export default class App extends Vue { 
			
		
	
		
			
				
					              const  utcHour  =  
			
		
	
		
			
				
					                hourNum  +  Math . round ( new  Date ( ) . getTimezoneOffset ( )  /  60 ) ;  
			
		
	
		
			
				
					              const  finalUtcHour  =  ( utcHour  +  ( utcHour  <  0  ?  24  :  0 ) )  %  24 ;  
			
		
	
		
			
				
					              console . log ( "utc hour:" ,  utcHour ,  "final utc:" ,  finalUtcHour ) ;  
			
		
	
		
			
				
					              const  minuteNum  =  libsUtil . numberOrZero ( this . minuteInput ) ;  
			
		
	
		
			
				
					              const  utcMinute  =  
			
		
	
		
			
				
					                minuteNum  +  Math . round ( new  Date ( ) . getTimezoneOffset ( )  %  60 ) ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -697,13 +704,18 @@ export default class App extends Vue { 
			
		
	
		
			
				
					                ... subscription . toJSON ( ) ,  
			
		
	
		
			
				
					              } ;  
			
		
	
		
			
				
					              await  this . sendSubscriptionToServer ( subscriptionWithTime ) ;  
			
		
	
		
			
				
					              / /   T o   h e l p   i n v e s t i g a t e   p o t e n t i a l   i s s u e s   w i t h   t h i s :   h t t p s : / / f i r e b a s e . g o o g l e . c o m / d o c s / c l o u d - m e s s a g i n g / m i g r a t e - v 1  
			
		
	
		
			
				
					              logConsoleAndDb (  
			
		
	
		
			
				
					                "Subscription data sent to server with endpoint: "  +  
			
		
	
		
			
				
					                  subscription . endpoint ,  
			
		
	
		
			
				
					              ) ;  
			
		
	
		
			
				
					              return  subscriptionWithTime ;  
			
		
	
		
			
				
					            }  else  {  
			
		
	
		
			
				
					              throw  new  Error ( "Subscription object is not available." ) ;  
			
		
	
		
			
				
					            }  
			
		
	
		
			
				
					          } )  
			
		
	
		
			
				
					          . then ( async  ( subscription :  PushSubscriptionWithTime )  =>  {  
			
		
	
		
			
				
					            console . log (  
			
		
	
		
			
				
					            logConsoleAndDb (  
			
		
	
		
			
				
					              "Subscription data sent to server and all finished successfully." ,  
			
		
	
		
			
				
					            ) ;  
			
		
	
		
			
				
					            await  libsUtil . sendTestThroughPushServer ( subscription ,  true ) ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -728,9 +740,10 @@ export default class App extends Vue { 
			
		
	
		
			
				
					          } ) ;  
			
		
	
		
			
				
					      } )  
			
		
	
		
			
				
					      . catch ( ( error )  =>  {  
			
		
	
		
			
				
					        console . error (  
			
		
	
		
			
				
					          "An error occurred setting notification permissions:" ,  
			
		
	
		
			
				
					          error ,  
			
		
	
		
			
				
					        logConsoleAndDb (  
			
		
	
		
			
				
					          "An error occurred setting notification permissions: "  +  
			
		
	
		
			
				
					            JSON . stringify ( error ) ,  
			
		
	
		
			
				
					          true ,  
			
		
	
		
			
				
					        ) ;  
			
		
	
		
			
				
					        alert ( "Some error occurred setting notification permissions." ) ;  
			
		
	
		
			
				
					      } ) ;  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -761,11 +774,19 @@ export default class App extends Vue { 
			
		
	
		
			
				
					          return  registration . pushManager . subscribe ( options ) ;  
			
		
	
		
			
				
					        } )  
			
		
	
		
			
				
					        . then ( ( subscription )  =>  {  
			
		
	
		
			
				
					          console . log ( "Push subscription successful:" ,  subscription ) ;  
			
		
	
		
			
				
					          logConsoleAndDb (  
			
		
	
		
			
				
					            "Push subscription successful: "  +  JSON . stringify ( subscription ) ,  
			
		
	
		
			
				
					          ) ;  
			
		
	
		
			
				
					          resolve ( ) ;  
			
		
	
		
			
				
					        } )  
			
		
	
		
			
				
					        . catch ( ( error )  =>  {  
			
		
	
		
			
				
					          console . error ( "Push subscription failed:" ,  error ,  options ) ;  
			
		
	
		
			
				
					          logConsoleAndDb (  
			
		
	
		
			
				
					            "Push subscription failed: "  +  
			
		
	
		
			
				
					              JSON . stringify ( error )  +  
			
		
	
		
			
				
					              " - "  +  
			
		
	
		
			
				
					              JSON . stringify ( options ) ,  
			
		
	
		
			
				
					            true ,  
			
		
	
		
			
				
					          ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					          / /   I n f o r m   t h e   u s e r   a b o u t   t h e   i s s u e  
			
		
	
		
			
				
					          alert (  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -781,7 +802,7 @@ export default class App extends Vue { 
			
		
	
		
			
				
					  private  sendSubscriptionToServer (  
			
		
	
		
			
				
					    subscription :  PushSubscriptionWithTime ,  
			
		
	
		
			
				
					  ) :  Promise < void >  {  
			
		
	
		
			
				
					    console . log ( "About to send subscription..." , subscription ) ;  
			
		
	
		
			
				
					    logConsoleAndDb ( "About to send subscription... "  + subscription ) ;  
			
		
	
		
			
				
					    return  fetch ( "/web-push/subscribe" ,  {  
			
		
	
		
			
				
					      method :  "POST" ,  
			
		
	
		
			
				
					      headers :  {  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -792,7 +813,7 @@ export default class App extends Vue { 
			
		
	
		
			
				
					      if  ( ! response . ok )  {  
			
		
	
		
			
				
					        throw  new  Error ( "Failed to send subscription to server" ) ;  
			
		
	
		
			
				
					      }  
			
		
	
		
			
				
					      console . log ( "Subscription sent to server successfully." ) ;  
			
		
	
		
			
				
					      logConsoleAndDb ( "Subscription sent to server successfully." ) ;  
			
		
	
		
			
				
					    } ) ;  
			
		
	
		
			
				
					  }  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -807,12 +828,15 @@ export default class App extends Vue { 
			
		
	
		
			
				
					        if  ( subscription )  {  
			
		
	
		
			
				
					          return  subscription . unsubscribe ( ) ;  
			
		
	
		
			
				
					        }  else  {  
			
		
	
		
			
				
					          console . log ( "Subscription object is not available." ) ;  
			
		
	
		
			
				
					          logConsoleAndDb ( "Subscription object is not available." ) ;  
			
		
	
		
			
				
					          return  false ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					      } )  
			
		
	
		
			
				
					      . catch ( ( error )  =>  {  
			
		
	
		
			
				
					        console . error ( "Push provider server communication failed:" ,  error ) ;  
			
		
	
		
			
				
					        logConsoleAndDb (  
			
		
	
		
			
				
					          "Push provider server communication failed: "  +  JSON . stringify ( error ) ,  
			
		
	
		
			
				
					          true ,  
			
		
	
		
			
				
					        ) ;  
			
		
	
		
			
				
					        return  false ;  
			
		
	
		
			
				
					      } ) ;  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -827,7 +851,10 @@ export default class App extends Vue { 
			
		
	
		
			
				
					        return  response . ok ;  
			
		
	
		
			
				
					      } )  
			
		
	
		
			
				
					      . catch ( ( error )  =>  {  
			
		
	
		
			
				
					        console . error ( "Push server communication failed:" ,  error ) ;  
			
		
	
		
			
				
					        logConsoleAndDb (  
			
		
	
		
			
				
					          "Push server communication failed: "  +  JSON . stringify ( error ) ,  
			
		
	
		
			
				
					          true ,  
			
		
	
		
			
				
					        ) ;  
			
		
	
		
			
				
					        return  false ;  
			
		
	
		
			
				
					      } ) ;