Skip to content

Commit

Permalink
Update insertion_observer for new Gmail updates (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: Brendon Chen <bchen@hubspot.com>
  • Loading branch information
bchenhs and Brendon Chen committed Sep 19, 2023
1 parent 2b3f5e3 commit 3605474
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/gmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -2672,7 +2672,10 @@ var Gmail = function(localJQuery) {
// for specified classes (as defined in api.tracker.dom_observers above) which indicate
// related actions which need triggering
$(window.document).on("DOMNodeInserted", function(e) {
api.tools.insertion_observer(e.target, api.tracker.dom_observers, api.tracker.dom_observer_map);
// Yield to allow Gmail render to complete
setTimeout(()=>{
api.tools.insertion_observer(e.target, api.tracker.dom_observers, api.tracker.dom_observer_map);
})

Check failure on line 2678 in src/gmail.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon

Check failure on line 2678 in src/gmail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing semicolon
});

// recipient_change also needs to listen to removals
Expand Down Expand Up @@ -2774,11 +2777,13 @@ var Gmail = function(localJQuery) {
}

// if an element has been found, execute the observer handler (or if none defined, execute the callback)
if(element.length) {

if (element.length) {
var handler = config.handler ? config.handler : function(match, callback) { callback(match); };
// console.log( "inserted DOM: class match in watchdog",observer,api.tracker.watchdog.dom[observer] );
api.observe.trigger_dom(observer, element, handler);
var idx;

Check failure on line 2782 in src/gmail.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'idx' is already defined

Check failure on line 2782 in src/gmail.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'idx' is already defined
for (idx = 0; idx < element.length; idx++) {
// console.log( "inserted DOM: class match in watchdog",observer,api.tracker.watchdog.dom[observer] );
api.observe.trigger_dom(observer, $(element[idx]), handler);
}
}
}
}
Expand Down

0 comments on commit 3605474

Please sign in to comment.