From 7db1168c143719969bbedac24387cce8c6b74e5b Mon Sep 17 00:00:00 2001
From: nightfox <>
Date: Wed, 15 May 2013 03:43:12 +0000
Subject: [PATCH] Version 1.25: Now using bbs.msg_number (absolute) rather than
 bbs.smb_curmsg (index) to retrieve a message header for the purpose of
 getting the author's initials when quoting a message.  bbs.msg_number is
 always correct when replying to messages in all situations (such as the Read
 Message prompt, scanning for new messages, and scanning for new messages to
 you).

If you use Digital Distortion message Lister, this version of SlyEdit requires version 1.34 of Digital Distortion Message Lister, which was updated to provide the correct message number to this verison of SlyEdit.
---
 exec/SlyEdit.js      | 17 +++++++++++++++--
 exec/SlyEdit_Misc.js | 21 +++++++++++++++++----
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/exec/SlyEdit.js b/exec/SlyEdit.js
index 8f3c8a8976..496a7f35ec 100644
--- a/exec/SlyEdit.js
+++ b/exec/SlyEdit.js
@@ -108,6 +108,19 @@
  *                              currently set for reading.
  *                              Also, defaulted the option for indenting quote
  *                              lines with initials to true.
+ * 2013-05-10 Eric Oulashin     Version 1.25 beta
+ *                              Started working on more reliably getting the
+ *                              message headers to correctly get author
+ *                              initials in all cases when replying to messages.
+ * 2013-05-14 Eric OUlashin     Version 1.25
+ *                              Updated to use bbs.msg_number instead of message
+ *                              indexes so that the correct message header (for
+ *                              retrieval of author initials) is correct in all
+ *                              cases, including when replying to messages during
+ *                              "Scan for messages to you":
+ *                              In SlyEdit_Misc.js, updated getCurMsgInfo() and
+ *                              getFromNameForCurMsg() to use the absolute message
+ *                              number (bbs.msg_number) rather than messages indexes.
  */
 
 /* Command-line arguments:
@@ -180,8 +193,8 @@ if (!console.term_supports(USER_ANSI))
 }
 
 // Constants
-const EDITOR_VERSION = "1.24";
-const EDITOR_VER_DATE = "2013-02-17";
+const EDITOR_VERSION = "1.25";
+const EDITOR_VER_DATE = "2013-05-14";
 
 
 // Program variables
diff --git a/exec/SlyEdit_Misc.js b/exec/SlyEdit_Misc.js
index 6b9eeaa7ca..544dec6f4f 100644
--- a/exec/SlyEdit_Misc.js
+++ b/exec/SlyEdit_Misc.js
@@ -80,6 +80,12 @@
  *                              current sub-board (i.e., a new user is applying
  *                              for access).  Also, updated ReadSlyEditConfigFile()
  *                              to default indentQuoteLinesWithInitials to true.
+ * 2013-05-14 Eric Oulashin     Updated getCurMsgInfo() and getFromNameForCurMsg()
+ *                              to use the absolute message number (bbs.msg_number)
+ *                              rather than messages indexes so that it gets
+ *                              the correct message header in all cases, including
+ *                              when replying to messages during "Scan for messages
+ *                              to you".
  */
 
 // Note: These variables are declared with "var" instead of "const" to avoid
@@ -1933,7 +1939,7 @@ function wrapQuoteLines(pUseAuthorInitials, pIndentQuoteLinesWithInitials)
 // Returns an object containing the following properties:
 //  lastMsg: The last message in the sub-board (i.e., bbs.smb_last_msg)
 //  totalNumMsgs: The total number of messages in the sub-board (i.e., bbs.smb_total_msgs)
-//  curMsgNum: The number of the current message being read (i.e., bbs.smb_curmsg)
+//  curMsgNum: The absolute number of the current message being read (i.e., bbs.msg_number)
 //  subBoardCode: The current sub-board code (i.e., bbs.smb_sub_code)
 //  grpIndex: The message group index for the sub-board
 //
@@ -1941,7 +1947,7 @@ function wrapQuoteLines(pUseAuthorInitials, pIndentQuoteLinesWithInitials)
 // DDML_SyncSMBInfo.txt in the node directory (written by the Digital
 // Distortion Message Lister v1.31 and higher).  If that file can't be read,
 // the values will default to the values of bbs.smb_last_msg,
-// bbs.smb_total_msgs, and bbs.smb_curmsg.
+// bbs.smb_total_msgs, and bbs.msg_number.
 //
 // Parameters:
 //  pMsgAreaName: The name of the message area being posted to
@@ -1952,7 +1958,8 @@ function getCurMsgInfo(pMsgAreaName)
   {
     retObj.lastMsg = bbs.smb_last_msg;
     retObj.totalNumMsgs = bbs.smb_total_msgs;
-    retObj.curMsgNum = bbs.smb_curmsg;
+    //retObj.curMsgNum = bbs.smb_curmsg; // OLD!
+    retObj.curMsgNum = bbs.msg_number; // New (2013-05-14)
     retObj.subBoardCode = bbs.smb_sub_code;
     retObj.grpIndex = msg_area.sub[bbs.smb_sub_code].grp_index;
   }
@@ -1994,6 +2001,9 @@ function getCurMsgInfo(pMsgAreaName)
   // If pMsgAreaName is valid, then if it specifies a message area name that is
   // different from what's in retObj, then we probably want to use bbs.cursub_code
   // instead of bbs.smb_sub_code, etc.
+  // Note: As of the May 8, 2013 build of Synchronet (3.16), the bbs.smb_sub*
+  // properties reflect the current sub-board being posted to, always.
+  // Digital Man committed a change in CVS for this on May 7, 2013.
   if ((typeof(pMsgAreaName) == "string") && (pMsgAreaName.length > 0))
   {
     if (msg_area.sub[retObj.subBoardCode].name.indexOf(pMsgAreaName) == -1)
@@ -2114,7 +2124,10 @@ function getFromNameForCurMsg(pMsgInfo)
     if (msgBase != null)
     {
       msgBase.open();
-      var hdr = msgBase.get_msg_header(true, msgInfo.curMsgNum, true);
+      // First parameter is false because we're not passing the message
+      // number by offset, we're passing the absolute message number
+      // (i.e., from bbs.msg_number) rather than the message offset.
+      var hdr = msgBase.get_msg_header(false, msgInfo.curMsgNum, true);
       if (hdr != null)
         fromName = hdr.from;
       msgBase.close();
-- 
GitLab