Fix: remove unused methods

This commit is contained in:
eight 2018-10-12 03:43:31 +08:00
parent 3ae0c4dd13
commit a8131fc9c5
3 changed files with 8 additions and 22 deletions

View File

@ -10,13 +10,13 @@ var backgroundWorker = workerUtil.createWorker({
window.API_METHODS = Object.assign(window.API_METHODS || {}, {
getSectionsByUrl: styleManager.getSectionsByUrl,
getSectionsById: styleManager.getSectionsById,
getStylesInfo: styleManager.getStylesInfo,
getStylesInfoByUrl: styleManager.getStylesInfoByUrl,
toggleStyle: styleManager.toggleStyle,
deleteStyle: styleManager.deleteStyle,
getStylesInfoByUrl: styleManager.getStylesInfoByUrl,
installStyle: styleManager.installStyle,
editSave: styleManager.editSave,
styleExists: styleManager.styleExists,
getTabUrlPrefix() {
return this.sender.tab.url.match(/^([\w-]+:\/+[^/#]+)/)[1];

View File

@ -34,8 +34,7 @@ const styleManager = (() => {
toggleStyle,
getAllStyles, // used by import-export
getStylesInfoByUrl, // used by popup
countStyles,
countStylesByUrl, // used by icon badge
styleExists,
});
function handleLivePreviewConnections() {
@ -112,16 +111,8 @@ const styleManager = (() => {
.map(s => getStyleWithNoCode(s.data));
}
function countStyles(filter) {
if (!filter) {
return styles.size;
}
if (filter.id) {
return styles.has(filter.id) ? 1 : 0;
}
return [...styles.values()]
.filter(s => filterMatch(filter, s.data))
.length;
function styleExists(filter) {
return [...styles.value()].some(s => filterMatch(filter, s.data));
}
function filterMatch(filter, target) {
@ -291,11 +282,6 @@ const styleManager = (() => {
.map(k => getStyleWithNoCode(styles.get(Number(k)).data));
}
function countStylesByUrl(url, filter) {
const sections = getSectionsByUrl(url, filter);
return Object.keys(sections).length;
}
function getSectionsByUrl(url, filter) {
let cache = cachedStyleForUrl.get(url);
if (!cache) {

View File

@ -289,14 +289,14 @@ window.addEventListener('showStyles:done', function _() {
return;
}
const md5Url = UPDATE_URL.replace('%', result.id);
API.countStyles({md5Url}).then(installedStyle => {
if (installedStyle) {
API.styleExists({md5Url}).then(exist => {
if (exist) {
totalResults = Math.max(0, totalResults - 1);
} else {
processedResults.push(result);
render();
}
setTimeout(processNextResult, !installedStyle && DELAY_AFTER_FETCHING_STYLES);
setTimeout(processNextResult, !exist && DELAY_AFTER_FETCHING_STYLES);
});
}