Fix: remove unused methods
This commit is contained in:
parent
3ae0c4dd13
commit
a8131fc9c5
|
@ -10,13 +10,13 @@ var backgroundWorker = workerUtil.createWorker({
|
||||||
|
|
||||||
window.API_METHODS = Object.assign(window.API_METHODS || {}, {
|
window.API_METHODS = Object.assign(window.API_METHODS || {}, {
|
||||||
getSectionsByUrl: styleManager.getSectionsByUrl,
|
getSectionsByUrl: styleManager.getSectionsByUrl,
|
||||||
getSectionsById: styleManager.getSectionsById,
|
|
||||||
getStylesInfo: styleManager.getStylesInfo,
|
getStylesInfo: styleManager.getStylesInfo,
|
||||||
|
getStylesInfoByUrl: styleManager.getStylesInfoByUrl,
|
||||||
toggleStyle: styleManager.toggleStyle,
|
toggleStyle: styleManager.toggleStyle,
|
||||||
deleteStyle: styleManager.deleteStyle,
|
deleteStyle: styleManager.deleteStyle,
|
||||||
getStylesInfoByUrl: styleManager.getStylesInfoByUrl,
|
|
||||||
installStyle: styleManager.installStyle,
|
installStyle: styleManager.installStyle,
|
||||||
editSave: styleManager.editSave,
|
editSave: styleManager.editSave,
|
||||||
|
styleExists: styleManager.styleExists,
|
||||||
|
|
||||||
getTabUrlPrefix() {
|
getTabUrlPrefix() {
|
||||||
return this.sender.tab.url.match(/^([\w-]+:\/+[^/#]+)/)[1];
|
return this.sender.tab.url.match(/^([\w-]+:\/+[^/#]+)/)[1];
|
||||||
|
|
|
@ -34,8 +34,7 @@ const styleManager = (() => {
|
||||||
toggleStyle,
|
toggleStyle,
|
||||||
getAllStyles, // used by import-export
|
getAllStyles, // used by import-export
|
||||||
getStylesInfoByUrl, // used by popup
|
getStylesInfoByUrl, // used by popup
|
||||||
countStyles,
|
styleExists,
|
||||||
countStylesByUrl, // used by icon badge
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleLivePreviewConnections() {
|
function handleLivePreviewConnections() {
|
||||||
|
@ -112,16 +111,8 @@ const styleManager = (() => {
|
||||||
.map(s => getStyleWithNoCode(s.data));
|
.map(s => getStyleWithNoCode(s.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
function countStyles(filter) {
|
function styleExists(filter) {
|
||||||
if (!filter) {
|
return [...styles.value()].some(s => filterMatch(filter, s.data));
|
||||||
return styles.size;
|
|
||||||
}
|
|
||||||
if (filter.id) {
|
|
||||||
return styles.has(filter.id) ? 1 : 0;
|
|
||||||
}
|
|
||||||
return [...styles.values()]
|
|
||||||
.filter(s => filterMatch(filter, s.data))
|
|
||||||
.length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterMatch(filter, target) {
|
function filterMatch(filter, target) {
|
||||||
|
@ -291,11 +282,6 @@ const styleManager = (() => {
|
||||||
.map(k => getStyleWithNoCode(styles.get(Number(k)).data));
|
.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) {
|
function getSectionsByUrl(url, filter) {
|
||||||
let cache = cachedStyleForUrl.get(url);
|
let cache = cachedStyleForUrl.get(url);
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
|
|
|
@ -289,14 +289,14 @@ window.addEventListener('showStyles:done', function _() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const md5Url = UPDATE_URL.replace('%', result.id);
|
const md5Url = UPDATE_URL.replace('%', result.id);
|
||||||
API.countStyles({md5Url}).then(installedStyle => {
|
API.styleExists({md5Url}).then(exist => {
|
||||||
if (installedStyle) {
|
if (exist) {
|
||||||
totalResults = Math.max(0, totalResults - 1);
|
totalResults = Math.max(0, totalResults - 1);
|
||||||
} else {
|
} else {
|
||||||
processedResults.push(result);
|
processedResults.push(result);
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
setTimeout(processNextResult, !installedStyle && DELAY_AFTER_FETCHING_STYLES);
|
setTimeout(processNextResult, !exist && DELAY_AFTER_FETCHING_STYLES);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user