Fix team saving in desktop client

I'm not sure why this only recently started becoming a problem; I've
been told this only recently became commonly reported in Help, but the
code I've fixed seems to have been around for a long time. Maybe some
recent change exacerbated it or something.

Anyway, this should make team saving much more frequent, matching how
team saving works in the browser.
This commit is contained in:
Guangcong Luo
2016-01-23 06:24:43 -05:00
parent 694610f35e
commit d209661b91
2 changed files with 18 additions and 10 deletions

View File

@@ -72,21 +72,17 @@
e.stopPropagation();
if (this[e.currentTarget.value]) this[e.currentTarget.value](e);
},
saveTeams: function () {
// save and return
Storage.saveTeams();
app.user.trigger('saveteams');
this.update();
},
back: function () {
if (this.exportMode) {
if (this.curTeam) this.curTeam.team = Storage.packTeam(this.curSetList);
if (this.curTeam) {
this.curTeam.team = Storage.packTeam(this.curSetList);
Storage.saveTeam(this.curTeam);
}
this.exportMode = false;
Storage.saveTeams();
} else if (this.curSet) {
app.clearGlobalListeners();
this.curSet = null;
Storage.saveTeams();
Storage.saveTeam(this.curTeam);
} else if (this.curTeam) {
this.curTeam.team = Storage.packTeam(this.curSetList);
this.curTeam.iconCache = '';
@@ -1140,7 +1136,11 @@
saveFlag: false,
save: function () {
this.saveFlag = true;
Storage.saveTeams();
if (this.curTeam) {
Storage.saveTeam(this.curTeam);
} else {
Storage.saveTeams();
}
},
validate: function () {
var format = this.curTeam.format;

View File

@@ -1222,6 +1222,7 @@ Storage.initDirectory2 = function () {
self.saveAllTeams = self.nwSaveAllTeams;
self.deleteAllTeams = self.nwDeleteAllTeams;
self.saveTeam = self.nwSaveTeam;
self.saveTeams = self.nwSaveTeams;
self.deleteTeam = self.nwDeleteTeam;
// logging
@@ -1411,6 +1412,13 @@ Storage.nwSaveTeam = function (team) {
fs.writeFile(this.dir + 'Teams/' + filename, Storage.exportTeam(team.team).replace(/\n/g, '\r\n'));
};
Storage.nwSaveTeams = function () {
// should never happen
try {
console.log("nwSaveTeams called: " + new Error().stack);
} catch (e) {}
};
Storage.nwDeleteTeam = function (team) {
if (team.filename) {
var oldFilename = team.filename;