mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
fix(client/dialogs): branch prefix initial value incorrect
This commit is contained in:
parent
b502e999de
commit
ae46798d1d
@ -14,7 +14,7 @@ import FBranch from "../../entities/fbranch.js";
|
|||||||
export default function BranchPrefixDialog() {
|
export default function BranchPrefixDialog() {
|
||||||
const [ shown, setShown ] = useState(false);
|
const [ shown, setShown ] = useState(false);
|
||||||
const [ branch, setBranch ] = useState<FBranch>();
|
const [ branch, setBranch ] = useState<FBranch>();
|
||||||
const [ prefix, setPrefix ] = useState(branch?.prefix ?? "");
|
const [ prefix, setPrefix ] = useState("");
|
||||||
const branchInput = useRef<HTMLInputElement>(null);
|
const branchInput = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
useTriliumEvent("editBranchPrefix", async () => {
|
useTriliumEvent("editBranchPrefix", async () => {
|
||||||
@ -32,13 +32,15 @@ export default function BranchPrefixDialog() {
|
|||||||
const newBranchId = await froca.getBranchId(parentNoteId, noteId);
|
const newBranchId = await froca.getBranchId(parentNoteId, noteId);
|
||||||
if (!newBranchId) {
|
if (!newBranchId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const parentNote = await froca.getNote(parentNoteId);
|
const parentNote = await froca.getNote(parentNoteId);
|
||||||
if (!parentNote || parentNote.type === "search") {
|
if (!parentNote || parentNote.type === "search") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setBranch(froca.getBranch(newBranchId));
|
const newBranch = froca.getBranch(newBranchId);
|
||||||
|
setBranch(newBranch);
|
||||||
|
setPrefix(newBranch?.prefix ?? "");
|
||||||
setShown(true);
|
setShown(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -77,4 +79,4 @@ export default function BranchPrefixDialog() {
|
|||||||
async function savePrefix(branchId: string, prefix: string) {
|
async function savePrefix(branchId: string, prefix: string) {
|
||||||
await server.put(`branches/${branchId}/set-prefix`, { prefix: prefix });
|
await server.put(`branches/${branchId}/set-prefix`, { prefix: prefix });
|
||||||
toast.showMessage(t("branch_prefix.branch_prefix_saved"));
|
toast.showMessage(t("branch_prefix.branch_prefix_saved"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user