Skip to content

Commit ae8e573

Browse files
Fix crash and improve fractions in list view of library (#1602)
* library: correctly parse title in list view regardless of type The title can be an object, a string or null. Setting a label to null instead of "" is an uncatchable exception. Thus, if this even happens, Foliate will crash. Fixes: f1a1602 ("Update foliate-js") Signed-off-by: Markus Göllnitz <camelcasenick@bewares.it> * library: improve fraction calculation With a zero-based index, this assumes if you are on a page, that you read it partially exactly to the amount of pages you read before relative to the amount of pages before and after. That results in the first page being considered unread and the last page being fully read of you were on those pages. While this is not accurate, there is no way to accurately determine the current sub-page percentage a person read. However, at least, this results in the percentage going from 0 % to 100 % for any given book. Thus, opening a book for the first time and not starting to read it marks it as 0 %, which is the desired outcome of this change. Signed-off-by: Markus Göllnitz <camelcasenick@bewares.it> --------- Signed-off-by: Markus Göllnitz <camelcasenick@bewares.it>
1 parent 1a63d93 commit ae8e573

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/library.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ GObject.registerClass({
219219
}
220220
})
221221

222-
const fraction = p => p?.[1] ? (p[0] + 1) / (p[1] + 1) : null
222+
const fraction = p => !isNaN(p?.[1]) && p?.[1] > 0 ? p[0] / p[1] : null
223223

224224
const BookItem = GObject.registerClass({
225225
GTypeName: 'FoliateBookItem',
@@ -279,7 +279,7 @@ const BookRow = GObject.registerClass({
279279
update(item, data) {
280280
this.#item = item
281281
const { metadata, progress } = data
282-
const title = metadata?.title
282+
const title = formatLanguageMap(metadata?.title)
283283
this._title.label = title
284284

285285
const author = formatAuthors(metadata)

0 commit comments

Comments
 (0)