Skip to content

Commit

Permalink
add resizable chat
Browse files Browse the repository at this point in the history
  • Loading branch information
nglmercer committed Dec 16, 2024
1 parent 8fdb84d commit c7dab8c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
18 changes: 0 additions & 18 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,6 @@ class TiktokConnection extends PlatformConnection {
}

initializeEventHandlers(socket, platform, uniqueId) {
// Only initialize if not already initialized or if platform/uniqueId combination is new
const handlerKey = `${platform}_${uniqueId}`;
if (this.eventHandlersInitialized && this.lastHandlerKey === handlerKey) return;

this.lastHandlerKey = handlerKey;
this.eventHandlersInitialized = false; // Reset to allow re-initialization

tiktokLiveEvents.forEach(event => {
// Remove previous listeners
this.tiktokLiveConnection.removeAllListeners(event);
Expand Down Expand Up @@ -278,22 +271,13 @@ class KickConnection extends PlatformConnection {
}

initializeEventHandlers(socket, platform, uniqueId) {
// Only initialize if not already initialized or if platform/uniqueId combination is new
const handlerKey = `${platform}_${uniqueId}`;
if (this.eventHandlersInitialized && this.lastHandlerKey === handlerKey) return;

this.lastHandlerKey = handlerKey;

// Unbind previous event listeners if they exist
LiveEvents.forEach(event => {
// Use standard event unbinding if possible
if (this.kickliveconnector.off) {
this.kickliveconnector.off(event);
}
});

this.eventHandlersInitialized = false;

LiveEvents.forEach(event => {
this.kickliveconnector.on(event, (data) => {
socket.emit(event, data); // Emit directly to the socket
Expand All @@ -303,8 +287,6 @@ class KickConnection extends PlatformConnection {
}
});
});

this.eventHandlersInitialized = true;
}
disconnect() {
if (this.kickliveconnector) {
Expand Down
3 changes: 3 additions & 0 deletions src/public/components/webcomponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -6505,7 +6505,10 @@ class MessageContainer extends HTMLElement {
:host {
display: block;
width: 100%;
height: 100%;
position: relative;
resize: both;
overflow: hidden;
}
.messages-wrapper {
position: relative;
Expand Down
6 changes: 3 additions & 3 deletions src/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ <h2>Chat</h2>
<div class="containerbox relative">
<div class="LiveContainer">
<div id="chat-container" class="chat1 chatcontainer">
<message-container id="chatcontainer" wrapper-classes="maxh-15rem"></message-container>
<message-container id="chatcontainer" wrapper-classes="maxh-20rem"></message-container>
</div>
<div class="gift2 giftcontainer">
<message-container id="giftcontainer" wrapper-classes="maxh-15rem"></message-container>
<message-container id="giftcontainer" wrapper-classes="maxh-20rem"></message-container>
</div>
<div class="events3 eventscontainer">
<message-container id="eventscontainer" wrapper-classes="maxh-5rem"></message-container>
<message-container id="eventscontainer" wrapper-classes="maxh-10rem"></message-container>
</div>
<audio-player></audio-player>
<div id="chatbotconfig" class="grid grid-cols-2 gap-4"></div>
Expand Down

0 comments on commit c7dab8c

Please sign in to comment.