Content store: Fix bugs relating to packages list size
parent
a5197eaebc
commit
f12d374956
|
@ -285,7 +285,7 @@ function store.load()
|
||||||
|
|
||||||
local file = io.open(target, "r")
|
local file = io.open(target, "r")
|
||||||
if file then
|
if file then
|
||||||
store.packages_full = core.parse_json(file:read("*all"))
|
store.packages_full = core.parse_json(file:read("*all")) or {}
|
||||||
file:close()
|
file:close()
|
||||||
|
|
||||||
for _, package in pairs(store.packages_full) do
|
for _, package in pairs(store.packages_full) do
|
||||||
|
@ -385,7 +385,7 @@ function store.get_formspec()
|
||||||
end
|
end
|
||||||
|
|
||||||
local formspec
|
local formspec
|
||||||
if #store.packages > 0 then
|
if #store.packages_full > 0 then
|
||||||
formspec = {
|
formspec = {
|
||||||
"size[12,7;true]",
|
"size[12,7;true]",
|
||||||
"position[0.5,0.55]",
|
"position[0.5,0.55]",
|
||||||
|
@ -426,6 +426,12 @@ function store.get_formspec()
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if #store.packages == 0 then
|
||||||
|
formspec[#formspec + 1] = "label[4,3;"
|
||||||
|
formspec[#formspec + 1] = fgettext("No results")
|
||||||
|
formspec[#formspec + 1] = "]"
|
||||||
|
end
|
||||||
|
|
||||||
local start_idx = (cur_page - 1) * num_per_page + 1
|
local start_idx = (cur_page - 1) * num_per_page + 1
|
||||||
for i=start_idx, math.min(#store.packages, start_idx+num_per_page-1) do
|
for i=start_idx, math.min(#store.packages, start_idx+num_per_page-1) do
|
||||||
local package = store.packages[i]
|
local package = store.packages[i]
|
||||||
|
@ -570,7 +576,7 @@ function store.handle_submit(this, fields, tabname, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
function create_store_dlg(type)
|
function create_store_dlg(type)
|
||||||
if not store.loaded then
|
if not store.loaded or #store.packages_full == 0 then
|
||||||
store.load()
|
store.load()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue