First pass formatting with Prettier

* Added .prettierrc.json
* Added .prettierignore
* Formatted
This commit is contained in:
Bryan Ashby
2022-06-05 14:04:25 -06:00
parent eecfb33ad5
commit 4881c2123a
172 changed files with 23696 additions and 18029 deletions

View File

@@ -2,24 +2,24 @@
'use strict';
// ENiGMA½
const { MenuModule } = require('./menu_module.js');
const messageArea = require('./message_area.js');
const { Errors } = require('./enig_error.js');
const { MenuModule } = require('./menu_module.js');
const messageArea = require('./message_area.js');
const { Errors } = require('./enig_error.js');
// deps
const async = require('async');
const _ = require('lodash');
const async = require('async');
const _ = require('lodash');
exports.moduleInfo = {
name : 'Message Conference List',
desc : 'Module for listing / choosing message conferences',
author : 'NuSkooler',
name: 'Message Conference List',
desc: 'Module for listing / choosing message conferences',
author: 'NuSkooler',
};
const MciViewIds = {
confList : 1,
confDesc : 2, // description updated @ index update
customRangeStart : 10, // updated @ index update
confList: 1,
confDesc: 2, // description updated @ index update
customRangeStart: 10, // updated @ index update
};
exports.getModule = class MessageConfListModule extends MenuModule {
@@ -29,51 +29,68 @@ exports.getModule = class MessageConfListModule extends MenuModule {
this.initList();
this.menuMethods = {
changeConference : (formData, extraArgs, cb) => {
if(1 === formData.submitId) {
changeConference: (formData, extraArgs, cb) => {
if (1 === formData.submitId) {
const conf = this.messageConfs[formData.value.conf];
messageArea.changeMessageConference(this.client, conf.confTag, err => {
if(err) {
this.client.term.pipeWrite(`\n|00Cannot change conference: ${err.message}\n`);
return this.prevMenuOnTimeout(1000, cb);
messageArea.changeMessageConference(
this.client,
conf.confTag,
err => {
if (err) {
this.client.term.pipeWrite(
`\n|00Cannot change conference: ${err.message}\n`
);
return this.prevMenuOnTimeout(1000, cb);
}
if (conf.hasArt) {
const menuOpts = {
extraArgs: {
confTag: conf.confTag,
},
menuFlags: ['popParent', 'noHistory'],
};
return this.gotoMenu(
this.menuConfig.config.changeConfPreArtMenu ||
'changeMessageConfPreArt',
menuOpts,
cb
);
}
return this.prevMenu(cb);
}
if(conf.hasArt) {
const menuOpts = {
extraArgs : {
confTag : conf.confTag,
},
menuFlags : [ 'popParent', 'noHistory' ]
};
return this.gotoMenu(this.menuConfig.config.changeConfPreArtMenu || 'changeMessageConfPreArt', menuOpts, cb);
}
return this.prevMenu(cb);
});
);
} else {
return cb(null);
}
}
},
};
}
mciReady(mciData, cb) {
super.mciReady(mciData, err => {
if(err) {
if (err) {
return cb(err);
}
async.series(
[
(next) => {
next => {
return this.prepViewController('confList', 0, mciData.menu, next);
},
(next) => {
const confListView = this.viewControllers.confList.getView(MciViewIds.confList);
if(!confListView) {
return next(Errors.MissingMci(`Missing conf list MCI ${MciViewIds.confList}`));
next => {
const confListView = this.viewControllers.confList.getView(
MciViewIds.confList
);
if (!confListView) {
return next(
Errors.MissingMci(
`Missing conf list MCI ${MciViewIds.confList}`
)
);
}
confListView.on('index update', idx => {
@@ -84,11 +101,14 @@ exports.getModule = class MessageConfListModule extends MenuModule {
confListView.redraw();
this.selectionIndexUpdate(0);
return next(null);
}
},
],
err => {
if(err) {
this.client.log.error( { error : err.message }, 'Failed loading message conference list');
if (err) {
this.client.log.error(
{ error: err.message },
'Failed loading message conference list'
);
}
}
);
@@ -97,26 +117,31 @@ exports.getModule = class MessageConfListModule extends MenuModule {
selectionIndexUpdate(idx) {
const conf = this.messageConfs[idx];
if(!conf) {
if (!conf) {
return;
}
this.setViewText('confList', MciViewIds.confDesc, conf.desc);
this.updateCustomViewTextsWithFilter('confList', MciViewIds.customRangeStart, conf);
this.updateCustomViewTextsWithFilter(
'confList',
MciViewIds.customRangeStart,
conf
);
}
initList()
{
initList() {
let index = 1;
this.messageConfs = messageArea.getSortedAvailMessageConferences(this.client).map(conf => {
return {
index : index++,
confTag : conf.confTag,
name : conf.conf.name,
text : conf.conf.name,
desc : conf.conf.desc,
areaCount : Object.keys(conf.conf.areas || {}).length,
hasArt : _.isString(conf.conf.art),
};
});
this.messageConfs = messageArea
.getSortedAvailMessageConferences(this.client)
.map(conf => {
return {
index: index++,
confTag: conf.confTag,
name: conf.conf.name,
text: conf.conf.name,
desc: conf.conf.desc,
areaCount: Object.keys(conf.conf.areas || {}).length,
hasArt: _.isString(conf.conf.art),
};
});
}
};