mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
Make typecheck happy
This commit is contained in:
parent
46643a7111
commit
eb31360dad
1 changed files with 34 additions and 24 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { TFile } from "obsidian";
|
||||
import { FrontmatterLinkCache, LinkCache, TFile } from "obsidian";
|
||||
import { AFileSyncTable } from "./abstractFileSyncTable";
|
||||
|
||||
export class LinksFileSyncTable extends AFileSyncTable {
|
||||
|
|
@ -26,29 +26,39 @@ export class LinksFileSyncTable extends AFileSyncTable {
|
|||
if (!cache) {
|
||||
return []
|
||||
}
|
||||
const tags = (cache.links || []).concat(cache.frontmatterLinks || []);
|
||||
return tags.map((t) => {
|
||||
const targetFile = this.app.metadataCache.getFirstLinkpathDest(t.link, file.path)
|
||||
let targetExists = false
|
||||
let target = t.link
|
||||
if (targetFile) {
|
||||
target = targetFile.path
|
||||
targetExists = true
|
||||
}
|
||||
let position = t.position;
|
||||
if (t.key) {
|
||||
position = {
|
||||
frontmatterKey: t.key
|
||||
}
|
||||
}
|
||||
return {
|
||||
path: file.path,
|
||||
target: target,
|
||||
position: position,
|
||||
display_text: t.displayText,
|
||||
target_exists: targetExists
|
||||
}
|
||||
})
|
||||
|
||||
const links: any[] = (cache.links || []).map((l: LinkCache) => {
|
||||
return {
|
||||
targetLink: l.link,
|
||||
position: l.position,
|
||||
display_text: l.displayText
|
||||
}
|
||||
});
|
||||
|
||||
const frontmatterLinks: any[] = (cache.frontmatterLinks || []).map((l: FrontmatterLinkCache) => {
|
||||
return {
|
||||
targetLink: l.link,
|
||||
position: { frontmatterKey: l.key },
|
||||
display_text: l.displayText
|
||||
}
|
||||
});
|
||||
|
||||
return links.concat(frontmatterLinks).map(({ targetLink, ...reference }) => {
|
||||
const targetFile = this.app.metadataCache.getFirstLinkpathDest(targetLink, file.path)
|
||||
let targetExists = false
|
||||
let target = targetLink
|
||||
if (targetFile) {
|
||||
target = targetFile.path
|
||||
targetExists = true
|
||||
}
|
||||
|
||||
return {
|
||||
path: file.path,
|
||||
target: target,
|
||||
...reference,
|
||||
target_exists: targetExists
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue