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

Merge branch 'dd_msg_reader_new_user_scan_ptr_fix' into 'master'

DDMsgReader: Updates to fix new user newscan, depending on the scan_ptr value

See merge request !452
parents e5eca8bc c1fc337f
No related branches found
No related tags found
2 merge requests!455Update branch with changes from master,!452DDMsgReader: Updates to fix new user newscan, depending on the scan_ptr value
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* Author: Eric Oulashin (AKA Nightfox) * Author: Eric Oulashin (AKA Nightfox)
* BBS: Digital Distortion * BBS: Digital Distortion
* BBS address: digitaldistortionbbs.com (or digdist.bbsindex.com) * BBS address: digitaldistortionbbs.com (or digdist.synchro.net)
* *
* Date Author Description * Date Author Description
* 2014-09-13 Eric Oulashin Started (based on my message lister script) * 2014-09-13 Eric Oulashin Started (based on my message lister script)
...@@ -159,6 +159,8 @@ ...@@ -159,6 +159,8 @@
* 2024-08-09 Eric Oulashin Version 1.95f * 2024-08-09 Eric Oulashin Version 1.95f
* New config option: msgSaveDir, which specifies the directory on the BBS PC * New config option: msgSaveDir, which specifies the directory on the BBS PC
* to save messages to. Can be empty, to use a full path inputted by the user. * to save messages to. Can be empty, to use a full path inputted by the user.
* 2024-08-12 Eric Oulashin Version 1.95g
* Updates to help with the newscan issues placing the user at the first message, etc.
*/ */
   
"use strict"; "use strict";
...@@ -274,8 +276,8 @@ var hexdump = load('hexdump_lib.js'); ...@@ -274,8 +276,8 @@ var hexdump = load('hexdump_lib.js');
*/ */
   
// Reader version information // Reader version information
var READER_VERSION = "1.95f"; var READER_VERSION = "1.95g";
var READER_DATE = "2024-08-09"; var READER_DATE = "2024-08-12";
   
// Keyboard key codes for displaying on the screen // Keyboard key codes for displaying on the screen
var UP_ARROW = ascii(24); var UP_ARROW = ascii(24);
...@@ -2660,6 +2662,7 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar ...@@ -2660,6 +2662,7 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar
   
var grpIndex = msg_area.sub[this.subBoardCode].grp_index; var grpIndex = msg_area.sub[this.subBoardCode].grp_index;
var subIndex = msg_area.sub[this.subBoardCode].index; var subIndex = msg_area.sub[this.subBoardCode].index;
var scanPtrMsgIdx = this.GetScanPtrMsgIdx();
// Sub-board description: msg_area.grp_list[grpIndex].sub_list[subIndex].description // Sub-board description: msg_area.grp_list[grpIndex].sub_list[subIndex].description
// Open the sub-board and check for unread messages. If there are any, then let // Open the sub-board and check for unread messages. If there are any, then let
// the user read the messages in the sub-board. // the user read the messages in the sub-board.
...@@ -2702,7 +2705,7 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar ...@@ -2702,7 +2705,7 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar
} }
*/ */
   
var scanPtrMsgIdx = this.GetScanPtrMsgIdx(); //var scanPtrMsgIdx = this.GetScanPtrMsgIdx();
// In the switch cases below, bbs.curgrp and bbs.cursub are // In the switch cases below, bbs.curgrp and bbs.cursub are
// temporarily changed the user's sub-board to the current // temporarily changed the user's sub-board to the current
// sub-board so that certain @-codes (such as @GRP-L@, etc.) // sub-board so that certain @-codes (such as @GRP-L@, etc.)
...@@ -2713,6 +2716,9 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar ...@@ -2713,6 +2716,9 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar
switch (pScanMode) switch (pScanMode)
{ {
case SCAN_NEW: case SCAN_NEW:
if (scanPtrMsgIdx < 0)
continue;
var totalNumMsgs = msgbase.total_msgs; var totalNumMsgs = msgbase.total_msgs;
   
// Temporary (debugging newscan for new user) // Temporary (debugging newscan for new user)
...@@ -2880,7 +2886,7 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar ...@@ -2880,7 +2886,7 @@ function DigDistMsgReader_MessageAreaScan(pScanCfgOpt, pScanMode, pScanScopeChar
msgbase.close(); msgbase.close();
} }
} }
// Briefly wait, to prevent the CPU from reaching 99% usage // Briefly wait, to prevent the CPU from reaching 99% usage or more
mswait(10); mswait(10);
} }
this.doingMultiSubBoardScan = false; this.doingMultiSubBoardScan = false;
...@@ -3053,8 +3059,12 @@ function DigDistMsgReader_ReadMessages(pSubBoardCode, pStartingMsgOffset, pRetur ...@@ -3053,8 +3059,12 @@ function DigDistMsgReader_ReadMessages(pSubBoardCode, pStartingMsgOffset, pRetur
else else
{ {
msgIndex = this.GetLastReadMsgIdxAndNum().lastReadMsgIdx; msgIndex = this.GetLastReadMsgIdxAndNum().lastReadMsgIdx;
if (msgIndex == -1)
{
msgIndex = this.NumMessages() - 1;
if (msgIndex == -1) if (msgIndex == -1)
msgIndex = 0; msgIndex = 0;
}
else if (msgIndex >= numOfMessages) else if (msgIndex >= numOfMessages)
msgIndex = numOfMessages - 1; msgIndex = numOfMessages - 1;
} }
...@@ -14602,6 +14612,24 @@ function DigDistMsgReader_GetLastReadMsgIdxAndNum(pMailStartFromFirst) ...@@ -14602,6 +14612,24 @@ function DigDistMsgReader_GetLastReadMsgIdxAndNum(pMailStartFromFirst)
} }
} }
else else
{
// If the user's scan_ptr is the special value indicating it should be the last message,
// then set it up that way, and return the index of the last message in the current sub-board
if (subBoardScanPtrIsLatestMsgSpecialVal(this.subBoardCode))
{
var lasgReadableMsgHdr = getLastReadableMsgHdrInSubBoard(this.subBoardCode);
if (lasgReadableMsgHdr != null)
{
if (this.GetMsgIdx(lasgReadableMsgHdr) > -1)
{
msg_area.sub[this.subBoardCode].scan_ptr = lasgReadableMsgHdr.number;
msg_area.sub[this.subBoardCode].last_read = lasgReadableMsgHdr.number;
retObj.lastReadMsgIdx = this.NumMessages() - 1;
retObj.lastReadMsgNum = lasgReadableMsgHdr.number;
}
}
}
else
{ {
//retObj.lastReadMsgIdx = this.AbsMsgNumToIdx(msg_area.sub[this.subBoardCode].last_read); //retObj.lastReadMsgIdx = this.AbsMsgNumToIdx(msg_area.sub[this.subBoardCode].last_read);
retObj.lastReadMsgIdx = this.GetMsgIdx(msg_area.sub[this.subBoardCode].last_read); retObj.lastReadMsgIdx = this.GetMsgIdx(msg_area.sub[this.subBoardCode].last_read);
...@@ -14654,6 +14682,7 @@ function DigDistMsgReader_GetLastReadMsgIdxAndNum(pMailStartFromFirst) ...@@ -14654,6 +14682,7 @@ function DigDistMsgReader_GetLastReadMsgIdxAndNum(pMailStartFromFirst)
} }
} }
} }
}
return retObj; return retObj;
} }
   
...@@ -14668,6 +14697,8 @@ function DigDistMsgReader_GetScanPtrMsgIdx() ...@@ -14668,6 +14697,8 @@ function DigDistMsgReader_GetScanPtrMsgIdx()
return 0; return 0;
if (msg_area.sub[this.subBoardCode].scan_ptr == 0) if (msg_area.sub[this.subBoardCode].scan_ptr == 0)
return -1; return -1;
if (msg_area.sub[this.subBoardCode].posts == 0)
return -1;
   
/* /*
// Temporary (debugging newscan for new user) // Temporary (debugging newscan for new user)
...@@ -14676,22 +14707,44 @@ function DigDistMsgReader_GetScanPtrMsgIdx() ...@@ -14676,22 +14707,44 @@ function DigDistMsgReader_GetScanPtrMsgIdx()
// End Temporary // End Temporary
*/ */
// If the user's scan pointer is a crazy value, that could be because //printf("%s - Scan tr is last msg special value: %s\r\n", subDesc, subBoardScanPtrIsLatestMsgSpecialVal(this.subBoardCode) ? "true" : "false"); // Temporary
// the user hasn't read messages in the sub-board yet. In that case,
// just use 0. Otherwise, get the user's scan pointer message index. // If the user's scan pointer is the special value that their scan pointer should be
// on the last message, then set it that way (the user might be a new user).
// Otherwise, get the user's scan pointer message index.
var msgIdx = 0; var msgIdx = 0;
// If the user's scan_ptr for the sub-board isn't the 'last message' if (subBoardScanPtrIsLatestMsgSpecialVal(this.subBoardCode))
// special value, then use it {
if (!subBoardScanPtrIsLatestMsgSpecialVal(this.subBoardCode)) var lasgReadableMsgHdr = getLastReadableMsgHdrInSubBoard(this.subBoardCode);
if (lasgReadableMsgHdr != null)
{
msgIdx = this.GetMsgIdx(lasgReadableMsgHdr);
// There shouldn't be any need to set scan_ptr or last_read:
/*
if (msgIdx > -1)
{
//msg_area.sub[this.subBoardCode].scan_ptr = lasgReadableMsgHdr.number;
//msg_area.sub[this.subBoardCode].last_read = lasgReadableMsgHdr.number;
//printf("- %s Here 1; scan_ptr: %d; msgIdx: %d\r\n\x01p", subDesc, msg_area.sub[this.subBoardCode].scan_ptr, msgIdx); // Temporary (debugging newscan for new user)
}
//else
// return -1;
*/
}
else
return -1;
}
else
{ {
msgIdx = this.GetMsgIdx(msg_area.sub[this.subBoardCode].scan_ptr); msgIdx = this.GetMsgIdx(msg_area.sub[this.subBoardCode].scan_ptr);
//console.print("- " + subDesc + " Here 1; scan_ptr: " + msg_area.sub[this.subBoardCode].scan_ptr + "; msgIdx: " + msgIdx + "\r\n\x01p"); // Temporary //printf("- %s Here 2; scan_ptr: %d; msgIdx: %d\r\n\x01p", subDesc, msg_area.sub[this.subBoardCode].scan_ptr, msgIdx); // Temporary (debugging newscan for new user)
} }
// Sanity checking for msgIdx // Sanity checking for msgIdx
var msgbase = new MsgBase(this.subBoardCode); var msgbase = new MsgBase(this.subBoardCode);
if (msgbase.open()) if (msgbase.open())
{ {
if ((msgIdx < 0) || (msgIdx >= msgbase.total_msgs) || subBoardScanPtrIsLatestMsgSpecialVal(this.subBoardCode)) //if ((msgIdx < 0) || (msgIdx >= msgbase.total_msgs) || subBoardScanPtrIsLatestMsgSpecialVal(this.subBoardCode))
if ((msgIdx < 0) || (msgIdx >= msgbase.total_msgs))
{ {
msgIdx = -1; msgIdx = -1;
// Look for the first message not marked as deleted // Look for the first message not marked as deleted
...@@ -14700,21 +14753,21 @@ function DigDistMsgReader_GetScanPtrMsgIdx() ...@@ -14700,21 +14753,21 @@ function DigDistMsgReader_GetScanPtrMsgIdx()
if (readableMsgIdx > -1) if (readableMsgIdx > -1)
{ {
var newLastRead = this.IdxToAbsMsgNum(readableMsgIdx); var newLastRead = this.IdxToAbsMsgNum(readableMsgIdx);
//console.print("- " + subDesc + " Here 2. newLastRead: " + newLastRead + "\r\n\x01p"); // Temporary //console.print("- " + subDesc + " Here 3. newLastRead: " + newLastRead + "\r\n\x01p"); // Temporary (debugging newscan for new user)
if (newLastRead > -1) if (newLastRead > -1)
{ {
//console.print("- " + subDesc + " Here 3\r\n\x01p"); // Temporary //console.print("- " + subDesc + " Here 4\r\n\x01p"); // Temporary (debugging newscan for new user)
msg_area.sub[this.subBoardCode].scan_ptr = newLastRead; msg_area.sub[this.subBoardCode].scan_ptr = newLastRead;
} }
else else
{ {
//console.print("- " + subDesc + " Here 4\r\n\x01p"); // Temporary //console.print("- " + subDesc + " Here 5\r\n\x01p"); // Temporary (debugging newscan for new user)
msg_area.sub[this.subBoardCode].scan_ptr = 0; msg_area.sub[this.subBoardCode].scan_ptr = 0;
} }
} }
else else
{ {
//console.print("- " + subDesc + " Here 5\r\n\x01p"); // Temporary //console.print("- " + subDesc + " Here 6\r\n\x01p"); // Temporary (debugging newscan for new user)
msg_area.sub[this.subBoardCode].scan_ptr = 0; msg_area.sub[this.subBoardCode].scan_ptr = 0;
} }
} }
...@@ -16755,11 +16808,11 @@ function getLatestPostTimestampAndNumNewMsgs(pSubCode, pMsgbase) ...@@ -16755,11 +16808,11 @@ function getLatestPostTimestampAndNumNewMsgs(pSubCode, pMsgbase)
// scan_ptr: user's current new message scan pointer (highest-read message number) // scan_ptr: user's current new message scan pointer (highest-read message number)
if (typeof(msg_area.sub[pSubCode].scan_ptr) === "number") if (typeof(msg_area.sub[pSubCode].scan_ptr) === "number")
{ {
// If the user's scan pointer for the sub-board is the special value indicating it isn't valid yet, // If the user's scan pointer for the sub-board is the special value indicating that the user's
// then the user is probably a new user who hasn't visited this sub-board before, so the number of // scan pointer thould be the last message, then the number of new messages should be 0 (they're
// new messages should be the total number of posts. // probably a new user).
if (msgNumIsLatestMsgSpecialVal(msg_area.sub[pSubCode].scan_ptr)) if (msgNumIsLatestMsgSpecialVal(msg_area.sub[pSubCode].scan_ptr))
retObj.numNewMsgs = msg_area.sub[pSubCode].posts; retObj.numNewMsgs = 0;
else else
{ {
var lastReadableMsgHdr = getLastReadableMsgHdrInSubBoard(pSubCode); var lastReadableMsgHdr = getLastReadableMsgHdrInSubBoard(pSubCode);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// If you have DDMsgReader in a directory other than xtrn/DDMsgReader, then the changes to // If you have DDMsgReader in a directory other than xtrn/DDMsgReader, then the changes to
// DDMsgReader.cfg will be saved in that directory (assuming you're running ddmr_cfg.js from // DDMsgReader.cfg will be saved in that directory (assuming you're running ddmr_cfg.js from
// that same directory). // that same directory).
// Currently for DDMsgReader 1.95f. // Currently for DDMsgReader 1.95g.
// //
// If you're running DDMsgReader from xtrn/DDMsgReader (the standard location) and you want // If you're running DDMsgReader from xtrn/DDMsgReader (the standard location) and you want
// to save the configuration file there (rather than sbbs/mods), you can use one of the // to save the configuration file there (rather than sbbs/mods), you can use one of the
...@@ -18,7 +18,7 @@ require("sbbsdefs.js", "P_NONE"); ...@@ -18,7 +18,7 @@ require("sbbsdefs.js", "P_NONE");
require("uifcdefs.js", "UIFC_INMSG"); require("uifcdefs.js", "UIFC_INMSG");
if (!uifc.init("DigDist. Message Reader 1.95f Configurator")) if (!uifc.init("DigDist. Message Reader 1.95g Configurator"))
{ {
print("Failed to initialize uifc"); print("Failed to initialize uifc");
exit(1); exit(1);
......
Digital Distortion Message Reader Digital Distortion Message Reader
Version 1.95f Version 1.95g
Release date: 2024-08-08 Release date: 2024-08-12
by by
......
...@@ -5,6 +5,8 @@ Revision History (change log) ...@@ -5,6 +5,8 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
1.95g 2024-08-12 Updates to help with the newscan issues placing the user
at the first message, etc.
1.95f 2024-08-08 New config option: msgSaveDir, which specifies the 1.95f 2024-08-08 New config option: msgSaveDir, which specifies the
directory on the BBS PC to save messages to. Can be empty, directory on the BBS PC to save messages to. Can be empty,
to use a full path inputted by the user. to use a full path inputted by the user.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment