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

Fixes for Offers #116

Merged
merged 4 commits into from Jun 26, 2018
Merged
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -65,6 +65,7 @@ class Notification extends Component {
className="notification-text"
href={this.props.data.textLink.href}
target="_blank"
rel="noopener noreferrer"
onClick={() => {
if (this.props.data.textLink.callback) {
this.props.data.textLink.callback();
@@ -137,7 +137,6 @@ class OfferCard extends Component {
disableRewards() {
sendMessage('ping', 'rewards_off');
this.props.actions.sendSignal('rewards_off', null, false);
this.props.actions.messageBackground('rewardsDisabled');
}

disableRewardsNotification() {
@@ -280,7 +279,7 @@ class OfferCard extends Component {
</div>
}
</div>
<a target="_blank" onClick={this.redeem} href={this.state.rewardUI.call_to_action && this.state.rewardUI.call_to_action.url} className="reward-redeem">
<a target="_blank" rel="noopener noreferrer" onClick={this.redeem} href={this.state.rewardUI.call_to_action && this.state.rewardUI.call_to_action.url} className="reward-redeem">
{this.state.rewardUI.call_to_action.text}
</a>
</div>
@@ -211,7 +211,9 @@ class RewardsApp {
}

messageBackground(name, message) {
if (this.port) {
if (this.port &&
(message.actionId !== 'rewards_off') &&
(message.actionId !== 'rewards_on')) {
this.port.postMessage({
name,
message
@@ -43,7 +43,7 @@ class License extends React.Component {
return (
<div className="license">
<div>{`${t('license_module')}: ${license.name}`}</div>
<a href={license.repository} target="_blank"><span style={{ color: '#4A4A4A' }}>{`${t('license_repository')}:`}</span>{` ${license.repository || t('license_information_missing')}`}</a>
<a href={license.repository} target="_blank" rel="noopener noreferrer"><span style={{ color: '#4A4A4A' }}>{`${t('license_repository')}:`}</span>{` ${license.repository || t('license_information_missing')}`}</a>
<div>{`${t('license_type')}: ${license.licenses}`}</div>
<div>{`${t('license_publisher')}: ${license.publisher || t('license_unknown')}`}</div>
<div>{`${t('license_url')}: ${license.url || t('license_unknown')}`}</div>
@@ -111,7 +111,7 @@ class GlobalTracker extends React.Component {
{
this.state.showTrackerLearnMore &&
<div className={(!this.state.showTrackerLearnMore ? 'hide' : '')}>
<a target="_blank" title={tracker.name} href={`https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}`}>
<a target="_blank" rel="noopener noreferrer" title={tracker.name} href={`https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}`}>
{ t('tracker_description_learn_more') }
</a>
</div>
@@ -210,6 +210,7 @@ class Tracker extends React.Component {
sources = tracker.sources.map((source, index) => (
<a
target="_blank"
rel="noopener noreferrer"
className="trk-src-link"
title={source.src}
key={index}
@@ -285,7 +286,7 @@ class Tracker extends React.Component {
<div className="trk-description">
{ this.state.description }
<div className={(!this.state.showTrackerLearnMore ? 'hide' : '')}>
<a target="_blank" title={tracker.name} href={`https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}`}>
<a target="_blank" rel="noopener noreferrer" title={tracker.name} href={`https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}`}>
{ t('tracker_description_learn_more') }
</a>
</div>
@@ -42,7 +42,7 @@
"homepage": "https://github.com/ghostery/ghostery-extension#readme",
"dependencies": {
"base64-js": "^1.2.1",
"browser-core": "https://s3.amazonaws.com/cdncliqz/update/edge/ghostery/v7.27/7.27.9.tgz?v=1",
"browser-core": "https://s3.amazonaws.com/cdncliqz/update/edge/ghostery/v7.27/7.27.10.tgz?v=1",
"classnames": "^2.2.5",
"d3": "^4.13.0",
"d3-scale": "^1.0.6",
@@ -69,6 +69,7 @@ const humanweb = cliqz.modules['human-web'];
const { adblocker, antitracking, hpn } = cliqz.modules;
const messageCenter = cliqz.modules['message-center'];
const offers = cliqz.modules['offers-v2'];
let OFFERS_ENABLE_SIGNAL;

/**
* Enable or disable specified module.
@@ -421,40 +422,49 @@ function handleBlockedRedirect(name, message, tab_id, callback) {
* @param {function} callback function to call (at most once) when you have a response
*/
function handleRewards(name, message, tab_id, callback) {
switch (name) {
case 'rewardSignal':
rewards.sendSignal(message);
if (message.actionId === 'rewards_off') {
cliqz.modules['offers-v2'].background.actions.flushSignals();
if (!offers.isEnabled) {
switch (name) {
case 'rewardSignal':
if (message.actionId === 'rewards_on') {
OFFERS_ENABLE_SIGNAL = message;
conf.enable_offers = true;
}
break;
default:
break;
}
} else {
switch (name) {
case 'rewardSignal':
rewards.sendSignal(message);
if (message.actionId === 'rewards_off') {
conf.enable_offers = false;
}
break;
case 'rewardSeen':
rewards.markRewardRead(message.offerId);
button.update();
break;
case 'deleteReward':
rewards.markRewardRead(message.offerId);
rewards.deleteReward(message.offerId);
button.update();
break;
case 'rewardsDisabled':
conf.enable_offers = false;
} else if (message.actionId === 'rewards_on') {
cliqz.modules['offers-v2'].background.actions.flushSignals();
conf.enable_offers = true;
}
break;
case 'rewardSeen':
rewards.markRewardRead(message.offerId);
button.update();
break;
case 'deleteReward':
rewards.markRewardRead(message.offerId);
rewards.deleteReward(message.offerId);
button.update();
break;
case 'rewardsDisabled':
conf.enable_offers = false;
break;
case 'rewardsPromptAccepted':
conf.rewards_accepted = true;
break;
case 'ping':
metrics.ping(message);
break;
case 'removeDisconnectListener':
rewards.panelPort.onDisconnect.removeListener(rewards.panelHubClosedListener);
break;
default:
break;
break;
case 'rewardsPromptAccepted':
conf.rewards_accepted = true;
break;
case 'ping':
metrics.ping(message);
break;
case 'removeDisconnectListener':
rewards.panelPort.onDisconnect.removeListener(rewards.panelHubClosedListener);
break;
default:
break;
}
}
}

@@ -859,6 +869,14 @@ function initializeDispatcher() {
button.update();
if (!IS_EDGE && !IS_CLIQZ) {
if (!enableOffers) {
const actions = cliqz &&
cliqz.modules['offers-v2'] &&
cliqz.modules['offers-v2'].background &&
cliqz.modules['offers-v2'].background.actions;
if (actions) {
actions.flushSignals();
}
OFFERS_ENABLE_SIGNAL = undefined;
registerWithOffers(offers, enableOffers);
}
setCliqzModuleEnabled(offers, enableOffers);
@@ -1072,7 +1090,19 @@ adblocker.on('enabled', () => {
offers.on('enabled', () => {
offers.isReady().then(() => {
log('IN OFFERS ON ENABLED', offers, messageCenter);
if (OFFERS_ENABLE_SIGNAL) {
rewards.sendSignal(OFFERS_ENABLE_SIGNAL);

const actions = cliqz &&
cliqz.modules['offers-v2'] &&
cliqz.modules['offers-v2'].background &&
cliqz.modules['offers-v2'].background.actions;
if (actions) {
actions.flushSignals();
}

OFFERS_ENABLE_SIGNAL = undefined;
}
if (DEBUG) {
offers.action('setConfiguration', {
config_location: 'de',
ProTip! Use n and p to navigate between commits in a pull request.