Fix handleSave and sections TOC (#1284)
This commit is contained in:
parent
654403eb00
commit
8abcf9e754
|
@ -107,7 +107,7 @@ const styleMan = (() => {
|
||||||
if (ready.then) await ready;
|
if (ready.then) await ready;
|
||||||
style = mergeWithMapped(style);
|
style = mergeWithMapped(style);
|
||||||
style.updateDate = Date.now();
|
style.updateDate = Date.now();
|
||||||
return handleSave(await saveStyle(style), 'editSave');
|
return handleSave(await saveStyle(style), {reason: 'editSave'});
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @returns {Promise<?StyleObj>} */
|
/** @returns {Promise<?StyleObj>} */
|
||||||
|
@ -223,7 +223,7 @@ const styleMan = (() => {
|
||||||
const events = await db.exec('putMany', items);
|
const events = await db.exec('putMany', items);
|
||||||
return Promise.all(items.map((item, i) => {
|
return Promise.all(items.map((item, i) => {
|
||||||
afterSave(item, events[i]);
|
afterSave(item, events[i]);
|
||||||
return handleSave(item, 'import');
|
return handleSave(item, {reason: 'import'});
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ const styleMan = (() => {
|
||||||
if (url) style.url = style.installationUrl = url;
|
if (url) style.url = style.installationUrl = url;
|
||||||
style.originalDigest = await calcStyleDigest(style);
|
style.originalDigest = await calcStyleDigest(style);
|
||||||
// FIXME: update updateDate? what about usercss config?
|
// FIXME: update updateDate? what about usercss config?
|
||||||
return handleSave(await saveStyle(style), reason);
|
return handleSave(await saveStyle(style), {reason});
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @returns {Promise<?StyleObj>} */
|
/** @returns {Promise<?StyleObj>} */
|
||||||
|
@ -264,7 +264,7 @@ const styleMan = (() => {
|
||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
doc.id = await db.exec('put', doc);
|
doc.id = await db.exec('put', doc);
|
||||||
uuidIndex.set(doc._id, doc.id);
|
uuidIndex.set(doc._id, doc.id);
|
||||||
return handleSave(doc, 'sync');
|
return handleSave(doc, {reason: 'sync'});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ const styleMan = (() => {
|
||||||
async toggle(id, enabled) {
|
async toggle(id, enabled) {
|
||||||
if (ready.then) await ready;
|
if (ready.then) await ready;
|
||||||
const style = Object.assign({}, id2style(id), {enabled});
|
const style = Object.assign({}, id2style(id), {enabled});
|
||||||
handleSave(await saveStyle(style), 'toggle', false);
|
handleSave(await saveStyle(style), {reason: 'toggle', codeIsUpdated: false});
|
||||||
return id;
|
return id;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ const styleMan = (() => {
|
||||||
case 'revoke':
|
case 'revoke':
|
||||||
await tokenMan.revokeToken('userstylesworld', style.id);
|
await tokenMan.revokeToken('userstylesworld', style.id);
|
||||||
style._usw = {};
|
style._usw = {};
|
||||||
handleSave(await saveStyle(style), 'success-revoke', true);
|
handleSave(await saveStyle(style), {reason: 'success-revoke', codeIsUpdated: true});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'publish':
|
case 'publish':
|
||||||
|
@ -392,7 +392,7 @@ const styleMan = (() => {
|
||||||
delete someStyle.tmpSourceCode;
|
delete someStyle.tmpSourceCode;
|
||||||
delete someStyle.metadata;
|
delete someStyle.metadata;
|
||||||
}
|
}
|
||||||
handleSave(await saveStyle(someStyle), null, null, false);
|
handleSave(await saveStyle(someStyle), {broadcast: false});
|
||||||
}
|
}
|
||||||
style._usw = {
|
style._usw = {
|
||||||
token: await tokenMan.getToken('userstylesworld', true, style.id),
|
token: await tokenMan.getToken('userstylesworld', true, style.id),
|
||||||
|
@ -404,7 +404,7 @@ const styleMan = (() => {
|
||||||
for (const [k, v] of Object.entries(await retrieveStyleInformation(style._usw.token))) {
|
for (const [k, v] of Object.entries(await retrieveStyleInformation(style._usw.token))) {
|
||||||
style._usw[k] = v;
|
style._usw[k] = v;
|
||||||
}
|
}
|
||||||
handleSave(await saveStyle(style), 'success-publishing', true);
|
handleSave(await saveStyle(style), {reason: 'success-publishing', codeIsUpdated: true});
|
||||||
}
|
}
|
||||||
uploadStyle(style);
|
uploadStyle(style);
|
||||||
break;
|
break;
|
||||||
|
@ -420,7 +420,7 @@ const styleMan = (() => {
|
||||||
throw new Error('The rule already exists');
|
throw new Error('The rule already exists');
|
||||||
}
|
}
|
||||||
style[type] = list.concat([rule]);
|
style[type] = list.concat([rule]);
|
||||||
return handleSave(await saveStyle(style), 'styleSettings');
|
return handleSave(await saveStyle(style), {reason: 'styleSettings'});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeIncludeExclude(type, id, rule) {
|
async function removeIncludeExclude(type, id, rule) {
|
||||||
|
@ -431,7 +431,7 @@ const styleMan = (() => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
style[type] = list.filter(r => r !== rule);
|
style[type] = list.filter(r => r !== rule);
|
||||||
return handleSave(await saveStyle(style), 'styleSettings');
|
return handleSave(await saveStyle(style), {reason: 'styleSettings'});
|
||||||
}
|
}
|
||||||
|
|
||||||
function broadcastStyleUpdated(style, reason, method = 'styleUpdated', codeIsUpdated = true) {
|
function broadcastStyleUpdated(style, reason, method = 'styleUpdated', codeIsUpdated = true) {
|
||||||
|
@ -497,7 +497,7 @@ const styleMan = (() => {
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSave(style, reason, codeIsUpdated, broadcast = true) {
|
function handleSave(style, {reason, codeIsUpdated, broadcast = true}) {
|
||||||
const data = id2data(style.id);
|
const data = id2data(style.id);
|
||||||
const method = data ? 'styleUpdated' : 'styleAdded';
|
const method = data ? 'styleUpdated' : 'styleAdded';
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
|
@ -392,7 +392,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<details id="integration" data-pref="editor.toc.expanded" class="ignore-pref-if-compact">
|
<details id="integration" data-pref="editor.integration.expanded" class="ignore-pref-if-compact">
|
||||||
<summary><h2 i18n-text="integration"></h2></summary>
|
<summary><h2 i18n-text="integration"></h2></summary>
|
||||||
<div>
|
<div>
|
||||||
<button id="publish-style" i18n-text="uploadStyle"></button>
|
<button id="publish-style" i18n-text="uploadStyle"></button>
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
'editor.toc.expanded': true, // UI element state: expanded/collapsed
|
'editor.toc.expanded': true, // UI element state: expanded/collapsed
|
||||||
'editor.options.expanded': true, // UI element state: expanded/collapsed
|
'editor.options.expanded': true, // UI element state: expanded/collapsed
|
||||||
'editor.lint.expanded': true, // UI element state: expanded/collapsed
|
'editor.lint.expanded': true, // UI element state: expanded/collapsed
|
||||||
|
'editor.integration.expanded': true, // UI element state expanded/collapsed
|
||||||
'editor.lineWrapping': true, // word wrap
|
'editor.lineWrapping': true, // word wrap
|
||||||
'editor.smartIndent': true, // 'smart' indent
|
'editor.smartIndent': true, // 'smart' indent
|
||||||
'editor.indentWithTabs': false, // smart indent with tabs
|
'editor.indentWithTabs': false, // smart indent with tabs
|
||||||
|
|
Loading…
Reference in New Issue
Block a user