fix wikipedia widget first loading

This commit is contained in:
Evgeny
2021-11-21 16:23:21 +03:00
parent ce6cbed2bb
commit 6a6993aeab

View File

@@ -28,7 +28,7 @@ function on_network_result_summary(result)
local parsed = json.decode(result) local parsed = json.decode(result)
local extract = get_extract(parsed) local extract = get_extract(parsed)
ui:show_lines({ extract:smart_sub(200) }, { title }) ui:show_lines({ smart_sub(extract, 200) }, { title })
end end
function on_click() function on_click()
@@ -37,13 +37,13 @@ end
-- utils -- -- utils --
function string:smart_sub(max) function smart_sub(string, max)
local pos1, pos2 = self:find("%.", max-50) local pos1, pos2 = string:find("%.", max-50)
if pos1 ~= nil and pos1 < max+50 then if pos1 ~= nil and pos1 < max+50 then
return self:sub(1, pos1+1) return string:sub(1, pos1+1)
else else
return self:sub(1, max) return string:sub(1, max)
end end
end end