mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-10 00:16:18 +02:00
increment unsaved changes count on file manipulation
This commit is contained in:
@ -239,6 +239,22 @@ export default class App extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
incrementUnsavedChanges() {
|
||||||
|
this.setState({ unsavedEditCount: this.state.unsavedEditCount + 1 });
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.state.unsavedEditCount % UNSAVED_WARNING_COUNT === 0 &&
|
||||||
|
this.state.unsavedEditCount >= UNSAVED_WARNING_COUNT
|
||||||
|
) {
|
||||||
|
window.saveBtn.classList.add('animated');
|
||||||
|
window.saveBtn.classList.add('wobble');
|
||||||
|
window.saveBtn.addEventListener('animationend', () => {
|
||||||
|
window.saveBtn.classList.remove('animated');
|
||||||
|
window.saveBtn.classList.remove('wobble');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateProfileUi() {
|
updateProfileUi() {
|
||||||
if (this.state.user) {
|
if (this.state.user) {
|
||||||
document.body.classList.add('is-logged-in');
|
document.body.classList.add('is-logged-in');
|
||||||
@ -732,19 +748,7 @@ export default class App extends Component {
|
|||||||
this.state.currentItem[type] = code;
|
this.state.currentItem[type] = code;
|
||||||
}
|
}
|
||||||
if (isUserChange) {
|
if (isUserChange) {
|
||||||
this.setState({ unsavedEditCount: this.state.unsavedEditCount + 1 });
|
this.incrementUnsavedChanges();
|
||||||
|
|
||||||
if (
|
|
||||||
this.state.unsavedEditCount % UNSAVED_WARNING_COUNT === 0 &&
|
|
||||||
this.state.unsavedEditCount >= UNSAVED_WARNING_COUNT
|
|
||||||
) {
|
|
||||||
window.saveBtn.classList.add('animated');
|
|
||||||
window.saveBtn.classList.add('wobble');
|
|
||||||
window.saveBtn.addEventListener('animationend', () => {
|
|
||||||
window.saveBtn.classList.remove('animated');
|
|
||||||
window.saveBtn.classList.remove('wobble');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.state.prefs.isJs13kModeOn) {
|
if (this.state.prefs.isJs13kModeOn) {
|
||||||
// Throttling codesize calculation
|
// Throttling codesize calculation
|
||||||
@ -1214,7 +1218,9 @@ export default class App extends Component {
|
|||||||
files: [...this.state.currentItem.files, newEntry]
|
files: [...this.state.currentItem.files, newEntry]
|
||||||
};
|
};
|
||||||
assignFilePaths(currentItem.files);
|
assignFilePaths(currentItem.files);
|
||||||
|
|
||||||
this.setState({ currentItem });
|
this.setState({ currentItem });
|
||||||
|
this.incrementUnsavedChanges();
|
||||||
}
|
}
|
||||||
removeFileHandler(filePath) {
|
removeFileHandler(filePath) {
|
||||||
const currentItem = {
|
const currentItem = {
|
||||||
@ -1222,9 +1228,9 @@ export default class App extends Component {
|
|||||||
files: [...this.state.currentItem.files]
|
files: [...this.state.currentItem.files]
|
||||||
};
|
};
|
||||||
removeFileAtPath(currentItem.files, filePath);
|
removeFileAtPath(currentItem.files, filePath);
|
||||||
this.setState({
|
|
||||||
currentItem
|
this.setState({ currentItem });
|
||||||
});
|
this.incrementUnsavedChanges();
|
||||||
}
|
}
|
||||||
renameFileHandler(oldFilePath, newFileName) {
|
renameFileHandler(oldFilePath, newFileName) {
|
||||||
const currentItem = {
|
const currentItem = {
|
||||||
@ -1236,6 +1242,7 @@ export default class App extends Component {
|
|||||||
assignFilePaths(currentItem.files);
|
assignFilePaths(currentItem.files);
|
||||||
|
|
||||||
this.setState({ currentItem });
|
this.setState({ currentItem });
|
||||||
|
this.incrementUnsavedChanges();
|
||||||
}
|
}
|
||||||
fileDropHandler(sourceFilePath, destinationFolder) {
|
fileDropHandler(sourceFilePath, destinationFolder) {
|
||||||
let { currentItem } = this.state;
|
let { currentItem } = this.state;
|
||||||
@ -1257,7 +1264,9 @@ export default class App extends Component {
|
|||||||
files: [...currentItem.files]
|
files: [...currentItem.files]
|
||||||
};
|
};
|
||||||
assignFilePaths(currentItem.files);
|
assignFilePaths(currentItem.files);
|
||||||
|
|
||||||
this.setState({ currentItem });
|
this.setState({ currentItem });
|
||||||
|
this.incrementUnsavedChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user