Skip to content
Snippets Groups Projects
Commit 7b42c86a authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'dd_msg_area_chooser_posts_property' into 'master'

Message area chooser only: Made use of the 'posts' property for the number of messages (without vote headers)

See merge request !215
parents 4dd32231 95a6db8a
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!215Message area chooser only: Made use of the 'posts' property for the number of messages (without vote headers)
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
* 2022-08-19 Eric Oulashin Version 1.30 * 2022-08-19 Eric Oulashin Version 1.30
* Set the control key pass-thru so that some hotkeys (such as Ctrl-P for PageUp) only * Set the control key pass-thru so that some hotkeys (such as Ctrl-P for PageUp) only
* get caught by this script. * get caught by this script.
* 2022-11-04 Eric Oulashin Version 1.31
* Made use of the 'posts' property in msg_area.sub[sub-code] (or msg_area.grp_list.sub_list)
* for the number of posts without votes
*/ */
// TODO: In the area list, the 10,000ths digit (for # posts) is in a different color) // TODO: In the area list, the 10,000ths digit (for # posts) is in a different color)
...@@ -136,11 +139,6 @@ else if (typeof(argv[0]) == "string") ...@@ -136,11 +139,6 @@ else if (typeof(argv[0]) == "string")
gChooseMsgGrpOnStartup = (argv[0].toLowerCase() == "true"); gChooseMsgGrpOnStartup = (argv[0].toLowerCase() == "true");
// When using the number of messages in a sub-board, whether or not to count the
// number of readable messages (which can be slow). If false, will just look at the number
// of all messages in the sub-board.
var gUseNumReadableMessagesForMsgCount = false;
// 2nd command-line argument: Determine whether or not to execute the message listing // 2nd command-line argument: Determine whether or not to execute the message listing
// code (true/false) // code (true/false)
var executeThisScript = true; var executeThisScript = true;
...@@ -1070,18 +1068,8 @@ function DDMsgAreaChooser_CreateLightbarSubBoardMenu(pLevel, pGrpIdx, pSubIdx) ...@@ -1070,18 +1068,8 @@ function DDMsgAreaChooser_CreateLightbarSubBoardMenu(pLevel, pGrpIdx, pSubIdx)
{ {
// There is no sub-subboard list, so this is just a regular sub-board. // There is no sub-subboard list, so this is just a regular sub-board.
// Get the number of readable messages in the sub-board. // Get the number of readable messages in the sub-board.
// TODO: This can take a long time
if (gUseNumReadableMessagesForMsgCount)
{
numItems = numReadableMsgs(msgBase, this.areaChooser.group_list[this.grpIdx].sub_list[pSubIdx].code); numItems = numReadableMsgs(msgBase, this.areaChooser.group_list[this.grpIdx].sub_list[pSubIdx].code);
} }
// Fast but could be inaccurate due to counting deleted messages,
// vote responses, etc..
else
{
numItems = msgBase.total_msgs;
}
}
msgBase.close(); msgBase.close();
} }
...@@ -1634,10 +1622,7 @@ function DDMsgAreaChooser_ListSubBoardsInMsgGroup_Traditional(pGrpIndex, pSubIdx ...@@ -1634,10 +1622,7 @@ function DDMsgAreaChooser_ListSubBoardsInMsgGroup_Traditional(pGrpIndex, pSubIdx
subBoardInfo.description = msg_area.grp_list[grpIndex].sub_list[subIdx].description; subBoardInfo.description = msg_area.grp_list[grpIndex].sub_list[subIdx].description;
} }
if (gUseNumReadableMessagesForMsgCount)
subBoardInfo.numPosts = numReadableMsgs(msgBase, msg_area.grp_list[grpIndex].sub_list[subIdx].code); subBoardInfo.numPosts = numReadableMsgs(msgBase, msg_area.grp_list[grpIndex].sub_list[subIdx].code);
else
subBoardInfo.numPosts = msgBase.total_msgs;
// Get the date & time when the last message was imported. // Get the date & time when the last message was imported.
if (this.showDatesInSubBoardList && (subBoardInfo.numPosts > 0)) if (this.showDatesInSubBoardList && (subBoardInfo.numPosts > 0))
...@@ -1931,11 +1916,7 @@ function DDMsgAreaChooser_GetSubBoardInfo(pGrpIdx, pSubIdx, pSubSubIdx) ...@@ -1931,11 +1916,7 @@ function DDMsgAreaChooser_GetSubBoardInfo(pGrpIdx, pSubIdx, pSubSubIdx)
retObj.subCode = msg_area.grp_list[pGrpIdx].sub_list[pSubIdx].code; retObj.subCode = msg_area.grp_list[pGrpIdx].sub_list[pSubIdx].code;
// Get the number of messages in the sub-board // Get the number of messages in the sub-board
var numMsgs = 0; var numMsgs = numReadableMsgs(msgBase, msg_area.grp_list[pGrpIdx].sub_list[pSubIdx].code);
if (gUseNumReadableMessagesForMsgCount)
numMsgs = numReadableMsgs(msgBase, msg_area.grp_list[pGrpIdx].sub_list[pSubIdx].code);
else
numMsgs = getNumMsgsInSubBoard(msg_area.grp_list[pGrpIdx].sub_list[pSubIdx].code);
if (numMsgs > 0) if (numMsgs > 0)
{ {
retObj.numItems = numMsgs; retObj.numItems = numMsgs;
...@@ -2018,11 +1999,7 @@ function DDMsgAreaChooser_GetMsgSubBrdLine(pGrpIndex, pSubIndex, pHighlight) ...@@ -2018,11 +1999,7 @@ function DDMsgAreaChooser_GetMsgSubBrdLine(pGrpIndex, pSubIndex, pHighlight)
var msgBase = new MsgBase(msg_area.grp_list[pGrpIndex].sub_list[pSubIndex].code); var msgBase = new MsgBase(msg_area.grp_list[pGrpIndex].sub_list[pSubIndex].code);
if (msgBase.open()) if (msgBase.open())
{ {
var numMsgs = 0; var numMsgs = numReadableMsgs(msgBase, msg_area.grp_list[pGrpIndex].sub_list[pSubIndex].code);
if (gUseNumReadableMessagesForMsgCount)
numMsgs = numReadableMsgs(msgBase, msg_area.grp_list[pGrpIndex].sub_list[pSubIndex].code);
else
numMsgs = msgBase.total_msgs;
var newestDate = {}; // For storing the date of the newest post var newestDate = {}; // For storing the date of the newest post
// Get the date & time when the last message was imported. // Get the date & time when the last message was imported.
var msgHeader = getLatestMsgHdr(msg_area.grp_list[pGrpIndex].sub_list[pSubIndex].code); var msgHeader = getLatestMsgHdr(msg_area.grp_list[pGrpIndex].sub_list[pSubIndex].code);
...@@ -2601,11 +2578,7 @@ function getGreatestNumMsgs(pGrpIndex) ...@@ -2601,11 +2578,7 @@ function getGreatestNumMsgs(pGrpIndex)
if (msgBase == null) continue; if (msgBase == null) continue;
if (msgBase.open()) if (msgBase.open())
{ {
var numMsgs = 0; var numMsgs = numReadableMsgs(msgBase, msg_area.grp_list[pGrpIndex].sub_list[subIndex].code);
if (gUseNumReadableMessagesForMsgCount)
numMsgs = numReadableMsgs(msgBase, msg_area.grp_list[pGrpIndex].sub_list[subIndex].code);
else
numMsgs = msgBase.total_msgs;
if (numMsgs > greatestNumMsgs) if (numMsgs > greatestNumMsgs)
greatestNumMsgs = numMsgs; greatestNumMsgs = numMsgs;
msgBase.close(); msgBase.close();
...@@ -2943,6 +2916,20 @@ function isReadableMsgHdr(pMsgHdr, pSubBoardCode) ...@@ -2943,6 +2916,20 @@ function isReadableMsgHdr(pMsgHdr, pSubBoardCode)
// Return value: The number of readable messages in the sub-board // Return value: The number of readable messages in the sub-board
function numReadableMsgs(pMsgbase, pSubBoardCode) function numReadableMsgs(pMsgbase, pSubBoardCode)
{ {
// The posts property in msg_area.sub[sub_code] and msg_area.grp_list.sub_list is the number
// of posts excluding vote posts
if (typeof(msg_area.sub[pSubBoardCode].posts) === "number")
return msg_area.sub[pSubBoardCode].posts;
else if ((pMsgbase !== null) && pMsgbase.is_open)
{
// Just return the total number of messages.. This isn't accurate, but it's fast.
return pMsgbase.total_msgs;
}
else
return 0;
// Older code, used before Synchronet 3.18c when the 'posts' property was added - This is slow:
/*
if ((pMsgbase === null) || !pMsgbase.is_open) if ((pMsgbase === null) || !pMsgbase.is_open)
return 0; return 0;
...@@ -2971,6 +2958,7 @@ function numReadableMsgs(pMsgbase, pSubBoardCode) ...@@ -2971,6 +2958,7 @@ function numReadableMsgs(pMsgbase, pSubBoardCode)
} }
} }
return numMsgs; return numMsgs;
*/
} }
// Returns whether a given name matches the logged-in user's handle, alias, or // Returns whether a given name matches the logged-in user's handle, alias, or
...@@ -3303,10 +3291,7 @@ function getLatestMsgTime(pSubCode) ...@@ -3303,10 +3291,7 @@ function getLatestMsgTime(pSubCode)
var msgBase = new MsgBase(pSubCode); var msgBase = new MsgBase(pSubCode);
if (msgBase.open()) if (msgBase.open())
{ {
if (gUseNumReadableMessagesForMsgCount)
numMsgs = numReadableMsgs(msgBase, pSubCode); numMsgs = numReadableMsgs(msgBase, pSubCode);
else
numMsgs = msgBase.total_msgs;
msgBase.close(); msgBase.close();
} }
delete msgBase; // Free some memory? delete msgBase; // Free some memory?
......
Digital Distortion Area Choosers Digital Distortion Area Choosers
Version 1.30 Version 1.31/1.30
Release date: 2022-08-19 Release date: 2022-11-04
by by
......
...@@ -5,6 +5,11 @@ Revision History (change log) ...@@ -5,6 +5,11 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
1.31 2022-11-04 Message area chooser only: Made use of the 'posts'
property in msg_area.sub[sub-code] (or
msg_area.grp_list.sub_list) for the number of posts
without votes, if that property exists (it was added
in Synchronet 3.18c)
1.30 2022-08-19 Made use of the control key passthru setting so that 1.30 2022-08-19 Made use of the control key passthru setting so that
certain hotkeys (such as Ctrl-P, for Pageup) are only certain hotkeys (such as Ctrl-P, for Pageup) are only
caught by the scripts and not passed thru to the BBS. caught by the scripts and not passed thru to the BBS.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment