Skip to content

CoverBrowser info_cache: move to core#13018

Merged
hius07 merged 68 commits into
koreader:masterfrom
hius07:book-info-cache
Jan 18, 2025
Merged

CoverBrowser info_cache: move to core#13018
hius07 merged 68 commits into
koreader:masterfrom
hius07:book-info-cache

Conversation

@hius07

@hius07 hius07 commented Jan 8, 2025

Copy link
Copy Markdown
Member

Less calls of DocSettings:open().


This change is Reviewable

Comment thread frontend/ui/widget/menu.lua Outdated
return item_t
end

-- BookInfoCache, for menues showing the file list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(menues => Menu instances)

Surprised to see the generic Menu holding self.book_info_cache. Our generic Menu shouldn't have any trace of higher level things like DocSettings or books.
Shouldn't/couldn't it be in the FileChooser (subclass of Menu dedicated to files which are most often books) ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where to place it for History/Collections (direct subclasses of Menu)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, don't these all have a FileChooser around ? These methods could be defined in FileChoser, and plugged into the upper Menu (if the Menu instance is not the FileChooser instance, but still accessible from the FileChooser instance).

Other ideas:
Create a new bookawaremenu.lua with BookAwareMenu = Menu:extend{} and your additional methods (might find a better shorter name), and have History and Collections be a specialized BookAwareMenu instance instead of a generic Menu one.
Or have some function elsewhere that dress/empower a Menu instance that need them with these additional methods.

(I understand why you need these methods, I'm just trying to find a cleaner solution - from a architectural/object oriented point of view, so we don't travestize a generic Menu into something that it shouldn't be just to solve some problem at the time.)

@hius07

hius07 commented Jan 9, 2025

Copy link
Copy Markdown
Member Author

New BookList widget.

@hius07

hius07 commented Jan 9, 2025

Copy link
Copy Markdown
Member Author

I have an idea to put the cache into the BookList base class, the common cache for all FileChooser, Hist, Coll instances.

@poire-z

poire-z commented Jan 9, 2025

Copy link
Copy Markdown
Contributor

While you are thinking about it, give it some thoughts if something like our flat/"browse by metadata" library experiment bits could find their home in this new class.

@hius07

hius07 commented Jan 9, 2025

Copy link
Copy Markdown
Member Author

Collections already do that, maybe it's enough?
One button to put all books from a folder and subfolders into a collection, one button to see all authors/series etc.

@poire-z

poire-z commented Jan 9, 2025

Copy link
Copy Markdown
Contributor

It's a poor man's "browse by metadata", the user have to manually create collections, they are not updated when new books are added...
I'm not saying you should implement anything related in this PR, just think if bits from https://github.com/de3sw2aq1/koreader-patches/blob/main/patches/2-BrowseByMetadata.lua could naturally find a home into this new class (instead of hacking too much FileChooser).

@hius07

hius07 commented Jan 9, 2025

Copy link
Copy Markdown
Member Author

But it is a real flat library, not folder-tree.

@hius07

hius07 commented Jan 12, 2025

Copy link
Copy Markdown
Member Author

Can we approve the names before next massive renaming please.

(1) BookList.getBookInfoCache(file) - propose to rename to BookList.getBookInfo(file), no need to mention the cache.
Some duplication of

function BookInfoManager:getBookInfo(filepath, get_cover)

(2) BookList.setBookInfoCache(file, status) - currently is used for changing cached status only, so I keep the generic name, but do not pass the whole table of properties to be changed.
Can be renamed to BookList.setBookInfoCacheStatus(file, status), but "status" looks duplicated, and will need to be renamed again when (if) more cached properties to be set.

(3) BookList.resetBookInfoCache(file) - good.

(4) BookList.beenOpened(file) - to be renamed to BookList.hasBookBeenOpened(file)

(5) BookList.openDocSettings(file) - inherits the name from DocSettings:open and actually returns doc_settings, probably good.

@Frenzie

Frenzie commented Jan 12, 2025

Copy link
Copy Markdown
Member

Sounds good to me at a glance.

@poire-z

poire-z commented Jan 12, 2025

Copy link
Copy Markdown
Contributor

(2) BookList.setBookInfoCache(file, status) - currently is used for changing cached status only, so I keep the generic name, but do not pass the whole table of properties to be changed.
Can be renamed to BookList.setBookInfoCacheStatus(file, status), but "status" looks duplicated, and will need to be renamed again when (if) more cached properties to be set.

I don't see how it's duplicated (?).
Anyway, it's either BookList.setBookInfoCacheProperty(file, prop_name, prop_value), or many BookList.setBookInfoCacheStatus, BookList.setBookInfoCacheBeenOpened, BookList.setBookInfoCachePages.
No problem with either if they can get different bits of logic depending on the properties.

Can't they even abstract more things ? ie. BookList.setBookInfoCacheBeenOpened with false => BookList.setBookBeenOpened would removed thedocsetting ?
Just asking: why are we just update xyzBookInfoCacheZzz ? Shouldn't/couldn't these just handle everythng ? The cache and the real docsetting field ? Or is all this just aimed at the cache, and there's no reason (now or later) to have these do more things ?

(5) BookList.openDocSettings(file) - inherits the name from DocSettings:open and actually returns doc_settings, probably good.

Why note BookList.getDocSettings(file) ? The point is that these higher level don't need to inherit the technical names of the lower level ones.

Fine with the others.

@poire-z

poire-z commented Jan 12, 2025

Copy link
Copy Markdown
Contributor

Can't they even abstract more things ? [...]Or is all this just aimed at the cache, and there's no reason (now or later) to have these do more things ?

May be i'm seeing too wide :) After all, BookList is just a subclass of Menu, a visual widget. It's not named BookManager.


-- BookInfo

function BookList.setBookInfoCache(file, doc_settings)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything (in the other changed modules) reads rather well.
This one is ok, but just mentionning some minor thought, in case you prefer these options:
setBookInfoCache(doc_settings) could read (a quick read) that we set the doc_settings as the cached thing.
setBookInfoCacheFrom(doc_settings) would make it clearer that we don't, but it's long and ugly.
updateBookInfoCache(doc_settings) would avoid the "set" feeling, and "update" is sufficiently opaque that we know we update the cache from the doc_settings.

Comment on lines +46 to +47
function BookList.setBookInfoCacheProperty(file, prop_name, prop_value)
if prop_name == "been_opened" and prop_value == false then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also ok, but :):
Elsewhere, we use: BookList.setBookInfoCacheProperty(file, "status", to_status).
Not fond of passing property names as strings ("status"), just from a stylistic PoV (it's prone to typo, but so it is if we pass it as a table key name).
The alternative I used in a few places is to have BookList.PROP_STATUS = "status" (or BookList.PROP_STATUS = 1) and just pass BookList.PROP_STATUS to avoid typos (we'll get a nil if a typo). But it's noisy.

We could also just pass a table BookList.updateBookInfoCache( { status = "reading" } ), but you'd need to iterate as it advertizes we could pass multiple properties. (And the name conflicts with my previous comment suggestion :)).

Anyway, just some thoughts in case you prefer one of these if you were not satisfied with the one you decided in the heat of the moment :)

@hius07 hius07 merged commit 1750499 into koreader:master Jan 18, 2025
@hius07 hius07 deleted the book-info-cache branch January 18, 2025 08:08
@hius07 hius07 added this to the 2025.01 milestone Jan 18, 2025
jospalau pushed a commit to jospalau/koreader that referenced this pull request Jan 22, 2025
…me recent changes in commit 1750499, CoverBrowser info_cache: move to core (koreader#13018). Update them manually
jospalau pushed a commit to jospalau/koreader that referenced this pull request Jan 22, 2025
… changes in commit 1750499, CoverBrowser info_cache: move to core (koreader#13018). Restore the modifications made for them
jospalau pushed a commit to jospalau/koreader that referenced this pull request Jan 27, 2025
…ce the book is being read and we change the status to tbr, even though the tbr mark appears, the progress bar remains. This probably was introduced in commit 1750499, CoverBrowser info_cache: move to core (koreader#13018). Reset the book info from the cache and refresh history or fm
jospalau pushed a commit to jospalau/koreader that referenced this pull request Jan 27, 2025
…ce the book is being read and we change the status to tbr, even though the tbr mark appears, the progress bar remains. This probably was introduced in commit 1750499, CoverBrowser info_cache: move to core (koreader#13018). Cleaning and fix some comments
Commodore64user pushed a commit to Commodore64user/KOReader_fork that referenced this pull request Jan 27, 2025
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants