Skip to content

Commit 26529a1

Browse files
authored
Update insertion_observer for new Gmail updates
Based on bchenhs/gmail.js-fork@3605474 To fix KartikTalwar#765
1 parent 2b3f5e3 commit 26529a1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/gmail.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,10 @@ var Gmail = function(localJQuery) {
26722672
// for specified classes (as defined in api.tracker.dom_observers above) which indicate
26732673
// related actions which need triggering
26742674
$(window.document).on("DOMNodeInserted", function(e) {
2675-
api.tools.insertion_observer(e.target, api.tracker.dom_observers, api.tracker.dom_observer_map);
2675+
// Yield to allow Gmail render to complete
2676+
setTimeout(()=>{
2677+
api.tools.insertion_observer(e.target, api.tracker.dom_observers, api.tracker.dom_observer_map);
2678+
})
26762679
});
26772680

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

27762779
// if an element has been found, execute the observer handler (or if none defined, execute the callback)
2777-
if(element.length) {
2778-
2780+
if (element.length) {
27792781
var handler = config.handler ? config.handler : function(match, callback) { callback(match); };
2780-
// console.log( "inserted DOM: class match in watchdog",observer,api.tracker.watchdog.dom[observer] );
2781-
api.observe.trigger_dom(observer, element, handler);
2782+
var idx;
2783+
for (idx = 0; idx < element.length; idx++) {
2784+
// console.log( "inserted DOM: class match in watchdog",observer,api.tracker.watchdog.dom[observer] );
2785+
api.observe.trigger_dom(observer, $(element[idx]), handler);
2786+
}
27822787
}
27832788
}
27842789
}

0 commit comments

Comments
 (0)