OPDSBrowser: Update the title during navigation (#7034)

* OPDSBrowser: Update the title during navigation

Fix #7030
reviewable/pr7038/r1
NiLuJe 3 years ago committed by GitHub
parent b78d9c1576
commit 7df60ba0e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -125,6 +125,7 @@ function OPDSBrowser:init()
servers[4].url = "https://bookserver.archive.org" servers[4].url = "https://bookserver.archive.org"
end end
self.item_table = self:genItemTableFromRoot() self.item_table = self:genItemTableFromRoot()
self.catalog_title = nil
Menu.init(self) -- call parent's init() Menu.init(self) -- call parent's init()
end end
@ -520,7 +521,7 @@ end
function OPDSBrowser:updateCatalog(item_url, username, password) function OPDSBrowser:updateCatalog(item_url, username, password)
local menu_table = self:genItemTableFromURL(item_url, username, password) local menu_table = self:genItemTableFromURL(item_url, username, password)
if #menu_table > 0 then if #menu_table > 0 then
self:switchItemTable(nil, menu_table) self:switchItemTable(self.catalog_title, menu_table)
if self.page_num <= 1 then if self.page_num <= 1 then
self:onNext() self:onNext()
end end
@ -536,7 +537,7 @@ function OPDSBrowser:appendCatalog(item_url, username, password)
table.insert(self.item_table, item) table.insert(self.item_table, item)
end end
self.item_table.hrefs = new_table.hrefs self.item_table.hrefs = new_table.hrefs
self:switchItemTable(nil, self.item_table, -1) self:switchItemTable(self.catalog_title, self.item_table, -1)
return true return true
end end
@ -680,6 +681,7 @@ function OPDSBrowser:browse(browse_url, username, password)
url = browse_url, url = browse_url,
username = username, username = username,
password = password, password = password,
title = self.catalog_title,
}) })
if not self:updateCatalog(browse_url, username, password) then if not self:updateCatalog(browse_url, username, password) then
table.remove(self.paths) table.remove(self.paths)
@ -721,6 +723,7 @@ function OPDSBrowser:browseSearchable(browse_url, username, password)
end end
function OPDSBrowser:onMenuSelect(item) function OPDSBrowser:onMenuSelect(item)
self.catalog_title = item.text or _("OPDS Catalog")
-- add catalog -- add catalog
if item.callback then if item.callback then
item.callback() item.callback()
@ -862,6 +865,7 @@ function OPDSBrowser:onReturn()
local path = self.paths[#self.paths] local path = self.paths[#self.paths]
if path then if path then
-- return to last path -- return to last path
self.catalog_title = path.title
self:updateCatalog(path.url, path.username, path.password) self:updateCatalog(path.url, path.username, path.password)
else else
-- return to root path, we simply reinit opdsbrowser -- return to root path, we simply reinit opdsbrowser

Loading…
Cancel
Save