remove some unnecessary deepCopy calls
This commit is contained in:
parent
45219a88c1
commit
bced23052c
|
@ -23,12 +23,7 @@ function createSourceEditor(style) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// normalize style
|
// normalize style
|
||||||
if (!style.id) {
|
if (!style.id) setupNewStyle(style);
|
||||||
setupNewStyle(style);
|
|
||||||
} else {
|
|
||||||
// style might be an object reference to background page
|
|
||||||
style = deepCopy(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
const cm = CodeMirror($('.single-editor'), {value: style.sourceCode});
|
const cm = CodeMirror($('.single-editor'), {value: style.sourceCode});
|
||||||
editors.push(cm);
|
editors.push(cm);
|
||||||
|
@ -195,7 +190,7 @@ function createSourceEditor(style) {
|
||||||
history.replaceState({}, '', `?id=${newStyle.id}`);
|
history.replaceState({}, '', `?id=${newStyle.id}`);
|
||||||
}
|
}
|
||||||
sessionStorage.justEditedStyleId = newStyle.id;
|
sessionStorage.justEditedStyleId = newStyle.id;
|
||||||
style = deepCopy(newStyle);
|
style = newStyle;
|
||||||
updateMeta();
|
updateMeta();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +217,6 @@ function createSourceEditor(style) {
|
||||||
sourceCode: code,
|
sourceCode: code,
|
||||||
}))
|
}))
|
||||||
.then(replaceStyle)
|
.then(replaceStyle)
|
||||||
.then(() => cm.setOption('mode', cm.doc.mode))
|
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.message === t('styleMissingMeta', 'name')) {
|
if (err.message === t('styleMissingMeta', 'name')) {
|
||||||
messageBox.confirm(t('usercssReplaceTemplateConfirmation')).then(ok => ok &&
|
messageBox.confirm(t('usercssReplaceTemplateConfirmation')).then(ok => ok &&
|
||||||
|
|
|
@ -283,7 +283,7 @@
|
||||||
]))
|
]))
|
||||||
).then(ok => ok &&
|
).then(ok => ok &&
|
||||||
API.saveUsercss(Object.assign(style, dup && {reason: 'update'}))
|
API.saveUsercss(Object.assign(style, dup && {reason: 'update'}))
|
||||||
.then(r => install(r instanceof Object ? r : deepCopy(r)))
|
.then(install)
|
||||||
.catch(err => messageBox.alert(t('styleInstallFailed', err)))
|
.catch(err => messageBox.alert(t('styleInstallFailed', err)))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -366,7 +366,7 @@ Object.assign(handleEvent, {
|
||||||
if (styleIsUsercss) {
|
if (styleIsUsercss) {
|
||||||
API.getStyles({id: styleId}).then(([style]) => {
|
API.getStyles({id: styleId}).then(([style]) => {
|
||||||
hotkeys.setState(false);
|
hotkeys.setState(false);
|
||||||
configDialog(deepCopy(style)).then(() => {
|
configDialog(style).then(() => {
|
||||||
hotkeys.setState(true);
|
hotkeys.setState(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user