File tree Expand file tree Collapse file tree
engraphis/dashboard_assets Expand file tree Collapse file tree Original file line number Diff line number Diff line change 25242524
25252525
25262526 let graphPreferencesSaveScheduled = false ;
2527+ let graphPreferencesSaveCancel = null ;
25272528 function scheduleGraphPreferencesSave ( ) {
25282529 if ( graphPreferencesSaveScheduled ) return ;
25292530 graphPreferencesSaveScheduled = true ;
25302531 const flush = ( ) => {
2532+ if ( ! graphPreferencesSaveScheduled ) return ;
25312533 graphPreferencesSaveScheduled = false ;
2534+ graphPreferencesSaveCancel = null ;
25322535 saveGraphPreferences ( ) ;
25332536 } ;
2534- if ( typeof requestAnimationFrame === 'function' ) requestAnimationFrame ( flush ) ;
2535- else setTimeout ( flush , 0 ) ;
2537+ if ( typeof requestAnimationFrame === 'function' ) {
2538+ const frame = requestAnimationFrame ( flush ) ;
2539+ graphPreferencesSaveCancel = ( ) => cancelAnimationFrame ( frame ) ;
2540+ } else {
2541+ const timer = setTimeout ( flush , 0 ) ;
2542+ graphPreferencesSaveCancel = ( ) => clearTimeout ( timer ) ;
2543+ }
25362544 }
25372545
25382546 function flushGraphPreferencesSave ( ) {
25392547 if ( ! graphPreferencesSaveScheduled ) return ;
25402548 graphPreferencesSaveScheduled = false ;
2549+ const cancel = graphPreferencesSaveCancel ;
2550+ graphPreferencesSaveCancel = null ;
2551+ if ( cancel ) cancel ( ) ;
25412552 saveGraphPreferences ( ) ;
25422553 }
25432554
You can’t perform that action at this time.
0 commit comments