mirror of
https://github.com/open-webui/open-webui
synced 2025-02-18 19:08:42 +00:00
refac: click to focus on mesage node
This commit is contained in:
parent
c89bb01db9
commit
732f730213
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
export let history;
|
export let history;
|
||||||
|
|
||||||
|
let selectedMessageId = null;
|
||||||
|
|
||||||
const nodes = writable([]);
|
const nodes = writable([]);
|
||||||
const edges = writable([]);
|
const edges = writable([]);
|
||||||
|
|
||||||
@ -34,10 +36,17 @@
|
|||||||
drawFlow();
|
drawFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (history?.currentId) {
|
$: if (history && history.currentId) {
|
||||||
fitView({ nodes: [{ id: history.currentId }] });
|
focusNode();
|
||||||
|
selectedMessageId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const focusNode = async () => {
|
||||||
|
if (selectedMessageId === null) {
|
||||||
|
await fitView({ nodes: [{ id: history.currentId }] });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const drawFlow = async () => {
|
const drawFlow = async () => {
|
||||||
const nodeList = [];
|
const nodeList = [];
|
||||||
const edgeList = [];
|
const edgeList = [];
|
||||||
@ -168,6 +177,8 @@
|
|||||||
on:nodeclick={(e) => {
|
on:nodeclick={(e) => {
|
||||||
console.log(e.detail.node.data);
|
console.log(e.detail.node.data);
|
||||||
dispatch('nodeclick', e.detail);
|
dispatch('nodeclick', e.detail);
|
||||||
|
selectedMessageId = e.detail.node.data.message.id;
|
||||||
|
fitView({ nodes: [{ id: selectedMessageId }] });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user