Skip to content

Commit 722a54a

Browse files
committed
eng-1650 WIP
1 parent 73f4dd7 commit 722a54a

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

apps/obsidian/src/components/GeneralSettings.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ const GeneralSettings = () => {
152152
const [canvasFolderPath, setCanvasFolderPath] = useState<string>(
153153
plugin.settings.canvasFolderPath,
154154
);
155+
const [username, setUsername] = useState<string>(
156+
plugin.settings.username || "",
157+
);
155158
const [canvasAttachmentsFolderPath, setCanvasAttachmentsFolderPath] =
156159
useState<string>(plugin.settings.canvasAttachmentsFolderPath);
157160
const [nodeTagHotkey, setNodeTagHotkey] = useState<string>(
@@ -203,6 +206,12 @@ const GeneralSettings = () => {
203206
[plugin],
204207
);
205208

209+
const handleSetUsername = (newValue: string) => {
210+
setUsername(newValue);
211+
plugin.settings.username = newValue;
212+
void plugin.saveSettings();
213+
};
214+
206215
return (
207216
<div className="general-settings">
208217
<div className="setting-item">
@@ -307,6 +316,27 @@ const GeneralSettings = () => {
307316
</div>
308317
</div>
309318

319+
<div
320+
className={
321+
"setting-item " + (plugin.settings.syncModeEnabled ? "" : "hidden")
322+
}
323+
>
324+
<div className="setting-item-info">
325+
<div className="setting-item-name">Username</div>
326+
<div className="setting-item-description">
327+
A username that will be associated with your vault if you share
328+
data.
329+
</div>
330+
</div>
331+
<div className="setting-item-control">
332+
<input
333+
type="text"
334+
value={username}
335+
onChange={(e) => handleSetUsername(e.target.value)}
336+
/>
337+
</div>
338+
</div>
339+
310340
<InfoSection />
311341
</div>
312342
);

apps/obsidian/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export type Settings = {
6969
syncModeEnabled?: boolean;
7070
/** Maps spaceUri (e.g. "obsidian:abc123") to human-readable name (e.g. "My Vault") */
7171
spaceNames?: Record<string, string>;
72+
username?: string;
7273
};
7374

7475
export type BulkImportCandidate = {

apps/obsidian/src/utils/supabaseContext.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const getSupabaseContext = async (
7777
if (contextCache === null) {
7878
try {
7979
const vaultName = plugin.app.vault.getName() || "obsidian-vault";
80+
const username = plugin.settings.username || vaultName;
8081

8182
const spacePassword = await getOrCreateSpacePassword(plugin);
8283
const accountLocalId = await getOrCreateAccountLocalId(plugin, vaultName);
@@ -100,8 +101,8 @@ export const getSupabaseContext = async (
100101
const userId = await fetchOrCreatePlatformAccount({
101102
platform: "Obsidian",
102103
accountLocalId,
103-
name: vaultName,
104-
email: accountLocalId,
104+
name: username,
105+
email: undefined,
105106
spaceId,
106107
password: spacePassword,
107108
});

0 commit comments

Comments
 (0)