From b3367a082dd9353287ed204aac59c2757eba146c Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 22 Apr 2022 22:42:20 +1000 Subject: [PATCH] Revert to avoid using get_msg_header and using index of get_all_msg_headers. Also more support for using msg_area.* when recalling a specific message. --- load/msgbases.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/load/msgbases.js b/load/msgbases.js index acecd18..e81eb3a 100644 --- a/load/msgbases.js +++ b/load/msgbases.js @@ -51,6 +51,8 @@ function MsgArea() { this.headers = undefined; this.tagged_list = undefined; this.untagged_list = undefined; + this.grp_number = undefined; + this.subnum = undefined; Object.defineProperty(this,'code',{ set: function(code) { @@ -115,7 +117,6 @@ function MsgArea() { this.untagged_list.push(this.headers[x]); write(); // @todo This is needed for this to work? } - } } @@ -123,9 +124,6 @@ function MsgArea() { } }); - // Get first untagged message - // Get specific tagged message - // Get Next page number Object.defineProperty(this,'page_next',{ get: function() { @@ -183,6 +181,9 @@ MsgArea.prototype.getMessage = function(page) { return undefined; } + msg.grp_number = this.msgbase.cfg.grp_number; + var cfg = this.msgbase.cfg; + msg.subnum = msg_area.grp_list[cfg.grp_number].sub_list.filter(function(x) { return x.number === cfg.number; }).pop().index; msg.content = this.msgbase.get_msg_body(false,msg.number,false,false,true,true); this.msgbase.close(); @@ -195,6 +196,8 @@ MsgArea.prototype.getMessage = function(page) { * @returns {boolean} */ MsgArea.prototype.tag_msgs = function() { + const MAX_PAGE_NUM = 9999; + var msgs = this.list_untagged; // See if we need to something @@ -207,15 +210,17 @@ MsgArea.prototype.tag_msgs = function() { } var page_next = this.page_next; + for(var x in msgs) { - var msg = this.msgbase.get_msg_header(msgs[x].number, /* expand: */false) - writeln('Setting page:'+(''+(page_next)).padStart(4,'0')+', for:'+msg.number+', existing tag:'+msg.tags); - msg.tags = (''+(page_next)).padStart(4,'0'); - if(! this.msgbase.put_msg_header(msg.number,msg)) { + msgs[x].tags = (''+(page_next)).padStart(4,'0'); + + if(! this.msgbase.put_msg_header(msgs[x].number,msgs[x])) { writeln('ERROR:'+this.msgbase.error); } else { page_next++; + if (page_next > MAX_PAGE_NUM) + page_next = 0; } }