diff --git a/core/misc_util.js b/core/misc_util.js index 633cc967..6e477821 100644 --- a/core/misc_util.js +++ b/core/misc_util.js @@ -12,6 +12,7 @@ exports.valueWithDefault = valueWithDefault; exports.resolvePath = resolvePath; exports.getCleanEnigmaVersion = getCleanEnigmaVersion; exports.getEnigmaUserAgent = getEnigmaUserAgent; +exports.valueAsArray = valueAsArray; function isProduction() { var env = process.env.NODE_ENV || 'dev'; @@ -49,4 +50,11 @@ function getEnigmaUserAgent() { const nodeVer = process.version.substr(1); // remove 'v' prefix return `ENiGMA-BBS/${version} (${os.platform()}; ${os.arch()}; ${nodeVer})`; +} + +function valueAsArray(value) { + if(!value) { + return []; + } + return Array.isArray(value) ? value : [ value ]; } \ No newline at end of file diff --git a/core/new_scan.js b/core/new_scan.js index 974519af..4d20ac18 100644 --- a/core/new_scan.js +++ b/core/new_scan.js @@ -10,6 +10,7 @@ const FileEntry = require('./file_entry.js'); const FileBaseFilters = require('./file_base_filter.js'); const Errors = require('./enig_error.js').Errors; const { getAvailableFileAreaTags } = require('./file_base_area.js'); +const { valueAsArray } = require('./misc_util.js'); // deps const _ = require('lodash'); @@ -52,6 +53,7 @@ exports.getModule = class NewScanModule extends MenuModule { this.currentScanAux = {}; // :TODO: Make this conf/area specific: + // :TODO: Use newer custom info format - TL10+ const config = this.menuConfig.config; this.scanStartFmt = config.scanStartFmt || 'Scanning {confName} - {areaName}...'; this.scanFinishNoneFmt = config.scanFinishNoneFmt || 'Nothing new'; @@ -109,8 +111,12 @@ exports.getModule = class NewScanModule extends MenuModule { newScanMessageArea(conf, cb) { // :TODO: it would be nice to cache this - must be done by conf! - const sortedAreas = msgArea.getSortedAvailMessageAreasByConfTag(conf.confTag, { client : this.client } ); - const currentArea = sortedAreas[this.currentScanAux.area]; + const omitMessageAreaTags = valueAsArray(_.get(this, 'menuConfig.config.omitMessageAreaTags', [])); + const sortedAreas = _.omitBy( + msgArea.getSortedAvailMessageAreasByConfTag(conf.confTag, { client : this.client } ), + area => omitMessageAreaTags.includes(area.areaTag) + ); + const currentArea = sortedAreas[this.currentScanAux.area]; // // Scan and update index until we find something. If results are found, @@ -167,9 +173,10 @@ exports.getModule = class NewScanModule extends MenuModule { newScanFileBase(cb) { // :TODO: add in steps + const omitFileAreaTags = valueAsArray(_.get(this, 'menuConfig.config.omitFileAreaTags', [])); const filterCriteria = { newerThanFileId : FileBaseFilters.getFileBaseLastViewedFileIdByUser(this.client.user), - areaTag : getAvailableFileAreaTags(this.client), + areaTag : getAvailableFileAreaTags(this.client).filter(ft => !omitFileAreaTags.includes(ft)), order : 'ascending', // oldest first };