Change: kill style.reason
This commit is contained in:
parent
fc53bed3de
commit
7d005f3eaa
|
@ -182,7 +182,6 @@
|
||||||
|
|
||||||
json.id = style.id;
|
json.id = style.id;
|
||||||
json.updateDate = Date.now();
|
json.updateDate = Date.now();
|
||||||
// json.reason = 'update';
|
|
||||||
|
|
||||||
// keep current state
|
// keep current state
|
||||||
delete json.enabled;
|
delete json.enabled;
|
||||||
|
@ -197,7 +196,6 @@
|
||||||
const newStyle = Object.assign({}, style, json);
|
const newStyle = Object.assign({}, style, json);
|
||||||
if (styleSectionsEqual(json, style, {checkSource: true})) {
|
if (styleSectionsEqual(json, style, {checkSource: true})) {
|
||||||
// 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.
|
||||||
// json.reason = 'update-digest';
|
|
||||||
return styleManager.installStyle(newStyle)
|
return styleManager.installStyle(newStyle)
|
||||||
.then(saved => {
|
.then(saved => {
|
||||||
style.originalDigest = saved.originalDigest;
|
style.originalDigest = saved.originalDigest;
|
||||||
|
|
|
@ -52,19 +52,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function assignVars(style) {
|
function assignVars(style) {
|
||||||
if (style.reason === 'config' && style.id) {
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
return find(style)
|
return find(style)
|
||||||
.then(dup => {
|
.then(dup => {
|
||||||
if (dup) {
|
if (dup) {
|
||||||
style.id = dup.id;
|
style.id = dup.id;
|
||||||
if (style.reason !== 'config') {
|
|
||||||
// preserve style.vars during update
|
// preserve style.vars during update
|
||||||
return usercss.assignVars(style, dup)
|
return usercss.assignVars(style, dup)
|
||||||
.then(() => style);
|
.then(() => style);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return style;
|
return style;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
12
edit/edit.js
12
edit/edit.js
|
@ -321,11 +321,13 @@ function preinit() {
|
||||||
function onRuntimeMessage(request) {
|
function onRuntimeMessage(request) {
|
||||||
switch (request.method) {
|
switch (request.method) {
|
||||||
case 'styleUpdated':
|
case 'styleUpdated':
|
||||||
if (editor.getStyleId() === request.style.id &&
|
if (
|
||||||
request.reason !== 'editPreview' &&
|
editor.getStyleId() === request.style.id &&
|
||||||
request.reason !== 'editSave' &&
|
!['editPreview', 'editPreviewEnd', 'editSave', 'config']
|
||||||
request.reason !== 'config') {
|
.includes(request.reason)
|
||||||
Promise.resolve(request.codeIsUpdated === false ?
|
) {
|
||||||
|
Promise.resolve(
|
||||||
|
request.codeIsUpdated === false ?
|
||||||
request.style : API.getStyle(request.style.id)
|
request.style : API.getStyle(request.style.id)
|
||||||
)
|
)
|
||||||
.then(newStyle => {
|
.then(newStyle => {
|
||||||
|
|
|
@ -88,7 +88,6 @@
|
||||||
|
|
||||||
API.installUsercss({
|
API.installUsercss({
|
||||||
id: (installed || installedDup).id,
|
id: (installed || installedDup).id,
|
||||||
reason: 'update',
|
|
||||||
sourceCode
|
sourceCode
|
||||||
}).then(style => {
|
}).then(style => {
|
||||||
updateMeta(style);
|
updateMeta(style);
|
||||||
|
|
|
@ -125,7 +125,6 @@ function configDialog(style) {
|
||||||
}
|
}
|
||||||
style = style.sections ? Object.assign({}, style) : style;
|
style = style.sections ? Object.assign({}, style) : style;
|
||||||
style.enabled = true;
|
style.enabled = true;
|
||||||
style.reason = 'config';
|
|
||||||
style.sourceCode = null;
|
style.sourceCode = null;
|
||||||
style.sections = null;
|
style.sections = null;
|
||||||
const styleVars = style.usercssData.vars;
|
const styleVars = style.usercssData.vars;
|
||||||
|
|
|
@ -419,7 +419,6 @@ Object.assign(handleEvent, {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const json = entry.updatedCode;
|
const json = entry.updatedCode;
|
||||||
json.id = entry.styleId;
|
json.id = entry.styleId;
|
||||||
// json.reason = 'update';
|
|
||||||
API[json.usercssData ? 'installUsercss' : 'installStyle'](json);
|
API[json.usercssData ? 'installUsercss' : 'installStyle'](json);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -519,10 +518,7 @@ Object.assign(handleEvent, {
|
||||||
|
|
||||||
|
|
||||||
function handleUpdate(style, {reason, method} = {}) {
|
function handleUpdate(style, {reason, method} = {}) {
|
||||||
if (reason === 'editPreview') return;
|
if (reason === 'editPreview' || reason === 'editPreviewEnd') return;
|
||||||
// the style was toggled and refreshAllTabs() sent a mini-notification,
|
|
||||||
// but we've already processed 'styleUpdated' sent directly from notifyAllTabs()
|
|
||||||
// if (!style.sections) return;
|
|
||||||
let entry;
|
let entry;
|
||||||
let oldEntry = $(ENTRY_ID_PREFIX + style.id);
|
let oldEntry = $(ENTRY_ID_PREFIX + style.id);
|
||||||
if (oldEntry && method === 'styleUpdated') {
|
if (oldEntry && method === 'styleUpdated') {
|
||||||
|
|
|
@ -52,7 +52,7 @@ function onRuntimeMessage(msg) {
|
||||||
case 'styleAdded':
|
case 'styleAdded':
|
||||||
case 'styleUpdated':
|
case 'styleUpdated':
|
||||||
case 'exclusionsUpdated':
|
case 'exclusionsUpdated':
|
||||||
if (msg.reason === 'editPreview') return;
|
if (msg.reason === 'editPreview' || msg.reason === 'editPreviewEnd') return;
|
||||||
handleUpdate(msg.style);
|
handleUpdate(msg.style);
|
||||||
break;
|
break;
|
||||||
case 'styleDeleted':
|
case 'styleDeleted':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user