From 83d0daf4b797fa578ac54cc2633dafde84c42ef4 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Fri, 15 Feb 2019 21:55:18 -0700 Subject: [PATCH] Add 'My Messages' module --- art/themes/luciano_blocktronics/MSGMNU.ANS | Bin 3660 -> 3685 bytes art/themes/luciano_blocktronics/MYMSGLST.ANS | Bin 0 -> 2122 bytes art/themes/luciano_blocktronics/theme.hjson | 15 +++++ core/my_messages.js | 59 +++++++++++++++++++ misc/menu_template.in.hjson | 37 ++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 art/themes/luciano_blocktronics/MYMSGLST.ANS create mode 100644 core/my_messages.js diff --git a/art/themes/luciano_blocktronics/MSGMNU.ANS b/art/themes/luciano_blocktronics/MSGMNU.ANS index 3585799b98f1e143184bf8efa54e5da16bfccba8..9c373944c901ce9fba4302f0fee7c0ef272e5d00 100644 GIT binary patch delta 54 zcmX>j^HgR7C#$lBvvjm!Zmx8+fwi$&u0n2VadBdLYOz8|K9H>-9c^rsyIGi3n3M6> IWOY7O0M3sPA^-pY delta 29 lcmaDVb4F$ZCo7kcv9olvu~F_uh0Qvw!kml`Cp++|0sw}G2wMOE diff --git a/art/themes/luciano_blocktronics/MYMSGLST.ANS b/art/themes/luciano_blocktronics/MYMSGLST.ANS new file mode 100644 index 0000000000000000000000000000000000000000..a56197bcc6fce15564c05499a6a4ac1d26e5aacc GIT binary patch literal 2122 zcmb_d%Zd|06wR!JY~45pv^MVhk#wV3jbRWM1LELpvQr`|)(kpEe`}a;n7`8v_ z?!8rAi9rOdMR(VIpL1_j&(_s)UM<_oyV<(-VHj5oG0fJLhrC|lK_kdU1AIjqImf5I zow+QMhiJqnOx-YOz7U|h@P=hA#fR3O2`^5 zK)TCt#MxA-sidKBEwUk3kD{Key^knW#(`C!bEoGR90+7v`Aox??MIskO_paO@xZ@_ zo@zV71uU{4N%+zEo14U4VFQf}z4f&SRJ@5a2O?YrKWB;84upH6fUA<0dxq@B=*}#3H>0O1 zss34`{IcWp;rYp%)oE2R-hWz6RWItQu72K|OpcCTO^zqB?!SC~<}O~G=q^8h0Z?wp AJ^%m! literal 0 HcmV?d00001 diff --git a/art/themes/luciano_blocktronics/theme.hjson b/art/themes/luciano_blocktronics/theme.hjson index 4a35eb15..998d4c34 100644 --- a/art/themes/luciano_blocktronics/theme.hjson +++ b/art/themes/luciano_blocktronics/theme.hjson @@ -450,6 +450,21 @@ } } + messageAreaMyMessagesList: { + config: { + // Fri Sep 25th + dateTimeFormat: ddd MMM Do + } + mci: { + VM1: { + height: 16 + width: 71 + itemFormat: "|00|15 {msgNum:<4.4} |03{subject:<34.33} {fromUserName:<19.18} |03{ts:<12.12}" + focusItemFormat: "|00|19> |15{msgNum:<4.4} {subject:<34.33} {fromUserName:<19.18} {ts:<12.12}" + } + } + } + messageAreaViewPost: { 0: { mci: { diff --git a/core/my_messages.js b/core/my_messages.js new file mode 100644 index 00000000..721e1f9d --- /dev/null +++ b/core/my_messages.js @@ -0,0 +1,59 @@ +/* jslint node: true */ +'use strict'; + +// ENiGMA½ +const MenuModule = require('./menu_module.js').MenuModule; +const Message = require('./message.js'); +const UserProps = require('./user_property.js'); + +exports.moduleInfo = { + name : 'My Messages', + desc : 'Finds messages addressed to the current user.', + author : 'NuSkooler', +}; + +exports.getModule = class MyMessagesModule extends MenuModule { + constructor(options) { + super(options); + } + + initSequence() { + const filter = { + toUserName : [ this.client.user.username, this.client.user.getProperty(UserProps.RealName) ], + sort : 'modTimestamp', + resultType : 'messageList', + limit : 1024 * 16, // we want some sort of limit... + }; + + Message.findMessages(filter, (err, messageList) => { + if(err) { + this.client.log.warn( { error : err.message }, 'Error finding messages addressed to current user'); + return this.prevMenu(); + } + this.messageList = messageList; + this.finishedLoading(); + }); + } + + finishedLoading() { + if(!this.messageList || 0 === this.messageList.length) { + return this.gotoMenu( + this.menuConfig.config.noResultsMenu || 'messageSearchNoResults', + { menuFlags : [ 'popParent' ] } + ); + } + + const menuOpts = { + extraArgs : { + messageList : this.messageList, + noUpdateLastReadId : true + }, + menuFlags : [ 'popParent' ], + }; + + return this.gotoMenu( + this.menuConfig.config.messageListMenu || 'messageAreaMessageList', + menuOpts + ); + } +}; diff --git a/misc/menu_template.in.hjson b/misc/menu_template.in.hjson index bdcf97cd..ac51397f 100644 --- a/misc/menu_template.in.hjson +++ b/misc/menu_template.in.hjson @@ -1970,6 +1970,43 @@ } } + messageAreaMyMessagesList: { + desc: Personal Messages + module: msg_list + art: MYMSGLST + config: { + menuViewPost: messageAreaViewPost + } + form: { + 0: { + mci: { + VM1: { + focus: true + submit: true + argName: message + } + TL6: { + // theme me! + } + } + submit: { + *: [ + { + value: { message: null } + action: @method:selectMessage + } + ] + } + actionKeys: [ + { + keys: [ "escape", "q", "shift + q" ] + action: @systemMethod:prevMenu + } + ] + } + } + } + messageSearchNoResults: { desc: Message Search art: MSRCNORES