1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-04-21 19:21:55 +02:00

fix files mode limit condition

This commit is contained in:
Kushagra Gour 2024-05-08 17:56:47 +05:30
parent dce8c02f03
commit 38a1e64e4a
2 changed files with 27 additions and 16 deletions

View File

@ -206,7 +206,6 @@ export default class ContentWrap extends Component {
this.frame.contentDocument.write(contents);
this.frame.contentDocument.close();
} else {
console.log('sending PM');
this.frame.contentWindow.postMessage({ contents }, '*');
}
};

View File

@ -1552,10 +1552,17 @@ export default class App extends Component {
this.setState({ isCreateNewModalOpen: false });
}
blankFileTemplateSelectHandler() {
function create() {
this.createNewItem(true);
this.setState({ isCreateNewModalOpen: false });
}
if (this.state.user?.isPro) {
create();
return;
}
itemService.getCountOfFileModeItems().then(count => {
if (count < 2) {
this.createNewItem(true);
this.setState({ isCreateNewModalOpen: false });
create();
} else {
trackEvent('ui', 'FileModeCreationLimitMessageSeen');
// this.closeAllOverlays();
@ -1568,24 +1575,29 @@ export default class App extends Component {
}
templateSelectHandler(template, isFileMode) {
function create() {
fetch(
`templates/template-${isFileMode ? 'files-' : ''}${template.id}.json`
)
.then(res => res.json())
.then(json => {
this.forkItem(json);
});
this.setState({ isCreateNewModalOpen: false });
}
if (isFileMode) {
if (this.state.user?.isPro) {
create();
return;
}
itemService.getCountOfFileModeItems().then(count => {
if (count < 2) {
fetch(
`templates/template-${isFileMode ? 'files-' : ''}${
template.id
}.json`
)
.then(res => res.json())
.then(json => {
this.forkItem(json);
});
this.setState({ isCreateNewModalOpen: false });
create();
} else {
trackEvent('ui', 'FileModeCreationLimitMessageSeen');
return alert(
'"Files mode" is currently in beta and is limited to only 2 creations per user. You have already made 2 creations in Files mode.\n\nNote: You can choose to delete old ones to create new.'
);
this.setState({ isFilesLimitModalOpen: true });
}
});
} else {