Skip to content

Commit

Permalink
Merge pull request #801 from ZhouBlackDuck/master
Browse files Browse the repository at this point in the history
修复高能进度条显示bug(第一页有记录时间但无法在高能进度条显示)
  • Loading branch information
MuiseDestiny committed Dec 14, 2023
2 parents 4b98519 + 7d12463 commit 757a124
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/modules/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class Events {
// Zotero is bulr
if (!(reader && reader.state && this.state.activate && item)) { return }
ztoolkit.log("listeningReader is running")
// pageIndex get from Zotero.Reader, it is start from 1
const pageIndex = reader.state.pageIndex;
if (pageIndex == this.state.pageIndex) {
if (reader.state.left == this.state.left && reader.state.top == this.state.top)
Expand Down Expand Up @@ -69,10 +70,11 @@ export default class Events {
data: {}
}
}
if (this.cache[cacheKey].data[pageIndex]) {
this.cache[cacheKey].data[pageIndex] += this.recordInterval
// when progress start to render, it starts from key 0
if (this.cache[cacheKey].data[pageIndex - 1]) {
this.cache[cacheKey].data[pageIndex - 1] += this.recordInterval
} else {
this.cache[cacheKey].data[pageIndex] = this.recordInterval
this.cache[cacheKey].data[pageIndex - 1] = this.recordInterval
}
await this.storage.set(item, "readingTime", this.cache[cacheKey])
}
Expand Down

0 comments on commit 757a124

Please sign in to comment.