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.resolvePath = resolvePath;
|
||||||
exports.getCleanEnigmaVersion = getCleanEnigmaVersion;
|
exports.getCleanEnigmaVersion = getCleanEnigmaVersion;
|
||||||
exports.getEnigmaUserAgent = getEnigmaUserAgent;
|
exports.getEnigmaUserAgent = getEnigmaUserAgent;
|
||||||
|
exports.valueAsArray = valueAsArray;
|
||||||
|
|
||||||
function isProduction() {
|
function isProduction() {
|
||||||
var env = process.env.NODE_ENV || 'dev';
|
var env = process.env.NODE_ENV || 'dev';
|
||||||
|
@ -49,4 +50,11 @@ function getEnigmaUserAgent() {
|
||||||
const nodeVer = process.version.substr(1); // remove 'v' prefix
|
const nodeVer = process.version.substr(1); // remove 'v' prefix
|
||||||
|
|
||||||
return `ENiGMA-BBS/${version} (${os.platform()}; ${os.arch()}; ${nodeVer})`;
|
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 FileBaseFilters = require('./file_base_filter.js');
|
||||||
const Errors = require('./enig_error.js').Errors;
|
const Errors = require('./enig_error.js').Errors;
|
||||||
const { getAvailableFileAreaTags } = require('./file_base_area.js');
|
const { getAvailableFileAreaTags } = require('./file_base_area.js');
|
||||||
|
const { valueAsArray } = require('./misc_util.js');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
@ -52,6 +53,7 @@ exports.getModule = class NewScanModule extends MenuModule {
|
||||||
this.currentScanAux = {};
|
this.currentScanAux = {};
|
||||||
|
|
||||||
// :TODO: Make this conf/area specific:
|
// :TODO: Make this conf/area specific:
|
||||||
|
// :TODO: Use newer custom info format - TL10+
|
||||||
const config = this.menuConfig.config;
|
const config = this.menuConfig.config;
|
||||||
this.scanStartFmt = config.scanStartFmt || 'Scanning {confName} - {areaName}...';
|
this.scanStartFmt = config.scanStartFmt || 'Scanning {confName} - {areaName}...';
|
||||||
this.scanFinishNoneFmt = config.scanFinishNoneFmt || 'Nothing new';
|
this.scanFinishNoneFmt = config.scanFinishNoneFmt || 'Nothing new';
|
||||||
|
@ -109,8 +111,12 @@ exports.getModule = class NewScanModule extends MenuModule {
|
||||||
|
|
||||||
newScanMessageArea(conf, cb) {
|
newScanMessageArea(conf, cb) {
|
||||||
// :TODO: it would be nice to cache this - must be done by conf!
|
// :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 currentArea = sortedAreas[this.currentScanAux.area];
|
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,
|
// Scan and update index until we find something. If results are found,
|
||||||
|
@ -167,9 +173,10 @@ exports.getModule = class NewScanModule extends MenuModule {
|
||||||
|
|
||||||
newScanFileBase(cb) {
|
newScanFileBase(cb) {
|
||||||
// :TODO: add in steps
|
// :TODO: add in steps
|
||||||
|
const omitFileAreaTags = valueAsArray(_.get(this, 'menuConfig.config.omitFileAreaTags', []));
|
||||||
const filterCriteria = {
|
const filterCriteria = {
|
||||||
newerThanFileId : FileBaseFilters.getFileBaseLastViewedFileIdByUser(this.client.user),
|
newerThanFileId : FileBaseFilters.getFileBaseLastViewedFileIdByUser(this.client.user),
|
||||||
areaTag : getAvailableFileAreaTags(this.client),
|
areaTag : getAvailableFileAreaTags(this.client).filter(ft => !omitFileAreaTags.includes(ft)),
|
||||||
order : 'ascending', // oldest first
|
order : 'ascending', // oldest first
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue