Fix infinite onChange loop in metadata

pull/1/head
yflory 5 years ago
parent 0636714829
commit a0598bf377

@ -99,6 +99,7 @@ define(['json.sortify'], function (Sortify) {
var addAuthor = function () { var addAuthor = function () {
if (!meta.user || !meta.user.netfluxId || !priv || !priv.edPublic) { return; } if (!meta.user || !meta.user.netfluxId || !priv || !priv.edPublic) { return; }
var authors = metadataObj.authors || {}; var authors = metadataObj.authors || {};
var old = Sortify(authors);
if (!authors[priv.edPublic]) { if (!authors[priv.edPublic]) {
authors[priv.edPublic] = { authors[priv.edPublic] = {
nId: [meta.user.netfluxId], nId: [meta.user.netfluxId],
@ -110,9 +111,11 @@ define(['json.sortify'], function (Sortify) {
authors[priv.edPublic].nId.push(meta.user.netfluxId); authors[priv.edPublic].nId.push(meta.user.netfluxId);
} }
} }
metadataObj.authors = authors; if (Sortify(authors) !== old) {
metadataLazyObj.authors = JSON.parse(JSON.stringify(authors)); metadataObj.authors = authors;
change(); metadataLazyObj.authors = JSON.parse(JSON.stringify(authors));
change();
}
}; };
var netfluxId; var netfluxId;

Loading…
Cancel
Save