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.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;
}
}