mirror of
https://github.com/chinchang/web-maker.git
synced 2025-08-01 11:00:28 +02:00
port new changelog notification code
This commit is contained in:
@@ -124,7 +124,9 @@ export default class Footer extends Component {
|
|||||||
<a
|
<a
|
||||||
onClick={this.props.notificationsBtnClickHandler}
|
onClick={this.props.notificationsBtnClickHandler}
|
||||||
id="notificationsBtn"
|
id="notificationsBtn"
|
||||||
class="notifications-btn mode-btn hint--top-left hint--rounded"
|
class={`notifications-btn mode-btn hint--top-left hint--rounded ${
|
||||||
|
this.props.hasUnseenChangelog ? 'has-new' : ''
|
||||||
|
}`}
|
||||||
aria-label="Notifications"
|
aria-label="Notifications"
|
||||||
>
|
>
|
||||||
<svg viewBox="0 0 24 24">
|
<svg viewBox="0 0 24 24">
|
||||||
|
@@ -9,7 +9,7 @@ import AddLibrary from './AddLibrary.jsx';
|
|||||||
import Modal from './Modal.jsx';
|
import Modal from './Modal.jsx';
|
||||||
import HelpModal from './HelpModal.jsx';
|
import HelpModal from './HelpModal.jsx';
|
||||||
import Login from './Login.jsx';
|
import Login from './Login.jsx';
|
||||||
import { log, generateRandomId } from '../utils';
|
import { log, generateRandomId, semverCompare } from '../utils';
|
||||||
import { itemService } from '../itemService';
|
import { itemService } from '../itemService';
|
||||||
import '../db';
|
import '../db';
|
||||||
import Notifications from './Notifications';
|
import Notifications from './Notifications';
|
||||||
@@ -33,6 +33,7 @@ const LocalStorageKeys = {
|
|||||||
ASKED_TO_IMPORT_CREATIONS: 'askedToImportCreations'
|
ASKED_TO_IMPORT_CREATIONS: 'askedToImportCreations'
|
||||||
};
|
};
|
||||||
const UNSAVED_WARNING_COUNT = 15;
|
const UNSAVED_WARNING_COUNT = 15;
|
||||||
|
const version = '3.2.0';
|
||||||
|
|
||||||
export default class App extends Component {
|
export default class App extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -168,6 +169,38 @@ export default class App extends Component {
|
|||||||
this.setState({ prefs: this.state.prefs });
|
this.setState({ prefs: this.state.prefs });
|
||||||
this.updateSetting();
|
this.updateSetting();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check for new version notifications
|
||||||
|
db.getUserLastSeenVersion().then(lastSeenVersion => {
|
||||||
|
// Check if new user
|
||||||
|
if (!lastSeenVersion) {
|
||||||
|
this.setState({
|
||||||
|
isOnboardModalOpen: true
|
||||||
|
});
|
||||||
|
if (document.cookie.indexOf('onboarded') === -1) {
|
||||||
|
trackEvent('ui', 'onboardModalSeen', version);
|
||||||
|
document.cookie = 'onboarded=1';
|
||||||
|
}
|
||||||
|
window.db.setUserLastSeenVersion(version);
|
||||||
|
// set some initial preferences on closing the onboard modal
|
||||||
|
// Old onboarding.
|
||||||
|
// utils.once(document, 'overlaysClosed', function() {});
|
||||||
|
}
|
||||||
|
// If its an upgrade
|
||||||
|
if (
|
||||||
|
lastSeenVersion &&
|
||||||
|
semverCompare(lastSeenVersion, version) === -1 &&
|
||||||
|
!window.localStorage.pledgeModalSeen
|
||||||
|
) {
|
||||||
|
scope.openSupportDeveloperModal();
|
||||||
|
window.localStorage.pledgeModalSeen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lastSeenVersion || semverCompare(lastSeenVersion, version) === -1) {
|
||||||
|
this.setState({ hasUnseenChangelog: true });
|
||||||
|
this.hasSeenNotifications = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
updateProfileUi() {
|
updateProfileUi() {
|
||||||
if (this.state.user) {
|
if (this.state.user) {
|
||||||
@@ -755,6 +788,17 @@ export default class App extends Component {
|
|||||||
|
|
||||||
this.contentWrap.detachPreview();
|
this.contentWrap.detachPreview();
|
||||||
}
|
}
|
||||||
|
notificationsBtnClickHandler() {
|
||||||
|
this.setState({ isNotificationsModalOpen: true });
|
||||||
|
|
||||||
|
if (this.state.isNotificationsModalOpen && !this.hasSeenNotifications) {
|
||||||
|
this.hasSeenNotifications = true;
|
||||||
|
this.setState({ hasUnseenChangelog: false });
|
||||||
|
window.db.setUserLastSeenVersion(version);
|
||||||
|
}
|
||||||
|
trackEvent('ui', 'notificationButtonClick', version);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
@@ -791,7 +835,7 @@ export default class App extends Component {
|
|||||||
this.setState({ isSettingsModalOpen: true })
|
this.setState({ isSettingsModalOpen: true })
|
||||||
}
|
}
|
||||||
notificationsBtnClickHandler={() =>
|
notificationsBtnClickHandler={() =>
|
||||||
this.setState({ isNotificationsModalOpen: true })
|
this.setState({ notificationsBtnClickHandler: true })
|
||||||
}
|
}
|
||||||
supportDeveloperBtnClickHandler={() =>
|
supportDeveloperBtnClickHandler={() =>
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -801,6 +845,7 @@ export default class App extends Component {
|
|||||||
detachedPreviewBtnHandler={this.detachedPreviewBtnHandler.bind(
|
detachedPreviewBtnHandler={this.detachedPreviewBtnHandler.bind(
|
||||||
this
|
this
|
||||||
)}
|
)}
|
||||||
|
hasUnseenChangelog={this.state.hasUnseenChangelog}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user