mirror of
https://github.com/xallt/sync-graph-settings.git
synced 2026-07-22 07:10:28 +00:00
Finalize for first release
This commit is contained in:
parent
156bfd9dd0
commit
f447761a93
1 changed files with 17 additions and 8 deletions
25
main.ts
25
main.ts
|
|
@ -1,4 +1,4 @@
|
|||
import { Plugin, WorkspaceLeaf, TFile} from 'obsidian';
|
||||
import { Plugin, WorkspaceLeaf, TFile, normalizePath} from 'obsidian';
|
||||
import * as path from "path";
|
||||
import {readFile} from "fs/promises";
|
||||
|
||||
|
|
@ -13,16 +13,25 @@ export default class SyncGraphPlugin extends Plugin {
|
|||
|
||||
async syncGlobalToLocal() {
|
||||
const configDir = app.vault.configDir;
|
||||
const graphConfigPath = path.join(configDir, 'graph.json');
|
||||
const graphConfigPath = normalizePath(configDir + '/graph.json');
|
||||
|
||||
// this.app.vault.getAbstractFileByPath('.obsidian/graph.json') would return null
|
||||
// So we're doing it the less safe way
|
||||
const graphConfigJson = await this.app.vault.adapter.read(graphConfigPath);
|
||||
const graphConfig = JSON.parse(graphConfigJson);
|
||||
const graphColorGroups = graphConfig.colorGroups;
|
||||
this.getLocalGraphLeaves().forEach((leaf) => {
|
||||
this.setColorGroups(leaf, graphColorGroups);
|
||||
})
|
||||
// const graphConfigJson = await this.app.vault.adapter.read(graphConfigPath);
|
||||
// const graphConfigFile = app.vault.getAbstractFileByPath(graphConfigPath);
|
||||
// if (graphConfigFile instanceof TFile) {
|
||||
if (true) {
|
||||
// const graphConfigJson = await app.vault.read(graphConfigFile);
|
||||
const graphConfigJson = await this.app.vault.adapter.read(graphConfigPath);
|
||||
const graphConfig = JSON.parse(graphConfigJson);
|
||||
const graphColorGroups = graphConfig.colorGroups;
|
||||
this.getLocalGraphLeaves().forEach((leaf) => {
|
||||
this.setColorGroups(leaf, graphColorGroups);
|
||||
})
|
||||
} else {
|
||||
// console.log(graphConfigPath);
|
||||
// console.log(graphConfigFile);
|
||||
}
|
||||
}
|
||||
|
||||
getLocalGraphLeaves() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue