Skip to content

Commit d90928b

Browse files
committed
Limit to 3 saved diagrams in free version
1 parent 6e94f48 commit d90928b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/components/app.jsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { currentBrowserTab } from '../services/browserService';
4949
import { syncDiagram, getShareLink } from '../services/syncService';
5050
import clsx from 'clsx';
5151
import EmbedHeader from './EmbedHeader.jsx';
52+
import userService from '../services/user_service';
5253

5354
if (module.hot) {
5455
require('preact/debug');
@@ -133,7 +134,7 @@ export default class App extends Component {
133134
// window.zd_libraryBtHander = this.openAddLibrary.bind(this)
134135
}
135136
firebase.auth().onAuthStateChanged(async (user) => {
136-
await this.setState({ isLoginModalOpen: false });
137+
await this.setState({ isLoginModalOpen: false });
137138
if (user) {
138139
log('You are -> ', user);
139140
alertsService.add('You are now logged in!');
@@ -450,6 +451,16 @@ BookLibService.Borrow(id) {
450451

451452
return d.promise;
452453
}
454+
455+
checkItemsLimit() {
456+
if(!this.state.user || Object.keys(this.state.user.items).length <= 3 || userService.isPro()) {
457+
return true;
458+
}
459+
460+
alert(`You have ${Object.keys(this.state.user.items).length} diagrams, the limit is 3. Upgrade now for unlimited storage.`);
461+
this.proBtnClickHandler();
462+
}
463+
453464
saveBtnClickHandler() {
454465
trackEvent(
455466
'ui',
@@ -460,6 +471,11 @@ BookLibService.Borrow(id) {
460471
? 'saved'
461472
: 'new'
462473
);
474+
475+
if(!this.checkItemsLimit()) {
476+
return;
477+
}
478+
463479
if (this.state.user || window.zenumlDesktop) {
464480
this.saveItem();
465481
const numOfItems = Object.keys(this.state.savedItems).length;
@@ -1007,13 +1023,22 @@ BookLibService.Borrow(id) {
10071023
await this.removeItem(item);
10081024
}
10091025
async itemForkBtnClickHandler(item) {
1026+
if(!this.checkItemsLimit()) {
1027+
return;
1028+
}
1029+
10101030
await this.toggleSavedItemsPane();
10111031
setTimeout(() => {
10121032
this.forkItem(item);
10131033
}, 350);
10141034
}
10151035
async newBtnClickHandler() {
10161036
trackEvent('ui', 'newBtnClick');
1037+
1038+
if(!this.checkItemsLimit()) {
1039+
return;
1040+
}
1041+
10171042
if (this.state.unsavedEditCount) {
10181043
var shouldDiscard = confirm(
10191044
'You have unsaved changes. Do you still want to create something new?'
@@ -1121,6 +1146,10 @@ BookLibService.Borrow(id) {
11211146
});
11221147
}
11231148
exportBtnClickHandler(e) {
1149+
if(!this.checkItemsLimit()) {
1150+
return;
1151+
}
1152+
11241153
this.exportItems();
11251154
e.preventDefault();
11261155
trackEvent('ui', 'exportBtnClicked');

src/components/subscription/ProFeatureListModal.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export function ProFeatureListModal(props) {
1414
<li>(Free) Real-time sequence diagram converter</li>
1515
<li>(Free) Export to PNG and JPEG</li>
1616
<li>(Free) Hand-tuned themes</li>
17+
<li>(Free) Limit of 3 diagrams</li>
1718
<li>(Pro) Custom CSS</li>
19+
<li>(Pro) Unlimited storage</li>
1820
</ul>
1921
</section>
2022
<section className={'call-for-action hide'}>

0 commit comments

Comments
 (0)