|
8 | 8 | import { getDateForPage } from 'logseq-dateutils'
|
9 | 9 | import {
|
10 | 10 | Article,
|
| 11 | + compareHighlightsInFile, |
11 | 12 | getHighlightLocation,
|
12 | 13 | getHighlightPoint,
|
13 | 14 | loadArticles,
|
@@ -166,19 +167,19 @@ const fetchOmnivore = async (inBackground = false) => {
|
166 | 167 | // sort highlights by location if selected in options
|
167 | 168 | highlightOrder === HighlightOrder.LOCATION &&
|
168 | 169 | article.highlights?.sort((a, b) => {
|
169 |
| - if (article.pageType === PageType.File) { |
170 |
| - // get the position of the highlight in the file |
171 |
| - const highlightPointA = getHighlightPoint(a.patch) |
172 |
| - const highlightPointB = getHighlightPoint(b.patch) |
173 |
| - if (highlightPointA.top === highlightPointB.top) { |
174 |
| - // if top is same, sort by left |
175 |
| - return highlightPointA.left - highlightPointB.left |
| 170 | + try { |
| 171 | + if (article.pageType === PageType.File) { |
| 172 | + // sort by location in file |
| 173 | + return compareHighlightsInFile(a, b) |
176 | 174 | }
|
177 |
| - // sort by top |
178 |
| - return highlightPointA.top - highlightPointB.top |
| 175 | + // for web page, sort by location in the page |
| 176 | + return ( |
| 177 | + getHighlightLocation(a.patch) - getHighlightLocation(b.patch) |
| 178 | + ) |
| 179 | + } catch (e) { |
| 180 | + console.error(e) |
| 181 | + return compareHighlightsInFile(a, b) |
179 | 182 | }
|
180 |
| - // for web page, sort by location in the page |
181 |
| - return getHighlightLocation(a.patch) - getHighlightLocation(b.patch) |
182 | 183 | })
|
183 | 184 |
|
184 | 185 | const highlightBatch = article.highlights?.map((it) => {
|
|
0 commit comments