don't save project if project not changed

This commit is contained in:
Yueyu 2021-05-28 08:26:37 +08:00
parent 064ee0cf48
commit cc7b6ee883
2 changed files with 8 additions and 2 deletions

View file

@ -83,6 +83,10 @@ export default class ScratchJr {
changed = newChanged;
}
static get changed () {
return changed;
}
static set storyStarted (newStoryStarted) {
storyStarted = newStoryStarted;
}

View file

@ -336,7 +336,7 @@ export default class UI {
static handleTextFieldSave (dontHide) {
// Handle story-starter mode project
if (ScratchJr.isEditable() && ScratchJr.editmode == 'storyStarter' && !Project.error) {
if (ScratchJr.isEditable() && ScratchJr.editmode == 'storyStarter' && !Project.error && ScratchJr.changed) {
OS.analyticsEvent('samples', 'story_starter_edited', Project.metadata.name);
// Get the new project name
var sampleName = Localization.localize('SAMPLE_' + Project.metadata.name);
@ -370,7 +370,6 @@ export default class UI {
ScratchJr.storyStart('UI.handleTextFieldSave');
}
Project.metadata.name = pname;
ScratchJr.changed = true;
OS.setfield(OS.database, Project.metadata.id, 'name', pname);
if (!dontHide) {
ScratchAudio.sndFX('exittap.wav');
@ -389,6 +388,9 @@ export default class UI {
return;
}
var canShare = ScratchJr.editmode != 'storyStarter' || ScratchJr.changed;
gn('infoboxParentsSectionButton').style.display = canShare ? 'block' : 'none';
// Prevent button from thrashing
setTimeout(function () {
okclicky.ontouchend = UI.hideInfoBox;