Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwi committed Jan 27, 2024
1 parent a22fc4a commit 1da990b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion public/full.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ function setupAddressModal() {
addressModal.addEventListener('show.bs.modal', event => {
const button = event.relatedTarget

// TODO: consider getting the address object from __addressData? Addresses currently have no id in API response, so we have to search
// TODO: consider getting the address object from __addressData rather than attributes? Addresses currently have no id in API response, so we have to search a bit
updateAddressModal({
name: button.getAttribute('data-bs-name'),
display_name: button.getAttribute('data-bs-display-name'),
Expand Down Expand Up @@ -919,12 +919,29 @@ function updateAddressModal(address) {
const addressDisplayName = addressModal.querySelector('.modal-body .address-display-name')
const addressAvatar = addressModal.querySelector('.modal-body .address-avatar')
const addressBadge = addressModal.querySelector('.modal-body .address-badge')
const channelButtons = {
messaging: addressModal.querySelector('.modal-body .btn-address-dial-audio'),
video: addressModal.querySelector('.modal-body .btn-address-dial-video'),
audio: addressModal.querySelector('.modal-body .btn-address-dial-messaging')
};

addressDisplayName.textContent = address.display_name
addressBadge.textContent = address.type
addressAvatar.src = address.cover_url || address.preview_url || `https://i.pravatar.cc/125?u=${address.resource_id}`

// TODO: disable all the buttons first

// TODO: wire up channel dial buttons
// Object.entries(address.channels).forEach(([channelName, channelValue]) => {
// let clone = channelButtons[channelName].cloneNode(true);
// clone.addEventListener('click', () => {
// alert(channelName + ': ' + channelValue);
// dialAddress(channelValue);
// $(addressModal).modal('hide');
// });
// button.parentNode.replaceChild(clone, button);
// })

}

function updateAddressUI() {
Expand Down
6 changes: 3 additions & 3 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,15 @@
</div>
</div>
<div class="address-channels-buttons mt-3">
<button>
<button class="btn btn-address-dial-audio">
<i class="bi bi-phone"></i>
Call
</button>
<button>
<button class="btn btn-address-dial-video">
<i class="bi bi-camera-video"></i>
Video
</button>
<button>
<button class="btn btn-address-dial-messaging">
<i class="bi bi-chat"></i>
Chat
</button>
Expand Down

0 comments on commit 1da990b

Please sign in to comment.