remove some unnecessary deepCopy calls

This commit is contained in:
tophf 2018-01-05 13:26:11 +03:00
parent 45219a88c1
commit bced23052c
3 changed files with 4 additions and 10 deletions

View File

@ -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 &&

View File

@ -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)))
); );
}; };

View File

@ -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);
}); });
}); });