reactivitey for editability for note editing.
This commit is contained in:
@@ -18,7 +18,7 @@ export const NotepadView: Component<{
|
||||
const [isLinking, setIsLinking] = createSignal(false);
|
||||
const [linkSearchQuery, setLinkSearchQuery] = createSignal("");
|
||||
|
||||
const currentUserId = pb.authStore.model?.id;
|
||||
const currentUserId = () => pb.authStore.model?.id;
|
||||
|
||||
// Derived states
|
||||
const activeNote = createMemo(() => {
|
||||
@@ -159,8 +159,8 @@ export const NotepadView: Component<{
|
||||
</div>
|
||||
}>
|
||||
{(note) => {
|
||||
const isOwner = note().user === currentUserId;
|
||||
const canEdit = isOwner || !note().isPrivate;
|
||||
const isOwner = () => note().user === currentUserId();
|
||||
const canEdit = () => isOwner() || !note().isPrivate;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -180,14 +180,14 @@ export const NotepadView: Component<{
|
||||
class="text-3xl sm:text-4xl font-black tracking-tight bg-transparent border-none outline-none focus:ring-0 flex-1 placeholder:text-muted-foreground/30 px-0 min-w-0"
|
||||
value={note().title}
|
||||
placeholder="Note Title"
|
||||
readOnly={!canEdit}
|
||||
readOnly={!canEdit()}
|
||||
onBlur={(e) => {
|
||||
const val = e.currentTarget.value.trim() || 'Untitled';
|
||||
if (val !== note().title) handleRenameNote(note().id, note().title, val);
|
||||
}}
|
||||
/>
|
||||
<div class="flex items-center gap-2 shrink-0 pt-1">
|
||||
<Show when={isOwner}>
|
||||
<Show when={isOwner()}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@@ -200,7 +200,7 @@ export const NotepadView: Component<{
|
||||
</Button>
|
||||
</Show>
|
||||
|
||||
<Show when={isOwner}>
|
||||
<Show when={isOwner()}>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
@@ -220,7 +220,7 @@ export const NotepadView: Component<{
|
||||
<TaskEditor
|
||||
content={note().content}
|
||||
onUpdate={(html) => handleUpdateContent(note().id, html)}
|
||||
editable={canEdit}
|
||||
editable={canEdit()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user