Fix no tocItem for some progress

This commit is contained in:
chrox
2024-11-07 22:49:39 +01:00
parent b768802305
commit 4d56900c3b
2 changed files with 9 additions and 9 deletions
@@ -85,10 +85,10 @@ const TOCItemView: React.FC<{
</span>
{item.subitems && isExpanded && (
<ol role='group'>
{item.subitems.map((subitem) => (
{item.subitems.map((subitem, index) => (
<TOCItemView
bookKey={bookKey}
key={subitem.label}
key={`${index}-${subitem.href}`}
item={subitem}
depth={depth + 1}
setCurrentHref={setCurrentHref}
@@ -152,10 +152,10 @@ const TOCView: React.FC<{
<div className='max-h-[calc(100vh-173px)] overflow-y-auto rounded pt-2'>
<ul role='tree' ref={tocRef} className='overflow-y-auto px-2'>
{toc &&
toc.map((item) => (
toc.map((item, index) => (
<TOCItemView
bookKey={bookKey}
key={item.label}
key={`${index}-${item.href}`}
item={item}
depth={0}
setCurrentHref={setCurrentHref}
+5 -5
View File
@@ -279,8 +279,8 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
config: {
...book.config,
lastUpdated: Date.now(),
href: tocItem.href,
chapter: tocItem.label,
href: tocItem?.href,
chapter: tocItem?.label,
progress: [pageinfo.current, pageinfo.total],
location,
section,
@@ -290,9 +290,9 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
...book.progress,
progress: [pageinfo.current, pageinfo.total],
location,
tocHref: tocItem.href,
tocLabel: tocItem.label,
tocId: tocItem.id,
tocHref: tocItem?.href,
tocLabel: tocItem?.label,
tocId: tocItem?.id,
section,
pageinfo,
range,