From 9bfc1a4ac1522fe275a41e7fbc219f41582a46bb Mon Sep 17 00:00:00 2001
From: Eric Oulashin <eric.oulashin@gmail.com>
Date: Sun, 13 Mar 2022 21:51:24 -0700
Subject: [PATCH] Fix for "fileDesc is not defined" error when displaying the
 file description on the main screen. ddfilelister version 2.05a: Fix for
 "fileDesc is not defined" error when displaying the file description on the
 main screen.  Also made a small refactor to the main screen refresh function.

---
 xtrn/ddfilelister/ddfilelister.js      | 22 +++++++++++++++++-----
 xtrn/ddfilelister/readme.txt           |  4 ++--
 xtrn/ddfilelister/revision_history.txt |  2 ++
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/xtrn/ddfilelister/ddfilelister.js b/xtrn/ddfilelister/ddfilelister.js
index c54a109bdd..edf9dc69ed 100644
--- a/xtrn/ddfilelister/ddfilelister.js
+++ b/xtrn/ddfilelister/ddfilelister.js
@@ -39,6 +39,10 @@
  *                              highlighted file on the right.  Also, made the file info
  *                              window taller for terminals within 25 lines high.
  *                              I had started work on this on March 9, 2022.
+ * 2022-03-13 Eric Oulashin     Version 2.05a
+ *                              Fix for "fileDesc is not defined" error when displaying
+ *                              the file description on the main screen.  Also made a
+ *                              small refactor to the main screen refresh function.
 */
 
 if (typeof(require) === "function")
@@ -94,8 +98,8 @@ if (system.version_num < 31900)
 }
 
 // Lister version information
-var LISTER_VERSION = "2.05";
-var LISTER_DATE = "2022-03-12";
+var LISTER_VERSION = "2.05a";
+var LISTER_DATE = "2022-03-13";
 
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -3604,6 +3608,8 @@ function displayFileExtDescOnMainScreen(pFileIdx, pStartScreenRow, pEndScreenRow
 		fileDesc = fileMetadata.extdesc;
 	else
 		fileDesc = fileMetadata.desc;
+	if (typeof(fileDesc) != "string")
+		fileDesc = "";
 
 	// This might be overkill, but just in case, convert any non-Synchronet
 	// attribute codes to Synchronet attribute codes in the description.
@@ -3691,9 +3697,15 @@ function displayFileExtDescOnMainScreen(pFileIdx, pStartScreenRow, pEndScreenRow
 //                      given top & bottom screen rows.
 function refreshScreenMainContent(pUpperLeftX, pUpperLeftY, pWidth, pHeight, pSelectedItemIdxes)
 {
-	var selectedItemIdxesIsValid = (typeof(pSelectedItemIdxes) === "object");
-	var selectedItemIdxes = (selectedItemIdxesIsValid ? pSelectedItemIdxes : {});
-	gFileListMenu.DrawPartialAbs(pUpperLeftX, pUpperLeftY, pWidth, pHeight, selectedItemIdxes);
+	// Have the file list menu partially re-draw itself if necessary
+	var startXWithinFileList = (pUpperLeftX >= gFileListMenu.pos.x && pUpperLeftX < gFileListMenu.pos.x + gFileListMenu.size.width);
+	var startYWithinFileList = (pUpperLeftY >= gFileListMenu.pos.y && pUpperLeftY < gFileListMenu.pos.y + gFileListMenu.size.height);
+	if (startXWithinFileList && startYWithinFileList)
+	{
+		var selectedItemIdxesIsValid = (typeof(pSelectedItemIdxes) === "object");
+		var selectedItemIdxes = (selectedItemIdxesIsValid ? pSelectedItemIdxes : {});
+		gFileListMenu.DrawPartialAbs(pUpperLeftX, pUpperLeftY, pWidth, pHeight, selectedItemIdxes);
+	}
 	// If pSelectedItemIdxes is a bool instead of an object and is true,
 	// refresh the selected items (with checkmarks) outside the top & bottom
 	// lines on the file menu
diff --git a/xtrn/ddfilelister/readme.txt b/xtrn/ddfilelister/readme.txt
index 37dfeb5338..1842252b21 100644
--- a/xtrn/ddfilelister/readme.txt
+++ b/xtrn/ddfilelister/readme.txt
@@ -1,6 +1,6 @@
                         Digital Distortion File Lister
-                                 Version 2.05
-                           Release date: 2022-03-12
+                                 Version 2.05a
+                           Release date: 2022-03-13
 
                                      by
 
diff --git a/xtrn/ddfilelister/revision_history.txt b/xtrn/ddfilelister/revision_history.txt
index f8c50f2d32..99fc0c0b7e 100644
--- a/xtrn/ddfilelister/revision_history.txt
+++ b/xtrn/ddfilelister/revision_history.txt
@@ -5,6 +5,8 @@ Revision History (change log)
 =============================
 Version  Date         Description
 -------  ----         -----------
+2.05a    2022-03-13   Fix for "fileDesc is not defined" error when displaying
+                      the file description on the main screen.
 2.05     2022-03-12   Now makes use of the user's extended file description
                       setting: If the user's extended file description setting
                       is enabled, the lister will now show extended file
-- 
GitLab