@@ -185,16 +185,7 @@ local function get_screenshot(package)
185
185
if not success then
186
186
core .log (" warning" , " Screenshot download failed for some reason" )
187
187
end
188
-
189
- local ele = ui .childlist .store
190
- if ele and not ele .hidden then
191
- core .update_formspec (ele :formspec ())
192
- else
193
- ele = ui .childlist .package_view
194
- if ele and not ele .hidden then
195
- core .update_formspec (ele :formspec ())
196
- end
197
- end
188
+ ui .update ()
198
189
end
199
190
if core .handle_async (download_screenshot ,
200
191
{ dest = filepath , url = package .thumbnail }, callback ) then
@@ -245,7 +236,7 @@ function package_dialog.get_formspec()
245
236
return table.concat (formspec , " " )
246
237
end
247
238
248
- function package_dialog .handle_submit (this , fields , tabname , tabdata )
239
+ function package_dialog .handle_submit (this , fields )
249
240
if fields .back then
250
241
this :delete ()
251
242
return true
@@ -395,11 +386,11 @@ function store.filter_packages(query)
395
386
396
387
end
397
388
398
- function store .get_formspec ()
389
+ function store .get_formspec (dlgdata )
399
390
store .update_paths ()
400
391
401
- local pages = math.ceil (# store .packages / num_per_page )
402
- if cur_page > pages then
392
+ dlgdata . pagemax = math.max ( math. ceil (# store .packages / num_per_page ), 1 )
393
+ if cur_page > dlgdata . pagemax then
403
394
cur_page = 1
404
395
end
405
396
@@ -428,7 +419,7 @@ function store.get_formspec()
428
419
" button[8.1,0;1,1;pback;<]" ,
429
420
" label[9.2,0.2;" ,
430
421
tonumber (cur_page ), " / " ,
431
- tonumber (pages ), " ]" ,
422
+ tonumber (dlgdata . pagemax ), " ]" ,
432
423
" button[10.1,0;1,1;pnext;>]" ,
433
424
" button[11.1,0;1,1;pend;>>]" ,
434
425
" container_end[]" ,
@@ -515,12 +506,11 @@ function store.get_formspec()
515
506
return table.concat (formspec , " " )
516
507
end
517
508
518
- function store .handle_submit (this , fields , tabname , tabdata )
509
+ function store .handle_submit (this , fields )
519
510
if fields .search or fields .key_enter_field == " search_string" then
520
511
search_string = fields .search_string :trim ()
521
512
cur_page = 1
522
513
store .filter_packages (search_string )
523
- core .update_formspec (store .get_formspec ())
524
514
return true
525
515
end
526
516
@@ -531,34 +521,28 @@ function store.handle_submit(this, fields, tabname, tabdata)
531
521
532
522
if fields .pstart then
533
523
cur_page = 1
534
- core .update_formspec (store .get_formspec ())
535
524
return true
536
525
end
537
526
538
527
if fields .pend then
539
- cur_page = math.ceil (# store .packages / num_per_page )
540
- core .update_formspec (store .get_formspec ())
528
+ cur_page = this .data .pagemax
541
529
return true
542
530
end
543
531
544
532
if fields .pnext then
545
533
cur_page = cur_page + 1
546
- local pages = math.ceil (# store .packages / num_per_page )
547
- if cur_page > pages then
534
+ if cur_page > this .data .pagemax then
548
535
cur_page = 1
549
536
end
550
- core .update_formspec (store .get_formspec ())
551
537
return true
552
538
end
553
539
554
540
if fields .pback then
555
541
if cur_page == 1 then
556
- local pages = math.ceil (# store .packages / num_per_page )
557
- cur_page = pages
542
+ cur_page = this .data .pagemax
558
543
else
559
544
cur_page = cur_page - 1
560
545
end
561
- core .update_formspec (store .get_formspec ())
562
546
return true
563
547
end
564
548
0 commit comments