more updates

This commit is contained in:
Andrew Gundersen 2021-06-28 11:32:45 -05:00
commit af421e6bfb
7 changed files with 60 additions and 67 deletions

View file

@ -5,39 +5,55 @@ import useScroll from "@/render/composables/useScroll";
export const messages: Ref<Array<Message>> = ref([]);
export const setMessages: IpcListenerCallback<Array<Message>> = (payload) => {
// messages.value = payload as Array<Message>;
console.log("setMessages", payload);
messages.value = payload as Array<Message>;
}
export const addMessage: IpcListenerCallback<Message> = (payload) => {
console.log("addMessage", payload);
messages.value.push(payload as Message);
}
export const updateMessage: IpcListenerCallback<Annotation> = (payload) => {
console.log("updateMessage", payload);
const annotation = payload as Annotation;
/* find the target message */
let targetMessage = messages.value.filter((m: Message) => {
return m.uid === annotation.uid;
})[0];
if (targetMessage) {
targetMessage.content = annotation.content;
targetMessage.context = annotation.context;
/* update the content (add a new bubble) */
if (annotation.data.hasOwnProperty("content")) {
const data = annotation.data as ContentData;
targetMessage.content = data.content;
}
/* and/or update the context */
if (annotation.data.hasOwnProperty("context")) {
const data = annotation.data as ContextData;
targetMessage.context = data.context;
}
}
}
messages.value = [
{
content: ["Welcome Andrew"],
context: "Crimata",
modifier: "ai",
uid: "b5dd3d1b-cef0-4057-aa0f-c72e5c4cd67d"
},
{
content: ["show contacts"],
context: "show contacts",
modifier: "client",
uid: "ee2819a3-1125-4881-9942-ca5b3d0ad502"
}]
// messages.value = [
// {
// content: ["Welcome Andrew"],
// context: "Crimata",
// modifier: "ai",
// uid: "b5dd3d1b-cef0-4057-aa0f-c72e5c4cd67d"
// },
// {
// content: ["show contacts"],
// context: "false",
// modifier: "client",
// uid: "ee2819a3-1125-4881-9942-ca5b3d0ad502"
// }]
// setTimeout(() => {
@ -52,10 +68,3 @@ messages.value = [
// }, 2000);
export default {
messages,
setMessages,
addMessage,
updateMessage
};