});
+ if (!props.text) props.text = "...";
+
return { getUrl };
},
let el;
-const initScroll = (elementId) => {
- el = document.getElementById(elementId);
- el.addEventListener('adjust-scroll', adjustScroll);
- window.addEventListener('resize', adjustScroll);
-}
-
-const isBottom = () => {
- if (el) {
- return el.scrollHeight - el.clientHeight <= el.scrollTop + 1;
- }
-}
-
-const adjustScroll = () => {
- if (el) {
+const scroll = () => {
+ if (!el) {
+ el = document.getElementById("messenger");
+ window.addEventListener('resize', scroll);
+ }
el.scrollTo({
top: el.scrollHeight - el.clientHeight,
behavior: 'smooth'
});
- }
}
-export default initScroll;
\ No newline at end of file
+export default scroll;
+
+// const isBottom = () => {
+// if (el) {
+// return el.scrollHeight - el.clientHeight <= el.scrollTop + 1;
+// }
+// }
\ No newline at end of file
import onDrop from "./control/drop.js";
-import initScroll from "./control/scroll.js";
+import scroll from "./control/scroll.js";
import WS from "./ws.js";
import Input from "./input.js";
const person = Vue.ref("");
const messages = Vue.ref([]);
+ let current = Vue.ref();
+
Vue.onMounted(() => {
window.mainApi.on("message", (update) => {
{
person.value = update.person;
messages.value = update.messages;
+ current.value = messages.value.at(-1);
}
else if (update.name)
{
}
else if (update.modifier)
{
- messages.value.push(update);
+ messages.value.push(update);
+ current.value = update;
+ }
+ else if (update.category)
+ {
+ current.value.content.push(update);
+ }
+ else if (update.context)
+ {
+ current.value.context = update.context;
}
else
{
- messages.at(-1).content.push(update);
+ current.value.content.at(-1).text = update.text;
}
+
+ setTimeout(scroll, 10);
});
- initScroll("messenger");
window.mainApi.send("messenger");
});
- const search = (id) => messages.value.find(m => m.id == id);
-
return { person, messages, onDrop };
},
v-bind="message"
/>
- </div> `
+ </div>`
}
export default Messenger;
const { initAudio, terminateAudio, playback, streamState } = require("./audio");
const util = require('util');
+
let ui;
+let current;
const messageQueue = [];
const update = messageQueue.shift();
if (update)
- {
+ {
+ console.log(update);
+
if (update.person)
{
- ui = update;
+ ui = update; current = update.messages.at(-1);
}
else if (update.name)
{
}
else if (update.modifier)
{
- ui.messages.push(update);
+ ui.messages.push(update); current = update;
}
else if (update.category)
{
- ui.messages.at(-1).content.push(update)
+ current.content.push(update);
}
- else if (update.title)
+ else if (update.context)
{
- new Notification(update).show(); return;
+ current.context = update.context;
+ }
+ else if (update.text)
+ {
+ current.content.at(-1).text = update.text;
+ }
+ else
+ {
+ const content = current.content.at(-1);
+
+ new Notification({
+ title: current.context,
+ body: content.text
+ }).show();
+
+ if (content.category == "audio")
+ {
+ playback(current.id, content.blob);
+ }
+
+ return;
}
- else playback(...update); return;
ipcEmit("message", update);
}