import: don't blindly overwrite styles with same id
This commit is contained in:
parent
ab63f028eb
commit
4df35b829b
|
@ -102,7 +102,8 @@ function importFromString(jsonString) {
|
|||
item.name = item.name.trim();
|
||||
const byId = BG.cachedStyles.byId.get(item.id);
|
||||
const byName = oldStylesByName.get(item.name);
|
||||
const oldStyle = byId && byId.name.trim() == item.name || !byName ? byId : byName;
|
||||
const oldStyle = byId && sameStyle(byId, item) ? byId : byName;
|
||||
oldStylesByName.delete(item.name);
|
||||
if (oldStyle == byName && byName) {
|
||||
item.id = byName.id;
|
||||
}
|
||||
|
@ -119,6 +120,12 @@ function importFromString(jsonString) {
|
|||
return {oldStyle, metaEqual, codeEqual};
|
||||
}
|
||||
|
||||
function sameStyle(oldStyle, newStyle) {
|
||||
return oldStyle.name.trim() === newStyle.name.trim() ||
|
||||
['updateUrl', 'originalMd5', 'originalDigest']
|
||||
.some(field => oldStyle[field] && oldStyle[field] == newStyle[field]);
|
||||
}
|
||||
|
||||
function account({style, info, resolve}) {
|
||||
renderQueue.push(style);
|
||||
if (performance.now() - lastRenderTime > RENDER_NAP_TIME_MAX
|
||||
|
|
Loading…
Reference in New Issue
Block a user