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

GH-1777 and GH-1776 Plus Promo modals #458

Merged
merged 26 commits into from Oct 16, 2019
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5102f35
Show plus promo modal on first view of Home view of each Hub session
wlycdgr Sep 16, 2019
e1c1f54
Stub out intro hub plus promo modal layout and implement its buttons
wlycdgr Sep 16, 2019
64869a5
Remove some unnecessary plus promo modal related CSS
wlycdgr Sep 17, 2019
5289bb9
Continue adding styling for plus promo modal
wlycdgr Sep 17, 2019
ce1fac9
Continue styling plus promo modal
wlycdgr Sep 18, 2019
361debe
Refactor plus promo modal CSS to improve alignment of elements
wlycdgr Sep 20, 2019
3c96366
Merge branch 'develop' into GH-1777/plus-intro-hub-promo
wlycdgr Sep 20, 2019
a60d6b4
Continue CSS work for plus promo modal
wlycdgr Sep 20, 2019
4f84229
Implement recommended gold banner in plus promo modal
wlycdgr Sep 23, 2019
3794709
Merge branch 'develop' into GH-1777/plus-intro-hub-promo
wlycdgr Sep 26, 2019
5cb13d5
Update and tweak plus promo modal design
wlycdgr Sep 27, 2019
f6d3298
Fix path bug in i18n-checker tool. Consolidate redundant entries in m…
wlycdgr Oct 1, 2019
4b16723
Additional consolidation of redundant and unused entries in messages
wlycdgr Oct 2, 2019
92d4923
Merge branch 'develop' into GH-1777/plus-intro-hub-promo
wlycdgr Oct 3, 2019
a1f102b
Merge branch 'develop' into GH-1777/plus-intro-hub-promo
wlycdgr Oct 3, 2019
569382e
Factor plus promo modal rendering out to shared component. Implement …
wlycdgr Oct 6, 2019
509f9eb
Move Plus Promo modal rendering to a PlusPromoModal shared component.…
wlycdgr Oct 7, 2019
833fdff
Create ModalPromos background class responsible for modal promo relat…
wlycdgr Oct 7, 2019
9e80640
Add local state to Panel to make sure component rerenders after user …
wlycdgr Oct 8, 2019
b03e312
Make PromoModals code more robust
wlycdgr Oct 8, 2019
a1270cc
Factor PlusPromoModal rendering out to helper in Panel. Extend condit…
wlycdgr Oct 8, 2019
cac56c1
Mark PromoModals methods as static. Refine PlusPromoModal implementat…
wlycdgr Oct 8, 2019
be05ce9
Add logic to hide plus promo modal from Insights subscribers. Cleanup…
wlycdgr Oct 9, 2019
ee361ad
Clean up. Finish string localization in PlusPromoModal
wlycdgr Oct 9, 2019
80d75fb
Pull non-shared upgrade version of plus promo modal out of shared Plu…
wlycdgr Oct 16, 2019
7c85e94
Remove debug console statement
wlycdgr Oct 16, 2019
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Create ModalPromos background class responsible for modal promo relat…

…ed business logic and state management
  • Loading branch information
wlycdgr committed Oct 7, 2019
commit 833fdff4c489990ed21e91c8aa62669db08ebef0
@@ -210,12 +210,12 @@ class Panel extends React.Component {

const notificationText = this.props.notificationShown && this.renderNotification();

const { plusPromoModalSeen } = this.props;
const { isTimeForAnotherPlusPromo } = this.props;

return (
<div id="panel">
<PlusPromoModal
show={!plusPromoModalSeen}
show={isTimeForAnotherPlusPromo}
location="panel"
clickHandler={this._plusPromoClickHandlerPlaceholder}
/>
@@ -42,6 +42,7 @@ import metrics from './classes/Metrics';
import rewards from './classes/Rewards';
import account from './classes/Account';
import GhosteryModule from './classes/Module';
import modalPromos from './classes/ModalPromos';

// utilities
import { allowAllwaysC2P } from './utils/click2play';
@@ -542,8 +543,7 @@ function handleRewards(name, message, callback) {
function handleGhosteryHub(name, message, callback) {
switch (name) {
case 'SET_PLUS_PROMO_MODAL_SEEN':
// TODO move this to a Promos class?
conf.plus_promo_modal_last_seen = Date.now();
modalPromos.recordPlusPromoSighting();
break;
case 'SEND_PING': {
const { type } = message;
@@ -123,7 +123,7 @@ class ConfData {
_initProperty('notify_library_updates', false);
_initProperty('notify_upgrade_updates', true);
_initProperty('paid_subscription', false);
_initProperty('plus_promo_modal_last_seen', null);
_initProperty('plus_promo_modal_last_seen', 0);
_initProperty('rewards_accepted', false);
_initProperty('rewards_opted_in', false);
_initProperty('settings_last_imported', 0);
@@ -0,0 +1,49 @@
/**
* ModalPromos Class
*
* Ghostery Browser Extension
* https://www.ghostery.com/
*
* Copyright 2019 Ghostery, Inc. All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0
*/

import conf from './Conf';

const DAYS_BETWEEN_PROMOS = {
plus: 30
};
const MSECS_IN_DAY = 1000 * 60 * 60 * 24; // msecs-in-sec * secs-in-min * mins-in-hour * hours-in-day

/**
* Class for handling the business logic for the display of modal promos (Plus, Insights, etc...)
* @memberOf BackgroundClasses
*/
class ModalPromos {
recordPlusPromoSighting() {
this._recordPromoSighting('plus');
}

isTimeForAnotherPlusPromo() {
return this._isTimeForAnotherPlusPromo('plus');
}

_isTimeForAnotherPlusPromo(promoType) {
const lastSeenTime = conf[`${promoType}_promo_modal_last_seen`];

return (
(Date.now() - lastSeenTime) >
(MSECS_IN_DAY * DAYS_BETWEEN_PROMOS[promoType])
);
}

_recordPromoSighting(promoType) {
conf[`${promoType}_promo_modal_last_seen`] = Date.now();
}
}

// return the class as a singleton
export default new ModalPromos();
@@ -27,6 +27,7 @@ import tabInfo from './TabInfo';
import rewards from './Rewards';
import account from './Account';
import dispatcher from './Dispatcher';
import modalPromos from './ModalPromos';
import { getCliqzGhosteryBugs, sendCliqzModuleCounts } from '../utils/cliqzModulesData';
import { getActiveTab, flushChromeMemoryCache, processUrl } from '../utils/utils';
import { objectEntries, log } from '../utils/common';
@@ -365,7 +366,7 @@ class PanelData {
is_expert,
is_android: globals.BROWSER_INFO.os === 'android',
language,
plusPromoModalSeen: !!plus_promo_modal_last_seen,
isTimeForAnotherPlusPromo: modalPromos.isTimeForAnotherPlusPromo(),
reload_banner_status,
tab_id,
trackers_banner_status,
ProTip! Use n and p to navigate between commits in a pull request.