From 4d19ce24ed0cec66af6cd40acac06effed8e2244 Mon Sep 17 00:00:00 2001 From: Jo Van Bulck Date: Thu, 14 Mar 2024 16:58:47 +0100 Subject: [PATCH] Dictionary: Fix download message when connection fails (#11548) --- .../apps/reader/modules/readerdictionary.lua | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/frontend/apps/reader/modules/readerdictionary.lua b/frontend/apps/reader/modules/readerdictionary.lua index a48f9fa3d..edaea517b 100644 --- a/frontend/apps/reader/modules/readerdictionary.lua +++ b/frontend/apps/reader/modules/readerdictionary.lua @@ -1114,15 +1114,24 @@ function ReaderDictionary:downloadDictionary(dict, download_location, continue) --logger.dbg(headers) file_size = headers and headers["content-length"] - UIManager:show(ConfirmBox:new{ - text = T(_("Dictionary filesize is %1 (%2 bytes). Continue with download?"), util.getFriendlySize(file_size), util.getFormattedSize(file_size)), - ok_text = _("Download"), - ok_callback = function() - -- call ourselves with continue = true - self:downloadDictionary(dict, download_location, true) - end, - }) - return + if file_size then + UIManager:show(ConfirmBox:new{ + text = T(_("Dictionary filesize is %1 (%2 bytes). Continue with download?"), util.getFriendlySize(file_size), util.getFormattedSize(file_size)), + ok_text = _("Download"), + ok_callback = function() + -- call ourselves with continue = true + self:downloadDictionary(dict, download_location, true) + end, + }) + return + else + logger.dbg("ReaderDictionary: Request failed; response headers:", headers) + UIManager:show(InfoMessage:new{ + text = _("Failed to fetch dictionary. Are you online?"), + --timeout = 3, + }) + return false + end else UIManager:nextTick(function() UIManager:show(InfoMessage:new{