Display pages read as tooltip on books and book calendar - #124
Open
binarymelon wants to merge 2 commits into
Open
Display pages read as tooltip on books and book calendar#124binarymelon wants to merge 2 commits into
binarymelon wants to merge 2 commits into
Conversation
GeorgeSG
reviewed
Aug 1, 2026
| @@ -0,0 +1,73 @@ | |||
| import { BookWithData, PageStat } from '@koinsight/common/types'; | |||
Collaborator
There was a problem hiding this comment.
Lots of computation going on in this file. So far I've been trying to keep this on the server side, especially if it's computed every time the page is rendered. Maybe we should try to move the logic so it gets fetched by BookWithData (we should also come up with a better name 馃槄)
GeorgeSG
reviewed
Aug 1, 2026
Comment on lines
+29
to
+49
| export function normalizeRanges(ranges: Range[]): Range[] { | ||
| const epsilon = 1e-9; | ||
| const sorted = [...ranges].sort((a, b) => a[0] - b[0]); | ||
| const result: Range[] = []; | ||
|
|
||
| for (const [start, end] of sorted) { | ||
| if (result.length === 0) { | ||
| result.push([start, end]); | ||
| continue; | ||
| } | ||
|
|
||
| const last = result[result.length - 1]; | ||
| if (start <= last[1] + epsilon) { | ||
| last[1] = Math.max(last[1], end); | ||
| } else { | ||
| result.push([start, end]); | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } |
Collaborator
There was a problem hiding this comment.
I think this is duplicated from the server side? One more reason to keep the computation there
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add pages read as tool-tip on calendar views