Skip to content

Commit 0ab7526

Browse files
committed
4.3.1
- #36 - Fixed issue where unresolved links would not be added to the metadata cache
1 parent 2091c57 commit 0ab7526

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-admonition",
33
"name": "Admonition",
4-
"version": "4.3.0",
4+
"version": "4.3.1",
55
"minAppVersion": "0.11.0",
66
"description": "Admonition block-styled content for Obsidian.md",
77
"author": "Jeremy Valentine",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-admonition",
3-
"version": "4.3.0",
3+
"version": "4.3.1",
44
"description": "Admonition block-styled content for Obsidian.md",
55
"main": "main.js",
66
"scripts": {

src/main.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -461,28 +461,34 @@ export default class ObsidianAdmonition
461461
sourcePath: string
462462
): void {
463463
if (!this.data.syncLinks) return;
464-
464+
/* //@ts-expect-error
465+
this.app.metadataCache.resolveLinks(sourcePath); */
465466
for (let i = 0; i < links.length; i++) {
466467
const a = links[i];
467468
if (a.dataset.href) {
468469
let file = this.app.metadataCache.getFirstLinkpathDest(
469470
a.dataset.href,
470471
""
471472
);
473+
let cache, path;
472474
if (file && file instanceof TFile) {
473-
if (!this.app.metadataCache.resolvedLinks[sourcePath]) {
474-
this.app.metadataCache.resolvedLinks[sourcePath] = {
475-
[file.path]: 0
476-
};
477-
}
478-
let resolved =
479-
this.app.metadataCache.resolvedLinks[sourcePath];
480-
if (!resolved[file.path]) {
481-
resolved[file.path] = 0;
482-
}
483-
resolved[file.path] += 1;
484-
this.app.metadataCache.resolvedLinks[sourcePath] = resolved;
475+
cache = this.app.metadataCache.resolvedLinks;
476+
path = file.path;
477+
} else {
478+
cache = this.app.metadataCache.unresolvedLinks;
479+
path = a.dataset.href;
480+
}
481+
if (!cache[sourcePath]) {
482+
cache[sourcePath] = {
483+
[path]: 0
484+
};
485+
}
486+
let resolved = cache[sourcePath];
487+
if (!resolved[path]) {
488+
resolved[path] = 0;
485489
}
490+
resolved[path] += 1;
491+
cache[sourcePath] = resolved;
486492
}
487493
}
488494
}

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"4.0.1": "0.11.0",
99
"4.1.7": "0.11.0",
1010
"4.2.1": "0.11.0",
11-
"4.3.0": "0.12.0"
11+
"4.3.1": "0.12.0"
1212
}

0 commit comments

Comments
 (0)