Skip to content
33 changes: 25 additions & 8 deletions apps/obsidian/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ import {
migrateFrontmatterRelationsToRelationsJson,
mergeAllRelationsJsonToRoot,
} from "~/utils/relationsStore";
import { migrateImportFolderMetadata } from "./utils/importFolderMetadata";
import {
migrateImportFolderMetadata,
migrateImportFolderNames,
} from "./utils/importFolderMetadata";
import { registerTemplateSettingsSync } from "~/utils/templateSettingsSync";
import { fetchUserNames } from "~/utils/importNodes";
import { getLoggedInClient } from "~/utils/supabaseContext";

export default class DiscourseGraphPlugin extends Plugin {
settings: Settings = { ...DEFAULT_SETTINGS };
Expand All @@ -63,16 +68,28 @@ export default class DiscourseGraphPlugin extends Plugin {
console.error("Failed to migrate import folder metadata:", error);
});

await migrateImportFolderNames(this).catch((error) => {
console.error("Failed to migrate import folder names:", error);
});

registerTemplateSettingsSync(this);

if (this.settings.syncModeEnabled === true) {
void initializeSupabaseSync(this).catch((error) => {
console.error("Failed to initialize Supabase sync:", error);
new Notice(
`Failed to initialize Supabase sync: ${error instanceof Error ? error.message : String(error)}`,
5000,
);
});
void initializeSupabaseSync(this)
.then(async () => {
const client = await getLoggedInClient(this);
if (client) {
await fetchUserNames(this, client);
}
await migrateImportFolderNames(this);
})
.catch((error) => {
console.error("Failed to initialize Supabase sync:", error);
new Notice(
`Failed to initialize Supabase sync: ${error instanceof Error ? error.message : String(error)}`,
5000,
);
});

try {
this.fileChangeListener = new FileChangeListener(this);
Expand Down
2 changes: 2 additions & 0 deletions apps/obsidian/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export type ImportFolderMetadata = {
spaceUri: string;
spaceName: string;
userName?: string;
/** Set after auto-rename or when the user has a custom folder name. */
migrated?: boolean;
Comment thread
trangdoan982 marked this conversation as resolved.
Outdated
};

export const VIEW_TYPE_DISCOURSE_CONTEXT = "discourse-context-view";
Loading