This commit is contained in:
Andrew Gundersen 2022-01-18 16:58:56 -06:00
commit 5d74c67648
17 changed files with 101 additions and 212 deletions

View file

@ -1,4 +1,5 @@
import initScroll from "./control/scroll.js";
import onDrop from "./control/drop.js";
import adjustScroll from "./control/scroll.js";
import WS from "./ws.js";
import Input from "./input.js";
@ -17,62 +18,32 @@ const Messenger = {
setup()
{
const person = Vue.ref("");
const messages = Vue.ref([{
modifier: "ai",
content: [{
category: "text/html",
text: `<div class="mail">
<h4>About HTML Parser</h4>
<p>Return the text of the most recently opened start tag. This should not normally be needed for structured processing, but may be useful in dealing with HTML “as deployed” or for re-generating input with minimal changes (whitespace between attributes can be preserved, etc.).</p>
</div>`,
blob: null
}],
context: "Email from David Spade",
avatar: null,
id: 0
}]);
const onDrop = async (e) => {
const file = e.dataTransfer.items[0].getAsFile();
const buffer = await file.arrayBuffer();
const b64String = await window.mainApi.invoke("encode", buffer);
window.mainApi.send("message", {
category: file.type,
text: file.name,
blob: b64String
});
}
const messages = Vue.ref([]);
Vue.onMounted(() => {
window.mainApi.on("message", (message) => {
if (message.person)
window.mainApi.on("update", (update) => {
if (update.name)
{
person.value = message.person;
messages.value = message.messages;
person.value = update;
}
else if (message.name)
else if (typeof update == Array)
{
person.value = message;
messages.value.push(...update);
}
else if (message.content)
{
messages.value.push(message);
messages.value.push(update);
}
else
else if (update.new)
{
messages.value[messages.value.length - 1].content.push(message);
messages.value.at(-1)[update.new] = update.val;
}
});
initScroll("messenger");
window.mainApi.send("messenger");
});
Vue.onUnmounted(() => {
messages.value = [];
window.mainApi.send("message", "win");
});
return { person, messages, onDrop };