Add ability to omit message and/or file area tags from new scan by config 'omitFileAreaTags' and 'omitMessageAreaTags' arrays
This commit is contained in:
parent
53cda734e5
commit
539c25ea83
|
@ -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';
|
||||
|
@ -50,3 +51,10 @@ function getEnigmaUserAgent() {
|
|||
|
||||
return `ENiGMA-BBS/${version} (${os.platform()}; ${os.arch()}; ${nodeVer})`;
|
||||
}
|
||||
|
||||
function valueAsArray(value) {
|
||||
if(!value) {
|
||||
return [];
|
||||
}
|
||||
return Array.isArray(value) ? value : [ value ];
|
||||
}
|
|
@ -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,7 +111,11 @@ 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 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];
|
||||
|
||||
//
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue