Skip to content

Commit 369e231

Browse files
committed
add authors to import modal.
1 parent 1221299 commit 369e231

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

apps/obsidian/src/components/ImportNodesModal.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,27 @@ const ImportNodesContent = ({ plugin, onClose }: ImportNodesModalProps) => {
106106
groupName:
107107
spaceNames.get(node.space_id) ?? `Space ${node.space_id}`,
108108
nodes: [],
109+
authors: new Set(),
109110
});
110111
}
111112

112113
const group = grouped.get(groupId)!;
114+
const spaceName =
115+
spaceNames.get(node.space_id) ?? `Space ${node.space_id}`;
113116
group.nodes.push({
114117
nodeInstanceId: node.source_local_id,
115118
title: node.text,
116119
spaceId: node.space_id,
117-
spaceName: spaceNames.get(node.space_id) ?? `Space ${node.space_id}`,
120+
spaceName,
118121
groupId,
119122
selected: false,
120123
createdAt: node.createdAt,
121124
modifiedAt: node.modifiedAt,
122125
filePath: node.filePath,
123126
authorName: node.authorName,
124127
});
128+
f(node.authorName && !node.authorName !== spaceName);
129+
group.authors.add(node.authorName);
125130
}
126131

127132
setGroupsWithNodes(Array.from(grouped.values()));
@@ -259,6 +264,7 @@ const ImportNodesContent = ({ plugin, onClose }: ImportNodesModalProps) => {
259264
number,
260265
{
261266
spaceName: string;
267+
authors: Set<string>;
262268
nodes: Array<{
263269
node: ImportableNode;
264270
groupId: string;
@@ -272,6 +278,7 @@ const ImportNodesContent = ({ plugin, onClose }: ImportNodesModalProps) => {
272278
if (!nodesBySpace.has(node.spaceId)) {
273279
nodesBySpace.set(node.spaceId, {
274280
spaceName: node.spaceName,
281+
authors: group.authors,
275282
nodes: [],
276283
});
277284
}
@@ -323,14 +330,17 @@ const ImportNodesContent = ({ plugin, onClose }: ImportNodesModalProps) => {
323330

324331
<div className="max-h-96 overflow-y-auto rounded border">
325332
{Array.from(nodesBySpace.entries()).map(
326-
([spaceId, { spaceName, nodes }]) => {
333+
([spaceId, { spaceName, nodes, authors }]) => {
327334
return (
328335
<div key={spaceId} className="border-b">
329336
<div className="bg-muted/10 flex items-center px-3 py-2">
330337
<span className="mr-2">📂</span>
331338
<span className="text-accent-foreground line-clamp-1 font-medium italic">
332339
{spaceName}
333340
</span>
341+
{authors.size === 1 && (
342+
<span>&nbsp;({[...authors][0]})</span>
343+
)}
334344
<span className="text-muted ml-2 text-sm">
335345
({nodes.length} node{nodes.length !== 1 ? "s" : ""})
336346
</span>
@@ -350,6 +360,13 @@ const ImportNodesContent = ({ plugin, onClose }: ImportNodesModalProps) => {
350360
<div className="min-w-0 flex-1">
351361
<div className="line-clamp-3 font-medium">
352362
{node.title}
363+
{node.authorName &&
364+
authors.size > 1 &&
365+
node.authorName !== spaceName && (
366+
<span className="font-light">
367+
&nbsp;({node.authorName})
368+
</span>
369+
)}
353370
</div>
354371
</div>
355372
</div>

apps/obsidian/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export type GroupWithNodes = {
104104
groupId: string;
105105
groupName?: string;
106106
nodes: ImportableNode[];
107+
authors: Set<string>;
107108
};
108109

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

0 commit comments

Comments
 (0)