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