Revert "Use localStorage as a backup for users who can't update settings [MAILPOET-1627]"

This reverts commit f7057b3bd3d37f557e23dd390b298e1bdf2f37a4.
This commit is contained in:
wxa
2018-12-10 17:52:01 +03:00
parent cb9c4ff238
commit 660c174b21
3 changed files with 2 additions and 30 deletions

View File

@ -3,38 +3,14 @@ import classNames from 'classnames';
import MailPoet from 'mailpoet';
import PropTypes from 'prop-types';
const LAST_ANNOUNCEMENT_SEEN_LS_KEY = 'last_announcement_seen';
const getLocalStorageKey = function getLocalStorageKey() {
try {
return parseInt(window.localStorage.getItem(LAST_ANNOUNCEMENT_SEEN_LS_KEY), 10);
} catch (e) {
return null;
}
};
const setLocalStorageKey = function setLocalStorageKey(value) {
try {
return window.localStorage.setItem(LAST_ANNOUNCEMENT_SEEN_LS_KEY, String(value));
} catch (e) {
return null;
}
};
class FeatureAnnouncement extends React.Component {
constructor(props) {
super(props);
this.loadBeamer = this.loadBeamer.bind(this);
this.beamerCallback = this.beamerCallback.bind(this);
// localStorage is used as a backup for users who don't have a permission to update settings
const lastAnnouncementSeenLS = getLocalStorageKey();
const hasNewsLS = lastAnnouncementSeenLS > 0 ?
lastAnnouncementSeenLS < window.mailpoet_last_announcement_date :
null;
this.state = {
showDot: hasNewsLS !== null ? hasNewsLS : props.hasNews,
showDot: props.hasNews,
beamerLoaded: typeof window.Beamer !== 'undefined',
};
}
@ -64,9 +40,7 @@ class FeatureAnnouncement extends React.Component {
window.Beamer.show();
const data = { last_announcement_seen: window.mailpoet_last_announcement_seen || {} };
const userId = window.mailpoet_current_wp_user.ID;
const lastAnnouncementSeen = Math.floor(Date.now() / 1000);
data.last_announcement_seen[userId] = lastAnnouncementSeen;
setLocalStorageKey(lastAnnouncementSeen);
data.last_announcement_seen[userId] = Math.floor(Date.now() / 1000);
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'settings',