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

EX-9437: Switch OFF Ghostery Rewards on Edge #483

Merged
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -727,6 +727,9 @@
"panel_detail_rewards_cliqz_text": {
"message": "Feature already active in the Cliqz MyOffrz control panel."
},
"panel_detail_rewards_edge_text": {
"message": "Ghostery Rewards are not supported in Edge browser"
},
"panel_detail_rewards_loading": {
"message": "Loading Rewards..."
},
@@ -21,6 +21,7 @@ import globals from '../../../src/classes/Globals';
import { log } from '../../../src/utils/common';

const IS_CLIQZ = (globals.BROWSER_INFO.name === 'cliqz');
const IS_EDGE = (globals.BROWSER_INFO.name === 'edge');

/**
* @class The Rewards Panel shows offers generated by Ghostery Rewards.
@@ -93,6 +94,7 @@ class Rewards extends React.Component {
}

sendToIframe(message) {
if (!this.iframe.current) { return; }
this.iframe.current.contentWindow.postMessage(JSON.stringify({
target: 'cliqz-offers-cc',
origin: 'window',
@@ -106,10 +108,12 @@ class Rewards extends React.Component {
log('myoffrzSendRuntimeMessage, runtime.lastError', chrome.runtime.lastError);
return;
}
if (result.action !== 'pushData' || !this.iframe.current) { return; }
if (result.action !== 'pushData') { return; }
const { data: { vouchers = [] } = {} } = result;
const rewardsCount = vouchers.length;
this.setState({ shouldHideRewards: rewardsCount === 0, rewardsCount });

if (!this.iframe.current) { return; }
this.iframe.current.frameBorder = 0;
this.sendToIframe(result);
});
@@ -174,11 +178,12 @@ class Rewards extends React.Component {
const { enable_offers } = this.props;
const headerClassNames = ClassNames('RewardsPanel__header', 'flex-container', 'align-middle', 'align-justify');
const headerTitleClassNames = ClassNames('RewardsPanel__title');
const shouldHideSlider = IS_CLIQZ || IS_EDGE;

return (
<div className={headerClassNames}>
<span className={headerTitleClassNames}>{ t('ghostery_rewards') }</span>
{!IS_CLIQZ && (
{!shouldHideSlider && (
<span className="flex-container align-middle">
<span className="RewardsPanel__slider_text">
{enable_offers ? t('rewards_on') : t('rewards_off')}
@@ -224,6 +229,15 @@ class Rewards extends React.Component {
);
}

renderEDGEtext() {
return (
<div className="RewardsPanel__info">
{ this.renderRewardSvg() }
<div>{ t('panel_detail_rewards_edge_text') }</div>
</div>
);
}

renderRewardsTurnoffText() {
return (
<div className="RewardsPanel__info">
@@ -248,6 +262,7 @@ class Rewards extends React.Component {
*/
renderRewardListComponent() {
if (IS_CLIQZ) { return this.renderCLIQZtext(); }
if (IS_EDGE) { return this.renderEDGEtext(); }
const { enable_offers, is_expanded } = this.props;
if (!enable_offers) { return this.renderRewardsTurnoffText(); }

@@ -1612,7 +1612,7 @@ function initializeGhosteryModules() {
conf.enable_ad_block = !adblocker.isDisabled;
conf.enable_anti_tracking = !antitracking.isDisabled;
conf.enable_human_web = !humanweb.isDisabled && !(IS_FIREFOX && globals.JUST_INSTALLED);
conf.enable_offers = !offers.isDisabled && !(IS_FIREFOX && globals.JUST_INSTALLED);
conf.enable_offers = !offers.isDisabled && !(IS_FIREFOX && globals.JUST_INSTALLED) && !IS_EDGE;
}

const myoffrzShouldMigrate = conf.rewards_opted_in !== undefined && cliqz.prefs.get('myoffrz.opted_in', undefined) === undefined;
ProTip! Use n and p to navigate between commits in a pull request.