From 6a6993aeab43955126ca0c53608c7ba98f08c662 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 21 Nov 2021 16:23:21 +0300 Subject: [PATCH] fix wikipedia widget first loading --- main/wikipedia-widget.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/wikipedia-widget.lua b/main/wikipedia-widget.lua index 672874d..4a6df50 100644 --- a/main/wikipedia-widget.lua +++ b/main/wikipedia-widget.lua @@ -28,7 +28,7 @@ function on_network_result_summary(result) local parsed = json.decode(result) local extract = get_extract(parsed) - ui:show_lines({ extract:smart_sub(200) }, { title }) + ui:show_lines({ smart_sub(extract, 200) }, { title }) end function on_click() @@ -37,13 +37,13 @@ end -- utils -- -function string:smart_sub(max) - local pos1, pos2 = self:find("%.", max-50) +function smart_sub(string, max) + local pos1, pos2 = string:find("%.", max-50) if pos1 ~= nil and pos1 < max+50 then - return self:sub(1, pos1+1) + return string:sub(1, pos1+1) else - return self:sub(1, max) + return string:sub(1, max) end end