only preserve old style name on update if it was actually customized

We didn't detect that previously and just blindly assumed that a local name is always customized by a user, which is nonsense, obviously. To ensure reliable detection a new property is added to the style object: "originalName". From now on the styles that didn't change their name remotely will be successfully marked as having non-customized names, hence the names will update along with the code. Should be like 99% of styles. As for the remaining 1%, welp, only uninstalling and reinstalling the style anew would switch to the new remote name.
This commit is contained in:
tophf 2017-12-13 09:12:54 +03:00
parent 0fe0423757
commit 8d9c7acb3c

View File

@ -125,10 +125,16 @@ var updater = {
json.id = style.id; json.id = style.id;
json.updateDate = Date.now(); json.updateDate = Date.now();
json.reason = 'update'; json.reason = 'update';
// keep current state // keep current state
delete json.enabled; delete json.enabled;
// keep local name customizations // keep local name customizations
if (style.originalName !== style.name && style.name !== json.name) {
delete json.name; delete json.name;
} else {
json.originalName = json.name;
}
if (styleSectionsEqual(json, style)) { if (styleSectionsEqual(json, style)) {
// update digest even if save === false as there might be just a space added etc. // update digest even if save === false as there might be just a space added etc.