Skip to content

Commit

Permalink
Merge pull request #50 from signalwire/aa/live-msg
Browse files Browse the repository at this point in the history
Conversation logs UI update
  • Loading branch information
iAmmar7 authored Feb 16, 2024
2 parents 3d37c2e + 0143ff5 commit 02acbf3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
27 changes: 24 additions & 3 deletions public/full.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const inCallElements = [
unmuteVideoSelfBtn,
deafSelfBtn,
undeafSelfBtn,
controlConvo,
controlSliders,
controlLayout,
hideVMutedBtn,
Expand Down Expand Up @@ -346,7 +345,6 @@ function restoreUI() {
btnReject.classList.add('d-none')
tabs.classList.remove('d-none')
connectStatus.innerHTML = 'Not Connected'
liveMessageList.textContent = ''

inCallElements.forEach((button) => {
button.classList.add('d-none')
Expand Down Expand Up @@ -1124,6 +1122,29 @@ async function fetchHistories() {
}
}

function createLiveMessageListItem(msg) {
const listItem = document.createElement('li')
listItem.classList.add('list-group-item')
listItem.id = msg.id
const formattedTimestamp = formatMessageDate(msg.ts * 1000)
listItem.innerHTML = `
<div class="d-flex flex-column">
<div class="d-flex justify-content-between align-items-center">
<div>
<h6 class="mb-0 text-capitalize">${msg.type ?? 'unknown'}</h6>
<p class="mb-1 fst-italic">${msg.conversation_name}</p>
<div>
<div class="d-flex align-items-center gap-1">
<span class="badge bg-info">${msg.subtype ?? 'unknown'}</span>
<span class="badge bg-success">${msg.kind ?? 'unknown'}</span>
</div>
</div>
<p class="text-muted small mb-0">${formattedTimestamp}</p>
</div>
`
return listItem
}

let isConvoSubscribed = false
function subscribeToNewMessages() {
if (!isConvoSubscribed) {
Expand Down Expand Up @@ -1151,7 +1172,7 @@ function subscribeToNewMessages() {
// Update in call live messages
// FIXME: Make sure the message is for the current call based on newMsg.conversation_id
const liveMessageList = document.querySelector('#liveMessageList')
const newListItem = createMessageListItem(newMsg)
const newListItem = createLiveMessageListItem(newMsg)
if (liveMessageList.firstChild) {
liveMessageList.insertBefore(newListItem, liveMessageList.firstChild)
} else {
Expand Down
30 changes: 15 additions & 15 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@
</div>
</div>
<!-- Room controls end -->

<!-- Conversation logs -->
<div id="controlConvo" class="row py-2 px-2">
<div class="card p-0">
<div class="card-header">
Conversation logs
</div>
<div class="card-body px-0 py-1">
<div class="overflow-auto" style="max-height: 200px; min-height: 100px;">
<ul id="liveMessageList" class="list-group list-group-flush mt-0"></ul>
</div>
</div>
</div>
</div>
<!-- Conversation logs end -->
</div>
<!-- Connect options end -->

Expand Down Expand Up @@ -242,21 +257,6 @@
</div>
<!-- Root element (for SDK video) end -->

<!-- Conversation logs -->
<div id="controlConvo" class="row py-2 px-2 d-none">
<div class="card p-0">
<div class="card-header">
Conversation logs
</div>
<div class="card-body px-0 py-1">
<div class="overflow-auto" style="max-height: 200px;">
<ul id="liveMessageList" class="list-group list-group-flush mt-0"></ul>
</div>
</div>
</div>
</div>
<!-- Conversation logs end -->

<!-- Mic/Speaker volume controls -->
<div id="controlSliders" class="row py-2 d-none">
<div class="col-4">
Expand Down

0 comments on commit 02acbf3

Please sign in to comment.