Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check pause state for CMP Windows and Rewards Hotdog #390

Merged
merged 2 commits into from Jun 11, 2019
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1311,15 +1311,15 @@ offers.on('enabled', () => {
* Set listener for 'enabled' event for Offers module.
* It registers message handler for messages with the offers.
* This handler adds incoming message data to the array of
* notimication messages (CMP_DATA) to be eventually displayed.
* notification messages (CMP_DATA) to be eventually displayed.
* @memberOf Background
*/
messageCenter.on('enabled', () => {
messageCenter.isReady().then(() => {
log('IN MESSAGE CENTER ON ENABLED', offers, messageCenter);
// const messageCenter = cliqz.modules['message-center'];
return messageCenter.action('registerMessageHandler', OFFERS_HANDLER_ID, (msg) => {
// ffers enabled at the moment when message received
// offers enabled at the moment when message received
messageCenter.action('hideMessage', OFFERS_HANDLER_ID, msg);
msg.Dismiss = 1; // to be immediately dismissed once shown
/**
@@ -1356,7 +1356,8 @@ messageCenter.on('enabled', () => {
rewards.unreadOfferIds.push(msg.data.offer_id);
button.update();

if (msg.data.offer_data.ui_info.notif_type !== 'star') {
// Don't show the Rewards hotdog if Ghostery is currently paused
if (msg.data.offer_data.ui_info.notif_type !== 'star' && !globals.SESSION.paused_blocking) {
// We use getTabByUrl() instead of getActiveTab()
// because user may open the offer-triggering url in a new tab
// through the context menu, which may not switch to the new tab
@@ -146,11 +146,17 @@ class EventHandlers {
onDOMContentLoaded(details) {
const tab_id = details.tabId;

// ignore if this is a sub-frame
if (!utils.isValidTopLevelNavigation(details)) {
return;
}

// show upgrade notifications
// do not show CMP notifications if Ghostery is paused
if (globals.SESSION.paused_blocking) {
return;
}

// show CMP upgrade notifications
utils.getActiveTab((tab) => {
if (!tab || tab.id !== tab_id || tab.incognito) {
return;
@@ -107,9 +107,8 @@ class Rewards {
this.currentOffer = offer;
const tab = tabInfo.getTabInfo(tab_id);

// If the tab is prefetched, we can't add purplebox to it.
if (!conf.enable_offers ||
!tab || tab.rewards) {
// If the tab is prefetched, we can't add Rewards hotdog to it
if (!conf.enable_offers || !tab || tab.rewards) {
return Promise.resolve(false);
}

ProTip! Use n and p to navigate between commits in a pull request.