note-linked tasks are now efficient
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { type Component, createSignal, For, createEffect } from "solid-js";
|
||||
import { store, upsertTagDefinition, isCurrentUserContextTag, setContextPolicy } from "@/store";
|
||||
import { store, upsertTagDefinition, isCurrentUserContextTag, setContextPolicy, setNoteContextPolicy, getNoteSharePolicy } from "@/store";
|
||||
import { useTheme } from "./ThemeProvider";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -55,6 +55,14 @@ export const TagPicker: Component<TagPickerProps> = (props) => {
|
||||
) || null;
|
||||
};
|
||||
|
||||
const selectedNoteContext = () => {
|
||||
const name = selectedTagName().trim();
|
||||
if (!name.startsWith("#")) return null;
|
||||
|
||||
const key = normalizeNoteKey(name);
|
||||
return store.notes.find(note => !note.deletedAt && note.key === key) || null;
|
||||
};
|
||||
|
||||
// When a tag name is selected, update the value score to match its current definition
|
||||
createEffect(() => {
|
||||
const name = selectedTagName().trim();
|
||||
@@ -72,7 +80,12 @@ export const TagPicker: Component<TagPickerProps> = (props) => {
|
||||
setShareMode(context.policy);
|
||||
return;
|
||||
}
|
||||
if (selectedTagName().trim().startsWith("@")) {
|
||||
const note = selectedNoteContext();
|
||||
if (note) {
|
||||
setShareMode(getNoteSharePolicy(note));
|
||||
return;
|
||||
}
|
||||
if (selectedTagName().trim().startsWith("@") || selectedTagName().trim().startsWith("#")) {
|
||||
setShareMode("handoff");
|
||||
}
|
||||
});
|
||||
@@ -82,6 +95,7 @@ export const TagPicker: Component<TagPickerProps> = (props) => {
|
||||
if (!name) return;
|
||||
|
||||
const context = selectedShareContext();
|
||||
const noteContext = selectedNoteContext();
|
||||
|
||||
if (name.startsWith("@")) {
|
||||
const normalized = normalizeContextKey(name);
|
||||
@@ -108,6 +122,11 @@ export const TagPicker: Component<TagPickerProps> = (props) => {
|
||||
toast.error("Create the canonical note first before linking it with a #tag.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (noteContext && getNoteSharePolicy(noteContext) !== shareMode()) {
|
||||
const updated = await setNoteContextPolicy(noteContext.id, shareMode());
|
||||
if (!updated) return;
|
||||
}
|
||||
}
|
||||
|
||||
// update global definition
|
||||
@@ -167,7 +186,7 @@ export const TagPicker: Component<TagPickerProps> = (props) => {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{selectedTagName().trim().startsWith("@") && (
|
||||
{(selectedTagName().trim().startsWith("@") || selectedTagName().trim().startsWith("#")) && (
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-[0.625rem] font-bold uppercase tracking-wider text-muted-foreground">Share Mode</label>
|
||||
<div class="bg-background border border-border p-1 rounded-xl flex items-center shadow-sm relative min-w-[160px] h-10">
|
||||
|
||||
Reference in New Issue
Block a user