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

feature/reward signal hotfix #111

Merged
merged 6 commits into from Jun 22, 2018
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

remove listener for offer shown + GH-1234
lint

change port name
  • Loading branch information
trickpattyFH20 committed Jun 20, 2018
commit 17aede1547232738da08ce5e901e8bdbef4bd9e2
@@ -59,6 +59,7 @@ class HotDog extends Component {
}

close() {
this.props.actions.removeFocusListener();
this.props.actions.sendSignal('offer_closed_hotdog');
if (this.iframeEl) {
this.iframeEl.classList = '';
@@ -174,6 +174,7 @@ class OfferCard extends Component {
}

closeOfferCard() {
this.props.actions.removeFocusListener();
if (this.iframeEl) {
this.iframeEl.classList = '';
}
@@ -48,13 +48,17 @@ class RewardsApp {
this.mainView = null;
this.rewardsApp.id = 'ghostery-rewards-app';
this.rewardsApp.className = 'show';

this.handleMessages = this.handleMessages.bind(this);
this.sendSignal = this.sendSignal.bind(this);
this.messageBackground = this.messageBackground.bind(this);
this.removeFocusListener = this.removeFocusListener.bind(this);
this.focusListener = this.focusListener.bind(this);

this.actions = {
sendSignal: this.sendSignal,
messageBackground: this.messageBackground
messageBackground: this.messageBackground,
removeFocusListener: this.removeFocusListener
};

this.init();
@@ -193,10 +197,16 @@ class RewardsApp {
}
}

focusListener() {
this.sendSignal('offer_shown');
}

addRewardSeenListener() {
window.addEventListener('focus', () => {
this.sendSignal('offer_shown');
});
window.addEventListener('focus', this.focusListener);
}

removeFocusListener() {
window.removeEventListener('focus', this.focusListener);
}

messageBackground(name, message) {
@@ -50,6 +50,7 @@ class Rewards extends React.Component {
componentDidMount() {
this.props.actions.getRewardsData();
this.props.actions.sendSignal('hub_open');
chrome.runtime.connect({ name: 'rewardsPanelPort' });
}

/**
@@ -12,6 +12,8 @@
"version_name": "8.2.0",
"default_locale": "en",
"description": "__MSG_short_description__",
"debug": true,
"log": true,
"icons": {
"16": "app/images/icon16.png",
"48": "app/images/icon48.png",
@@ -99,4 +101,4 @@
"browser_action_next_to_addressbar": true
}
}
}
}
@@ -1267,6 +1267,14 @@ function initializeEventListeners() {

// Fired when a message is sent from either an extension process (by runtime.sendMessage) or a content script (by tabs.sendMessage).
onMessage.addListener(onMessageHandler);

// Fired when panel is disconnected
chrome.runtime.onConnect.addListener((port) => {
if (port && port.name === 'rewardsPanelPort') {
rewards.panelPort = port;
rewards.panelHubClosedListener();
}
});
}

/**
@@ -33,6 +33,7 @@ class Rewards {
constructor() {
this.getStoredOffers();
this.currentOffer = null;
this.panelPort = null;
this.ports = new Map();
this.channelsSupported = (typeof chrome.runtime.onConnect === 'object');
}
@@ -149,6 +150,17 @@ class Rewards {
return false;
});
}

panelHubClosedListener() {
this.panelPort.onDisconnect(() => {
this.sendSignal({
offerId: null,
actionId: 'hub_closed',
origin: 'ghostery-rewards-hub',
type: 'action-signal'
});
});
}
}

export default new Rewards();
ProTip! Use n and p to navigate between commits in a pull request.