chore: cleanup FileManagerHistory:updateItemTable()

pull/880/head
Qingping Hou 10 years ago
parent 7c6790796a
commit 18d4c7550a

@ -79,39 +79,25 @@ function FileManagerHistory:addToMainMenu(tab_item_table)
end end
function FileManagerHistory:updateItemTable() function FileManagerHistory:updateItemTable()
function readHistDir(re) self.hist = {}
local sorted_files = {}
for f in lfs.dir(history_dir) do for f in lfs.dir(history_dir) do
local path = history_dir..f local path = history_dir..f
if lfs.attributes(path, "mode") == "file" then if lfs.attributes(path, "mode") == "file" then
table.insert(sorted_files, { local name = DocSettings:getNameFromHistory(f)
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,
})
end
end
self.hist = {}
local last_files = {}
readHistDir(last_files)
for _,v in pairs(last_files) do
table.insert(self.hist, { table.insert(self.hist, {
text = v.name, date = lfs.attributes(path, "modification"),
histfile = v.histfile, text = name,
histfile = f,
callback = function() callback = function()
ReaderUI:showReader(v.dir .. "/" .. v.name) ReaderUI:showReader(
DocSettings:getPathFromHistory(f).. "/" .. name)
end end
}) })
end end
end
table.sort(self.hist, function(v1, v2) return v1.date > v2.date end)
self.hist_menu:swithItemTable(self.hist_menu_title, self.hist) self.hist_menu:swithItemTable(self.hist_menu_title, self.hist)
end end

Loading…
Cancel
Save