Skip to content

Commit b096d0d

Browse files
committed
perf: improve performance by using batch insert
1 parent d68e2a3 commit b096d0d

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
LSPluginBaseInfo,
66
SettingSchemaDesc,
77
} from '@logseq/libs/dist/LSPlugin'
8-
import { getDateForPage } from 'logseq-dateutils';
8+
import { getDateForPage } from 'logseq-dateutils'
99
import icon from './icon.png'
1010
import { Article, loadArticles } from './util'
1111

@@ -38,8 +38,9 @@ const settings: SettingSchemaDesc[] = [
3838
const siteNameFromUrl = (originalArticleUrl: string): string => {
3939
try {
4040
return new URL(originalArticleUrl).hostname.replace(/^www\./, '')
41-
} catch {}
42-
return ''
41+
} catch {
42+
return ''
43+
}
4344
}
4445

4546
const delay = (t = 100) => new Promise((r) => setTimeout(r, t))
@@ -69,8 +70,8 @@ const fetchOmnivore = async (
6970

7071
loading = true
7172
let targetBlock: BlockEntity | null = null
72-
const userConfigs = await logseq.App.getUserConfigs();
73-
const preferredDateFormat: string = userConfigs.preferredDateFormat;
73+
const userConfigs = await logseq.App.getUserConfigs()
74+
const preferredDateFormat: string = userConfigs.preferredDateFormat
7475

7576
try {
7677
!inBackground && (await logseq.UI.showMsg('🚀 Fetching articles ...'))
@@ -117,8 +118,9 @@ const fetchOmnivore = async (
117118
let content = `[${article.title}](https://omnivore.app/me/${article.slug})`
118119
content += '\ncollapsed:: true'
119120

120-
const displaySiteName = article.siteName || siteNameFromUrl(article.originalArticleUrl)
121-
console.log("display site name", displaySiteName)
121+
const displaySiteName =
122+
article.siteName || siteNameFromUrl(article.originalArticleUrl)
123+
console.log('display site name', displaySiteName)
122124
if (displaySiteName) {
123125
content += `\nsite:: [${displaySiteName}](${article.originalArticleUrl})`
124126
}
@@ -133,7 +135,10 @@ const fetchOmnivore = async (
133135
.join()}`
134136
}
135137

136-
content += `\ndate_saved:: ${getDateForPage(new Date(article.savedAt), preferredDateFormat)}`
138+
content += `\ndate_saved:: ${getDateForPage(
139+
new Date(article.savedAt),
140+
preferredDateFormat
141+
)}`
137142

138143
// remove existing block for the same article
139144
const existingBlocks = await logseq.DB.q<BlockEntity>(

0 commit comments

Comments
 (0)