From 18d4c7550a79068aea1ea2be2da0ddfc394766ba Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 8 Sep 2014 02:33:26 -0400 Subject: [PATCH] chore: cleanup FileManagerHistory:updateItemTable() --- .../apps/filemanager/filemanagerhistory.lua | 44 +++++++------------ 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/frontend/apps/filemanager/filemanagerhistory.lua b/frontend/apps/filemanager/filemanagerhistory.lua index 410807782..a79999f66 100644 --- a/frontend/apps/filemanager/filemanagerhistory.lua +++ b/frontend/apps/filemanager/filemanagerhistory.lua @@ -79,39 +79,25 @@ function FileManagerHistory:addToMainMenu(tab_item_table) end function FileManagerHistory:updateItemTable() - function readHistDir(re) - local sorted_files = {} - for f in lfs.dir(history_dir) do - local path = history_dir..f - if lfs.attributes(path, "mode") == "file" then - table.insert(sorted_files, { - file = f, - date = lfs.attributes(path, "modification") - }) - end - end - table.sort(sorted_files, function(v1,v2) return v1.date > v2.date end) - for _, v in pairs(sorted_files) do - table.insert(re, { - dir = DocSettings:getPathFromHistory(v.file), - name = DocSettings:getNameFromHistory(v.file), - histfile = v.file, + self.hist = {} + + for f in lfs.dir(history_dir) do + local path = history_dir..f + if lfs.attributes(path, "mode") == "file" then + local name = DocSettings:getNameFromHistory(f) + table.insert(self.hist, { + date = lfs.attributes(path, "modification"), + text = name, + histfile = f, + callback = function() + ReaderUI:showReader( + DocSettings:getPathFromHistory(f).. "/" .. name) + end }) end end + table.sort(self.hist, function(v1, v2) return v1.date > v2.date end) - self.hist = {} - local last_files = {} - readHistDir(last_files) - for _,v in pairs(last_files) do - table.insert(self.hist, { - text = v.name, - histfile = v.histfile, - callback = function() - ReaderUI:showReader(v.dir .. "/" .. v.name) - end - }) - end self.hist_menu:swithItemTable(self.hist_menu_title, self.hist) end