mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
update self.items and self.current after file deletion
This commit is contained in:
@@ -200,6 +200,7 @@ function FileChooser:choose(ypos, height)
|
||||
if i <= #self.dirs then
|
||||
DrawFileItem(self.dirs[i],self.margin_H,ypos+self.title_H+self.spacing*c,"folder")
|
||||
elseif i <= self.items then
|
||||
print("-----", self.files[i-#self.dirs])
|
||||
local file_type = string.lower(string.match(self.files[i-#self.dirs], ".+%.([^.]+)") or "")
|
||||
DrawFileItem(self.files[i-#self.dirs],self.margin_H,ypos+self.title_H+self.spacing*c,file_type)
|
||||
end
|
||||
@@ -370,6 +371,8 @@ function FileChooser:addAllCommands()
|
||||
if lfs.rmdir(self.path.."/"..folder) then
|
||||
self.pagedirty = true
|
||||
table.remove(self.dirs, offset)
|
||||
self.items = self.items - 1
|
||||
self.current = self.current - 1
|
||||
else
|
||||
showInfoMsgWithDelay("This folder can not be deleted! ",2000,1)
|
||||
end
|
||||
@@ -385,6 +388,8 @@ function FileChooser:addAllCommands()
|
||||
os.remove(DocToHistory(fullpath))
|
||||
-- to avoid showing just deleted file
|
||||
table.remove(self.files, pos)
|
||||
self.items = self.items - 1
|
||||
self.current = self.current - 1
|
||||
self.pagedirty = true
|
||||
end
|
||||
end -- if folder == ".."
|
||||
|
||||
Reference in New Issue
Block a user