Enable msg_area_new to take a area tag as an argument
This commit is contained in:
parent
8e15c890a5
commit
71208075c3
@ -231,6 +231,11 @@ function atcode(field,length,pad,context) {
|
||||
|
||||
// Count of unread messages
|
||||
case 'msg_area_new':
|
||||
if (args.length === 1) {
|
||||
context = new MsgArea();
|
||||
context.code = args[0];
|
||||
}
|
||||
|
||||
if (typeof context !== 'object') {
|
||||
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
||||
break;
|
||||
|
@ -61,15 +61,23 @@ function MsgArea() {
|
||||
set: function(code) {
|
||||
this.msgbase = new MsgBase(code);
|
||||
|
||||
if (! this.msgbase.open()) {
|
||||
writeln(code+' cannot be opened:'+this.msgbase.error);
|
||||
exit(2);
|
||||
try {
|
||||
if (this.msgbase.open()) {
|
||||
// @todo If there are more than 10,000, take only the last 10,000.
|
||||
this.headers = this.msgbase.get_all_msg_headers(false,false) || [];
|
||||
this.msgbase.close();
|
||||
|
||||
} else {
|
||||
log(LOG_ERROR,code+' cannot be opened:'+this.msgbase.error);
|
||||
this.headers = [];
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
log(LOG_ERROR,code+' cannot be opened:'+e.message);
|
||||
this.headers = [];
|
||||
}
|
||||
|
||||
this.headers = this.msgbase.get_all_msg_headers(false,false) || [];
|
||||
// @todo If there are more than 10,000, take only the last 10,000.
|
||||
|
||||
this.msgbase.close();
|
||||
log(LOG_DEBUG,'msgbase:'+JSON.stringify(this.msgbase));
|
||||
}
|
||||
});
|
||||
|
||||
@ -259,7 +267,7 @@ MsgArea.prototype.getMessagePage = function(number) {
|
||||
}
|
||||
|
||||
MsgArea.prototype.getUserStats = function() {
|
||||
return msg_area.grp_list[this.msgbase.cfg.grp_number].sub_list[msg_area.sub[this.msgbase.cfg.code].index];
|
||||
return this.msgbase.cfg ? msg_area.grp_list[this.msgbase.cfg.grp_number].sub_list[msg_area.sub[this.msgbase.cfg.code].index] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user