From 69c5653a4c7144a9c7dcc6da2574b331a23ec111 Mon Sep 17 00:00:00 2001 From: Ksaper Date: Sat, 25 Feb 2023 03:46:24 +0200 Subject: [PATCH] Add a proper refresh method --- widget/app_launcher/init.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/widget/app_launcher/init.lua b/widget/app_launcher/init.lua index 2a16c70..89c7488 100644 --- a/widget/app_launcher/init.lua +++ b/widget/app_launcher/init.lua @@ -463,8 +463,20 @@ end function app_launcher:set_favorites(favorites) self.favorites = favorites self:sort_apps() - self:search() -- Refresh the app list - -- self:search() -- Refresh the app list + self:refresh() +end + +function app_launcher:refresh() + local max_app_index_to_include = self._private.apps_per_page * self._private.current_page + local min_app_index_to_include = max_app_index_to_include - self._private.apps_per_page + + self:get_grid():reset() + for index, app in ipairs(self._private.matched_apps) do + -- Only add widgets that are between this range (part of the current page) + if index > min_app_index_to_include and index <= max_app_index_to_include then + self:get_grid():add(app_widget(self, app)) + end + end end function app_launcher:search()