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.

This commit is contained in:
Deon George 2022-04-22 22:42:20 +10:00
parent 30d402e797
commit b3367a082d

View File

@ -51,6 +51,8 @@ function MsgArea() {
this.headers = undefined; this.headers = undefined;
this.tagged_list = undefined; this.tagged_list = undefined;
this.untagged_list = undefined; this.untagged_list = undefined;
this.grp_number = undefined;
this.subnum = undefined;
Object.defineProperty(this,'code',{ Object.defineProperty(this,'code',{
set: function(code) { set: function(code) {
@ -115,7 +117,6 @@ function MsgArea() {
this.untagged_list.push(this.headers[x]); this.untagged_list.push(this.headers[x]);
write(); // @todo This is needed for this to work? 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 // Get Next page number
Object.defineProperty(this,'page_next',{ Object.defineProperty(this,'page_next',{
get: function() { get: function() {
@ -183,6 +181,9 @@ MsgArea.prototype.getMessage = function(page) {
return undefined; 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); msg.content = this.msgbase.get_msg_body(false,msg.number,false,false,true,true);
this.msgbase.close(); this.msgbase.close();
@ -195,6 +196,8 @@ MsgArea.prototype.getMessage = function(page) {
* @returns {boolean} * @returns {boolean}
*/ */
MsgArea.prototype.tag_msgs = function() { MsgArea.prototype.tag_msgs = function() {
const MAX_PAGE_NUM = 9999;
var msgs = this.list_untagged; var msgs = this.list_untagged;
// See if we need to something // See if we need to something
@ -207,15 +210,17 @@ MsgArea.prototype.tag_msgs = function() {
} }
var page_next = this.page_next; var page_next = this.page_next;
for(var x in msgs) { for(var x in msgs) {
var msg = this.msgbase.get_msg_header(msgs[x].number, /* expand: */false) msgs[x].tags = (''+(page_next)).padStart(4,'0');
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(msgs[x].number,msgs[x])) {
if(! this.msgbase.put_msg_header(msg.number,msg)) {
writeln('ERROR:'+this.msgbase.error); writeln('ERROR:'+this.msgbase.error);
} else { } else {
page_next++; page_next++;
if (page_next > MAX_PAGE_NUM)
page_next = 0;
} }
} }