@@ -1004,9 +1004,9 @@ function restartBackgroundUpdate() {
10041004 restartBackgroundUpdateThrottle = setTimeout ( ( ) => {
10051005 restartBackgroundUpdateThrottle = false
10061006 clearInterval ( backgroundInterval )
1007- backgroundInterval = setInterval ( handleBackgroundUpdate , ( isDev ? 5000 : 60000 * 1 ) )
1007+ backgroundInterval = setInterval ( handleBackgroundUpdate , ( isDev ? 8000 : 60000 * 1 ) )
10081008 handleBackgroundUpdate ( )
1009- } , 1000 )
1009+ } , 3000 )
10101010 } else {
10111011 clearTimeout ( restartBackgroundUpdateThrottle )
10121012 restartBackgroundUpdateThrottle = false
@@ -1037,13 +1037,16 @@ function handleBackgroundUpdate() {
10371037 // Find most recent event
10381038 let foundEvent = false
10391039 for ( let event of settings . adjustmentTimes ) {
1040- const eventHour = ( event . hour * 1 ) + ( event . am == "PM" && event . hour != 12 ? 12 : ( event . am == "AM" && event . hour ! = 12 ? - 12 : 0 ) )
1040+ const eventHour = ( event . hour * 1 ) + ( event . am == "PM" && ( event . hour * 1 ) != 12 ? 12 : ( event . am == "AM" && ( event . hour * 1 ) = = 12 ? - 12 : 0 ) )
10411041 const eventMinute = event . minute * 1
10421042 // Check if event is not later than current time, last event time, or last found time
1043- if ( hour >= eventHour && ( hour > eventHour || minute >= eventMinute ) && ( foundEvent === false || ( foundEvent . hour < eventHour && foundEvent . minute <= eventMinute ) ) ) {
1044- foundEvent = Object . assign ( { } , event )
1045- foundEvent . minute = foundEvent . minute * 1
1046- foundEvent . hour = ( foundEvent . hour * 1 ) + ( foundEvent . am == "PM" && foundEvent . hour != 12 ? 12 : ( foundEvent . am == "AM" && foundEvent . hour != 12 ? - 12 : 0 ) )
1043+ if ( hour >= eventHour || ( hour == eventHour && minute >= eventMinute ) ) {
1044+ // Check if found event is greater than last found event
1045+ if ( foundEvent === false || foundEvent . hour < eventHour || ! ( foundEvent . hour == eventHour && foundEvent . minute > eventMinute ) ) {
1046+ foundEvent = Object . assign ( event , { } )
1047+ foundEvent . minute = eventMinute
1048+ foundEvent . hour = eventHour
1049+ }
10471050 }
10481051 }
10491052 if ( foundEvent ) {
0 commit comments