Spaces:
Running
Running
File size: 724 Bytes
e6addfc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import type { Message } from "$lib/types/Message";
import { getContext, setContext } from "svelte";
import { writable, type Writable } from "svelte/store";
// used to store the id of the message that is the currently displayed leaf of the conversation tree
// (that is the last message in the current branch of the conversation tree)
interface ConvTreeStore {
leaf: Message["id"] | null;
editing: Message["id"] | null;
}
export function useConvTreeStore() {
return getContext<Writable<ConvTreeStore>>("convTreeStore");
}
export function createConvTreeStore() {
const convTreeStore = writable<ConvTreeStore>({
leaf: null,
editing: null,
});
setContext("convTreeStore", convTreeStore);
return convTreeStore;
}
|