Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit 1b9acac

Browse files
committed
fix: fix vault config bug
fetch vault attachment folder config from app.json fix #30
1 parent 75de30e commit 1b9acac

8 files changed

+49
-31
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [2.1.1](https://github.com/JYC333/obsidian-file-structure-format/compare/2.1.0...2.1.1) (2023-10-26)
2+
3+
4+
### Bug Fixes
5+
6+
* fix vault config bug ([b87f885](https://github.com/JYC333/obsidian-file-structure-format/commit/b87f885ba1d8715c1de29507f70626aa414d223f)), closes [#30](https://github.com/JYC333/obsidian-file-structure-format/issues/30)
7+
8+
9+
110
# [2.1.0](https://github.com/JYC333/obsidian-file-structure-format/compare/2.0.0...2.1.0) (2023-05-06)
211

312

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Yuchuan Jin
3+
Copyright (c) 2021-2023 Yuchuan Jin
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-attachment-name-formatting",
33
"name": "Attachment Name Formatting",
4-
"version": "2.1.0",
4+
"version": "2.1.1",
55
"minAppVersion": "0.12.0",
66
"description": "Obsidian plugin for formatting attachments name (filename attachmentType indexNumber.xxx)",
77
"author": "JYC333",

package-lock.json

+19-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-attachment-name-formattion",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Obsidian plugin for formatting attachments name (filename attachmentType indexNumber.xxx)",
55
"main": "main.js",
66
"scripts": {

src/main.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface AttachmentList {
2929

3030
export default class AttachmentNameFormatting extends Plugin {
3131
settings: ANFSettings;
32+
vaultAttachmentFolderPath: string;
3233
allFolders: string[];
3334
renaming = false;
3435
renameCopyAttachment: string[] = [];
@@ -223,6 +224,15 @@ export default class AttachmentNameFormatting extends Plugin {
223224
}
224225
}
225226

227+
async getVaultAttachmentFolderPath() {
228+
await this.app.vault.adapter
229+
.read(this.app.vault.configDir + "/app.json")
230+
.then((config) => {
231+
this.vaultAttachmentFolderPath =
232+
JSON.parse(config).attachmentFolderPath;
233+
});
234+
}
235+
226236
/**
227237
* Rename the attachments in the active file when it has
228238
*
@@ -242,6 +252,8 @@ export default class AttachmentNameFormatting extends Plugin {
242252
this.renaming = true;
243253
timeInterval = new Date();
244254

255+
await this.getVaultAttachmentFolderPath();
256+
245257
console.log("Formatting attachments...");
246258

247259
// Get the metadata of the active file
@@ -352,9 +364,7 @@ export default class AttachmentNameFormatting extends Plugin {
352364
if (attachmentFile instanceof TFile) {
353365
// Create the new full name with path
354366
// Fetch attachment folder path setting
355-
let parent_path =
356-
// @ts-ignore
357-
this.app.vault.config.attachmentFolderPath;
367+
let parent_path = this.vaultAttachmentFolderPath;
358368

359369
if (parent_path.startsWith("./")) {
360370
parent_path = path.join(

src/settings.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ export class ANFSettingTab extends PluginSettingTab {
211211
});
212212

213213
new Setting(containerEl)
214-
.setName("Automic formatting")
214+
.setName("Automatic formatting")
215215
.setDesc(
216-
"Automic formatting the attachments' name when changing note content"
216+
"Automatic formatting the attachments' name when changing note content"
217217
)
218218
.addToggle((toggle) => {
219219
toggle
@@ -416,7 +416,7 @@ export class ANFSettingTab extends PluginSettingTab {
416416
containerEl.createEl("h2", { text: "Log Setting" });
417417

418418
new Setting(containerEl)
419-
.setName("Logging Attahment Name Changes")
419+
.setName("Logging Attachment Name Changes")
420420
.setDesc("Logging the attachmnet name changes into file.")
421421
.addToggle((toggle) =>
422422
toggle

versions.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"1.6.2": "0.12.0",
1010
"1.6.3": "0.12.0",
1111
"1.6.4": "0.12.0",
12-
"%npm_config_new%": "0.12.0",
13-
"true": "0.12.0",
1412
"1.7.0": "0.12.0",
1513
"1.8.0": "0.12.0",
1614
"1.9.0": "0.12.0",
@@ -24,5 +22,6 @@
2422
"1.9.8": "0.12.0",
2523
"1.10.0": "0.12.0",
2624
"2.0.0": "0.12.0",
27-
"2.1.0": "0.12.0"
25+
"2.1.0": "0.12.0",
26+
"2.1.1": "0.12.0"
2827
}

0 commit comments

Comments
 (0)