Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/content.js

Issue 29712599: Issue 6420 - Fixed poping up whitelisted website notification for several custom filter lists (Closed)
Patch Set: Created March 5, 2018, 8:26 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | js/desktop-options.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/content.js
===================================================================
--- a/ext/content.js
+++ b/ext/content.js
@@ -74,18 +74,26 @@
payload: message
});
+ let resolvePromise = null;
saroyanm 2018/03/05 20:28:33 I noticed that it took me longer than needed to im
Thomas Greiner 2018/03/06 13:08:47 We're not handling errors yet so we don't need to
+ let callbackWrapper = event =>
+ {
+ if (event.data.type == "response" && event.data.messageId == messageId)
+ {
+ window.removeEventListener("message", callbackWrapper);
+ resolvePromise(event.data.payload);
+ }
+ };
+ window.addEventListener("message", callbackWrapper);
if (responseCallback)
{
- let callbackWrapper = event =>
+ resolvePromise = responseCallback;
+ }
+ else
+ {
+ return new Promise((resolve, reject) =>
{
- if (event.data.type == "response" && event.data.messageId == messageId)
- {
- window.removeEventListener("message", callbackWrapper);
- responseCallback(event.data.payload);
- }
- };
-
- window.addEventListener("message", callbackWrapper);
+ resolvePromise = resolve;
+ });
}
};
}());
« no previous file with comments | « no previous file | js/desktop-options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld