From 8abcf9e7548c9a268e7260516dc9d7c6f2c4be81 Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 16 Jul 2021 23:57:50 +0000 Subject: [PATCH] Fix handleSave and sections TOC (#1284) --- background/style-manager.js | 22 +++++++++++----------- edit.html | 2 +- js/prefs.js | 1 + 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/background/style-manager.js b/background/style-manager.js index 3e9a00da..e473b079 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -107,7 +107,7 @@ const styleMan = (() => { if (ready.then) await ready; style = mergeWithMapped(style); style.updateDate = Date.now(); - return handleSave(await saveStyle(style), 'editSave'); + return handleSave(await saveStyle(style), {reason: 'editSave'}); }, /** @returns {Promise} */ @@ -223,7 +223,7 @@ const styleMan = (() => { const events = await db.exec('putMany', items); return Promise.all(items.map((item, 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; style.originalDigest = await calcStyleDigest(style); // FIXME: update updateDate? what about usercss config? - return handleSave(await saveStyle(style), reason); + return handleSave(await saveStyle(style), {reason}); }, /** @returns {Promise} */ @@ -264,7 +264,7 @@ const styleMan = (() => { if (diff < 0) { doc.id = await db.exec('put', doc); 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) { if (ready.then) await ready; const style = Object.assign({}, id2style(id), {enabled}); - handleSave(await saveStyle(style), 'toggle', false); + handleSave(await saveStyle(style), {reason: 'toggle', codeIsUpdated: false}); return id; }, @@ -369,7 +369,7 @@ const styleMan = (() => { case 'revoke': await tokenMan.revokeToken('userstylesworld', style.id); style._usw = {}; - handleSave(await saveStyle(style), 'success-revoke', true); + handleSave(await saveStyle(style), {reason: 'success-revoke', codeIsUpdated: true}); break; case 'publish': @@ -392,7 +392,7 @@ const styleMan = (() => { delete someStyle.tmpSourceCode; delete someStyle.metadata; } - handleSave(await saveStyle(someStyle), null, null, false); + handleSave(await saveStyle(someStyle), {broadcast: false}); } style._usw = { 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))) { style._usw[k] = v; } - handleSave(await saveStyle(style), 'success-publishing', true); + handleSave(await saveStyle(style), {reason: 'success-publishing', codeIsUpdated: true}); } uploadStyle(style); break; @@ -420,7 +420,7 @@ const styleMan = (() => { throw new Error('The rule already exists'); } style[type] = list.concat([rule]); - return handleSave(await saveStyle(style), 'styleSettings'); + return handleSave(await saveStyle(style), {reason: 'styleSettings'}); } async function removeIncludeExclude(type, id, rule) { @@ -431,7 +431,7 @@ const styleMan = (() => { return; } 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) { @@ -497,7 +497,7 @@ const styleMan = (() => { return style; } - function handleSave(style, reason, codeIsUpdated, broadcast = true) { + function handleSave(style, {reason, codeIsUpdated, broadcast = true}) { const data = id2data(style.id); const method = data ? 'styleUpdated' : 'styleAdded'; if (!data) { diff --git a/edit.html b/edit.html index a48f96f9..f37e083f 100644 --- a/edit.html +++ b/edit.html @@ -392,7 +392,7 @@ -
+

diff --git a/js/prefs.js b/js/prefs.js index 3d7b93fa..5a5011d3 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -61,6 +61,7 @@ 'editor.toc.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.integration.expanded': true, // UI element state expanded/collapsed 'editor.lineWrapping': true, // word wrap 'editor.smartIndent': true, // 'smart' indent 'editor.indentWithTabs': false, // smart indent with tabs