reverting changes in polish manually
This commit is contained in:
parent
664a9d06f9
commit
fb14847730
6 changed files with 60 additions and 20 deletions
|
|
@ -38,3 +38,6 @@ window.mainApi.on("set-account", (account_) => {
|
|||
|
||||
export default App;
|
||||
export { account };
|
||||
|
||||
// Is called when window is about to close or reload
|
||||
window.onbeforeunload = () => console.log("beforeunload");
|
||||
|
|
@ -9,7 +9,7 @@ const Bubble =
|
|||
}
|
||||
|
||||
Vue.onMounted(() => {
|
||||
document.dispatchEvent(new CustomEvent("scroll"));
|
||||
document.getElementById("messenger").dispatchEvent(new CustomEvent('adjust-scroll'));
|
||||
});
|
||||
|
||||
return { getUrl };
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@ const initScroll = (elementId) => {
|
|||
}
|
||||
|
||||
const isBottom = () => {
|
||||
return el.scrollHeight - el.clientHeight <= el.scrollTop + 1;
|
||||
if (el) {
|
||||
return el.scrollHeight - el.clientHeight <= el.scrollTop + 1;
|
||||
}
|
||||
}
|
||||
|
||||
const adjustScroll = () => {
|
||||
if (isBottom()) {
|
||||
if (el) {
|
||||
el.scrollTo({
|
||||
top: el.scrollHeight - el.clientHeight,
|
||||
behavior: 'smooth'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import onDrop from "./control/drop.js";
|
||||
import adjustScroll from "./control/scroll.js";
|
||||
import initScroll from "./control/scroll.js";
|
||||
|
||||
import WS from "./ws.js";
|
||||
import Input from "./input.js";
|
||||
|
|
@ -22,24 +22,34 @@ const Messenger = {
|
|||
|
||||
Vue.onMounted(() => {
|
||||
|
||||
window.mainApi.on("update", (update) => {
|
||||
window.mainApi.on("message", (update) => {
|
||||
|
||||
if (update.name)
|
||||
if (update.person)
|
||||
{
|
||||
person.value = update.person;
|
||||
messages.value = update.messages;
|
||||
}
|
||||
else if (update.name)
|
||||
{
|
||||
person.value = update;
|
||||
}
|
||||
else if (message.content)
|
||||
else if (update.content)
|
||||
{
|
||||
messages.value.push(update);
|
||||
}
|
||||
else
|
||||
{
|
||||
messages.value.at(-1).content.push(update);
|
||||
messages.value[messages.value.length - 1].content.push(update);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
window.mainApi.send("message", {route: "window", open: true});
|
||||
initScroll("messenger");
|
||||
window.mainApi.send("messenger");
|
||||
});
|
||||
|
||||
Vue.onUnmounted(() => {
|
||||
messages.value = [];
|
||||
});
|
||||
|
||||
return { person, messages, onDrop };
|
||||
|
|
@ -67,6 +77,3 @@ const Messenger = {
|
|||
}
|
||||
|
||||
export default Messenger;
|
||||
|
||||
// Is called when window is about to close or reload
|
||||
window.onbeforeunload = () => window.mainApi.send("message", {route: "window", open: true});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const { contextBridge, ipcRenderer } = require("electron");
|
|||
|
||||
const validFromMainChannels = [
|
||||
"set-account",
|
||||
"update",
|
||||
"message",
|
||||
"ws-status",
|
||||
"record",
|
||||
"playback"
|
||||
|
|
|
|||
|
|
@ -5,13 +5,22 @@ const { backgroundMitt, ipcEmit } = require("./utils/emitter");
|
|||
const { connectToPlatform, disconnectFromPlatform } = require("./io");
|
||||
const { initAudio, terminateAudio, playback, streamState } = require("./audio");
|
||||
|
||||
let ui;
|
||||
|
||||
const messageQueue = [];
|
||||
|
||||
let processContentId;
|
||||
|
||||
/* Possible messages:
|
||||
* - New UI (set ui)
|
||||
* - New message (add message to ui.messages)
|
||||
* - New content (add content to existing message)
|
||||
* - Update person
|
||||
* - Notification
|
||||
*/
|
||||
backgroundMitt.on("message", (message) => messageQueue.push(message));
|
||||
|
||||
function handleUpdateQueue()
|
||||
function handleMessageQueue()
|
||||
{
|
||||
if (!streamState.pb && !streamState.rec)
|
||||
{
|
||||
|
|
@ -19,15 +28,28 @@ function handleUpdateQueue()
|
|||
|
||||
if (update)
|
||||
{
|
||||
if (update.title)
|
||||
if (update.person)
|
||||
{
|
||||
new Notification(update).show();
|
||||
ui = update;
|
||||
}
|
||||
else if (update.audio)
|
||||
else if (update.name)
|
||||
{
|
||||
playback(update);
|
||||
ui.person = update;
|
||||
}
|
||||
else { ipcEmit("update", update); }
|
||||
else if (update.content)
|
||||
{
|
||||
ui.messages.push(update);
|
||||
}
|
||||
else if (update.category)
|
||||
{
|
||||
ui.messages[ui.messages.length - 1].content.push(update);
|
||||
}
|
||||
else
|
||||
{
|
||||
new Notification(update).show(); return;
|
||||
}
|
||||
|
||||
ipcEmit("message", update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +58,7 @@ function launchSession(account)
|
|||
{
|
||||
connectToPlatform(account);
|
||||
// initAudio();
|
||||
processContentId = setInterval(handleUpdateQueue, 100);
|
||||
processContentId = setInterval(handleMessageQueue, 100);
|
||||
}
|
||||
|
||||
function endSession()
|
||||
|
|
@ -46,5 +68,11 @@ function endSession()
|
|||
disconnectFromPlatform();
|
||||
}
|
||||
|
||||
ipcMain.on("messenger", () => {
|
||||
if (ui) {
|
||||
ipcEmit("message", ui);
|
||||
}
|
||||
});
|
||||
|
||||
exports.launchSession = launchSession;
|
||||
exports.endSession = endSession;
|
||||
|
|
|
|||
Loading…
Reference in a new issue