Skip to content

Commit

Permalink
fix: 修复多个同一文件的项(非块链接)同时出现
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyloong committed May 16, 2024
1 parent 1628107 commit 186ca41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"author": "lazyloong",

"minAppVersion": "1.0.0",
"version": "2.24.1"
"version": "2.25.0"
}
12 changes: 5 additions & 7 deletions src/modal/fileModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,15 @@ export default class FileModal extends FuzzyModal<Item> {
lastNode.itemIndex = matchData1.map((p) => p.item);
lastNode.itemIndexByPath = matchData2.map((p) => p.item);
// 去除重复的笔记
let result = matchData.reduce((acc, cur) => {
let result = matchData.reduce<MatchData[]>((acc, cur) => {
if (cur.item.type === "link") {
acc.push(cur);
} else {
const existingItemIndex = acc.findIndex(
(item) => item.item.path === cur.item.path && item.score < cur.score
);
if (existingItemIndex !== -1) {
acc[existingItemIndex] = cur;
} else {
const existingItemIndex = acc.findIndex((item) => item.item.path === cur.item.path);
if (existingItemIndex === -1) {
acc.push(cur);
} else if (cur.score > acc[existingItemIndex].score) {
acc[existingItemIndex] = cur;
}
}
return acc;
Expand Down

0 comments on commit 186ca41

Please sign in to comment.