-
Notifications
You must be signed in to change notification settings - Fork 6
ENG-1656: Rename imported vault folders to owner-username-spaceName #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1c3615e
2bd6a6d
42425cf
aaf0cdf
7eb9501
159aaa8
72bf26d
0803a25
3ea5563
598da9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,6 +281,16 @@ export const fetchUserNames = async ( | |
| await plugin.saveSettings(); | ||
| }; | ||
|
|
||
| const resolveOwnerUserName = ( | ||
| nodes: ImportableNode[], | ||
| plugin: DiscourseGraphPlugin, | ||
| ): string | undefined => { | ||
| const authorId = nodes.find((n) => n.authorId !== undefined)?.authorId; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don’t think deriving For Obsidian, the configured username is uploaded as |
||
| return authorId !== undefined | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a concern, let me know if I'm missing something. We are looking at first author; but in obsidian first author is the default author, which is created in src/utils/supabaseContext.ts:101, and unless we've set a username in settings, the default name is the same as the vault name (L80). So we'd basically repeat the vault name in most cases. Can we detect that case, and consider that the author name is undefined if it's identical to the vault name? |
||
| ? (plugin.settings.userNames ?? {})[authorId] | ||
| : undefined; | ||
| }; | ||
|
|
||
| export const fetchNodeContent = async ({ | ||
| client, | ||
| spaceId, | ||
|
|
@@ -1318,9 +1328,11 @@ export const importSelectedNodes = async ({ | |
| nodesBySpace.get(node.spaceId)!.push(node); | ||
| } | ||
|
|
||
| const spaceUris = await getSpaceUris(client, [...nodesBySpace.keys()]); | ||
| const spaceNames = await getSpaceNameFromIds(client, [ | ||
| ...nodesBySpace.keys(), | ||
| const spaceIdList = [...nodesBySpace.keys()]; | ||
| const [spaceUris, spaceNames] = await Promise.all([ | ||
| getSpaceUris(client, spaceIdList), | ||
| getSpaceNameFromIds(client, spaceIdList), | ||
| fetchUserNames(plugin, client), | ||
| ]); | ||
|
|
||
| // Process each space | ||
|
|
@@ -1336,10 +1348,12 @@ export const importSelectedNodes = async ({ | |
| } | ||
|
|
||
| const spaceName = spaceNames.get(spaceId) ?? `space-${spaceId}`; | ||
| const ownerUserName = resolveOwnerUserName(nodes, plugin); | ||
| const importFolderPath = await resolveFolderForSpaceUri({ | ||
| adapter: plugin.app.vault.adapter, | ||
| spaceUri, | ||
| spaceName, | ||
| ownerUserName, | ||
| }); | ||
|
|
||
| // Process each node in this space | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's the right call, but flagging that means we're not resilient to the user renaming the folder.