Change: getStylesInfoByUrl -> getStylesByUrl

This commit is contained in:
eight 2018-10-14 18:50:54 +08:00
parent f9dc04558f
commit 81f3e69574
4 changed files with 6 additions and 6 deletions

View File

@ -15,7 +15,7 @@ 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,
getStylesInfoByUrl: styleManager.getStylesInfoByUrl, getStylesByUrl: styleManager.getStylesByUrl,
importStyle: styleManager.importStyle, importStyle: styleManager.importStyle,
installStyle: styleManager.installStyle, installStyle: styleManager.installStyle,
styleExists: styleManager.styleExists, styleExists: styleManager.styleExists,

View File

@ -25,7 +25,7 @@
if (/^url:/i.test(query)) { if (/^url:/i.test(query)) {
matchUrl = query.slice(query.indexOf(':') + 1).trim(); matchUrl = query.slice(query.indexOf(':') + 1).trim();
if (matchUrl) { if (matchUrl) {
return styleManager.getStylesInfoByUrl(matchUrl) return styleManager.getStylesByUrl(matchUrl, true)
.then(results => results.map(r => r.data.id)); .then(results => results.map(r => r.data.id));
} }
} }

View File

@ -58,7 +58,7 @@ const styleManager = (() => {
toggleStyle, toggleStyle,
setStyleExclusions, setStyleExclusions,
getAllStyles, // used by import-export getAllStyles, // used by import-export
getStylesInfoByUrl, // used by popup getStylesByUrl, // used by popup
styleExists, styleExists,
}); });
@ -277,7 +277,7 @@ const styleManager = (() => {
} }
// get styles matching a URL, including sloppy regexps and excluded items. // get styles matching a URL, including sloppy regexps and excluded items.
function getStylesInfoByUrl(url) { function getStylesByUrl(url, noCode = false) {
// FIXME: do we want to cache this? Who would like to open popup rapidly // FIXME: do we want to cache this? Who would like to open popup rapidly
// or search the DB with the same URL? // or search the DB with the same URL?
const result = []; const result = [];
@ -308,7 +308,7 @@ const styleManager = (() => {
} }
if (sectionMatched) { if (sectionMatched) {
result.push({ result.push({
data: getStyleWithNoCode(style.data), data: noCode ? getStyleWithNoCode(style.data) : style.data,
excluded, excluded,
sloppy sloppy
}); });

View File

@ -25,7 +25,7 @@ getActiveTab()
) )
.then(url => Promise.all([ .then(url => Promise.all([
(tabURL = URLS.supported(url) ? url : '') && (tabURL = URLS.supported(url) ? url : '') &&
API.getStylesInfoByUrl(tabURL), API.getStylesByUrl(tabURL, true),
onDOMready().then(initPopup), onDOMready().then(initPopup),
])) ]))
.then(([results]) => { .then(([results]) => {