@@ -42,7 +42,7 @@ export default {
4242 hooks : {
4343 async activate ( ) {
4444 console . log ( "Activating: fetching pages and properties" ) ;
45- this . setLastUpdatedTimestamp ( new Date ( ) ) ;
45+ this . _setLastUpdatedTimestamp ( Date . now ( ) ) ;
4646 const propertyValues = { } ;
4747 const propertiesToCheck = await this . _getPropertiesToCheck ( ) ;
4848 const params = this . lastUpdatedSortParam ( ) ;
@@ -60,11 +60,17 @@ export default {
6060 } ,
6161 async deactivate ( ) {
6262 console . log ( "Deactivating: clearing states" ) ;
63- this . setLastUpdatedTimestamp ( null ) ;
63+ this . _setLastUpdatedTimestamp ( null ) ;
6464 } ,
6565 } ,
6666 methods : {
6767 ...base . methods ,
68+ _getLastUpdatedTimestamp ( ) {
69+ return this . db . get ( constants . timestamps . LAST_EDITED_TIME ) ;
70+ } ,
71+ _setLastUpdatedTimestamp ( ts ) {
72+ this . db . set ( constants . timestamps . LAST_EDITED_TIME , ts ) ;
73+ } ,
6874 _getPropertyValues ( ) {
6975 const compressed = this . db . get ( "propertyValues" ) ;
7076 const buffer = Buffer . from ( compressed , "base64" ) ;
@@ -119,10 +125,10 @@ export default {
119125 } ,
120126 } ,
121127 async run ( ) {
122- const lastCheckedTimestamp = this . getLastUpdatedTimestamp ( ) ;
128+ const lastCheckedTimestamp = this . _getLastUpdatedTimestamp ( ) ;
123129 const propertyValues = this . _getPropertyValues ( ) ;
124130
125- if ( lastCheckedTimestamp == null ) {
131+ if ( ! lastCheckedTimestamp ) {
126132 // recently updated (deactivated / activated), skip execution
127133 console . log ( "Awaiting restart completion: skipping execution" ) ;
128134 return ;
@@ -203,7 +209,7 @@ export default {
203209 }
204210 }
205211
206- this . setLastUpdatedTimestamp ( newLastUpdatedTimestamp ) ;
212+ this . _setLastUpdatedTimestamp ( newLastUpdatedTimestamp ) ;
207213 this . _setPropertyValues ( propertyValues ) ;
208214 } ,
209215 sampleEmit,
0 commit comments