Fix: drop getStylesInfo
This commit is contained in:
parent
fea04d591f
commit
f9dc04558f
|
@ -15,7 +15,6 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, {
|
||||||
getAllStyles: styleManager.getAllStyles, // used by importer
|
getAllStyles: styleManager.getAllStyles, // used by importer
|
||||||
getSectionsByUrl: styleManager.getSectionsByUrl,
|
getSectionsByUrl: styleManager.getSectionsByUrl,
|
||||||
getStyle: styleManager.get,
|
getStyle: styleManager.get,
|
||||||
getStylesInfo: styleManager.getStylesInfo,
|
|
||||||
getStylesInfoByUrl: styleManager.getStylesInfoByUrl,
|
getStylesInfoByUrl: styleManager.getStylesInfoByUrl,
|
||||||
importStyle: styleManager.importStyle,
|
importStyle: styleManager.importStyle,
|
||||||
installStyle: styleManager.installStyle,
|
installStyle: styleManager.installStyle,
|
||||||
|
|
|
@ -49,7 +49,6 @@ const styleManager = (() => {
|
||||||
|
|
||||||
return ensurePrepared({
|
return ensurePrepared({
|
||||||
get,
|
get,
|
||||||
getStylesInfo,
|
|
||||||
getSectionsByUrl,
|
getSectionsByUrl,
|
||||||
installStyle,
|
installStyle,
|
||||||
deleteStyle,
|
deleteStyle,
|
||||||
|
@ -92,12 +91,14 @@ const styleManager = (() => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get(id) {
|
function get(id, noCode = false) {
|
||||||
return styles.get(id).data;
|
const data = styles.get(id).data;
|
||||||
|
return noCode ? getStyleWithNoCode(data) : data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllStyles() {
|
function getAllStyles(noCode = false) {
|
||||||
return [...styles.values()].map(s => s.data);
|
const datas = [...styles.values()].map(s => s.data);
|
||||||
|
return noCode ? datas.map(getStyleWithNoCode) : datas;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleStyle(id, enabled) {
|
function toggleStyle(id, enabled) {
|
||||||
|
@ -108,15 +109,6 @@ const styleManager = (() => {
|
||||||
.then(() => id);
|
.then(() => id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStylesInfo(filter) {
|
|
||||||
if (filter && filter.id) {
|
|
||||||
return [getStyleWithNoCode(styles.get(filter.id).data)];
|
|
||||||
}
|
|
||||||
return [...styles.values()]
|
|
||||||
.filter(s => !filter || filterMatch(filter, s.data))
|
|
||||||
.map(s => getStyleWithNoCode(s.data));
|
|
||||||
}
|
|
||||||
|
|
||||||
// used by install-hook-userstyles.js
|
// used by install-hook-userstyles.js
|
||||||
function findStyle(filter, noCode = false) {
|
function findStyle(filter, noCode = false) {
|
||||||
for (const style of styles.values()) {
|
for (const style of styles.values()) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ function configDialog(style) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!bgStyle) {
|
if (!bgStyle) {
|
||||||
API.getStylesInfo({id: style.id})
|
API.getStyle(style.id, true)
|
||||||
.then(([bgStyle]) => save({anyChangeIsDirty}, bgStyle || {}));
|
.then(([bgStyle]) => save({anyChangeIsDirty}, bgStyle || {}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ const OWN_ICON = chrome.runtime.getManifest().icons['16'];
|
||||||
const handleEvent = {};
|
const handleEvent = {};
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
API.getStylesInfo(),
|
API.getAllStyles(true),
|
||||||
urlFilterParam && API.searchDB({query: 'url:' + urlFilterParam}),
|
urlFilterParam && API.searchDB({query: 'url:' + urlFilterParam}),
|
||||||
onDOMready().then(initGlobalEvents),
|
onDOMready().then(initGlobalEvents),
|
||||||
]).then(args => {
|
]).then(args => {
|
||||||
|
@ -48,8 +48,8 @@ function onRuntimeMessage(msg) {
|
||||||
switch (msg.method) {
|
switch (msg.method) {
|
||||||
case 'styleUpdated':
|
case 'styleUpdated':
|
||||||
case 'styleAdded':
|
case 'styleAdded':
|
||||||
API.getStylesInfo({id: msg.style.id})
|
API.getStyle(msg.style.id, true)
|
||||||
.then(([style]) => handleUpdate(style, msg));
|
.then(style => handleUpdate(style, msg));
|
||||||
break;
|
break;
|
||||||
case 'styleDeleted':
|
case 'styleDeleted':
|
||||||
handleDelete(msg.style.id);
|
handleDelete(msg.style.id);
|
||||||
|
@ -647,7 +647,7 @@ function switchUI({styleOnly} = {}) {
|
||||||
const missingFavicons = newUI.enabled && newUI.favicons && !$('.applies-to img');
|
const missingFavicons = newUI.enabled && newUI.favicons && !$('.applies-to img');
|
||||||
if (changed.enabled || (missingFavicons && !createStyleElement.parts)) {
|
if (changed.enabled || (missingFavicons && !createStyleElement.parts)) {
|
||||||
installed.textContent = '';
|
installed.textContent = '';
|
||||||
API.getStylesInfo().then(showStyles);
|
API.getAllStyles(true).then(showStyles);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (changed.targets) {
|
if (changed.targets) {
|
||||||
|
@ -671,11 +671,10 @@ function onVisibilityChange() {
|
||||||
// assuming other changes aren't important enough to justify making a complicated DOM sync
|
// assuming other changes aren't important enough to justify making a complicated DOM sync
|
||||||
case 'visible':
|
case 'visible':
|
||||||
if (sessionStorage.justEditedStyleId) {
|
if (sessionStorage.justEditedStyleId) {
|
||||||
API.getStylesInfo({
|
API.getStyle(Number(sessionStorage.justEditedStyleId), true)
|
||||||
id: sessionStorage.justEditedStyleId
|
.then(style => {
|
||||||
}).then(([style]) => {
|
handleUpdate(style, {method: 'styleUpdated'});
|
||||||
handleUpdate(style, {method: 'styleUpdated'});
|
});
|
||||||
});
|
|
||||||
delete sessionStorage.justEditedStyleId;
|
delete sessionStorage.justEditedStyleId;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
global configDialog hotkeys
|
global configDialog hotkeys
|
||||||
popupExclusions onTabReady msg
|
popupExclusions onTabReady msg
|
||||||
getActiveTab FIREFOX getTabRealURL URLS API onDOMready $ $$ prefs CHROME
|
getActiveTab FIREFOX getTabRealURL URLS API onDOMready $ $$ prefs CHROME
|
||||||
setupLivePrefs template ignoreChromeError t $create tWordBreak animateElement
|
setupLivePrefs template t $create tWordBreak animateElement
|
||||||
tryJSONparse debounce
|
tryJSONparse debounce
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ Object.assign(handleEvent, {
|
||||||
configure(event) {
|
configure(event) {
|
||||||
const {styleId, styleIsUsercss} = handleEvent.getClickedStyleElement(event);
|
const {styleId, styleIsUsercss} = handleEvent.getClickedStyleElement(event);
|
||||||
if (styleIsUsercss) {
|
if (styleIsUsercss) {
|
||||||
API.getStylesInfo({id: styleId}).then(([style]) => {
|
API.getStyle(styleId, true).then(style => {
|
||||||
hotkeys.setState(false);
|
hotkeys.setState(false);
|
||||||
configDialog(style).then(() => {
|
configDialog(style).then(() => {
|
||||||
hotkeys.setState(true);
|
hotkeys.setState(true);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user