forked from snxraven/LinkUp-P2P-Chat
fix
This commit is contained in:
parent
b62636ed0e
commit
184edb8b44
16
app.js
16
app.js
@ -50,10 +50,12 @@ async function initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const savedUser = localStorage.getItem('currentUser');
|
const savedUser = localStorage.getItem('currentUser');
|
||||||
|
const avatarURL = localStorage.getItem('avatarURL');
|
||||||
|
|
||||||
if (savedUser) {
|
if (savedUser) {
|
||||||
const user = JSON.parse(savedUser);
|
const user = JSON.parse(savedUser);
|
||||||
userName = user.username;
|
userName = user.username;
|
||||||
userAvatar = user.avatar || '';
|
userAvatar = avatarURL || '';
|
||||||
const setupDiv = document.querySelector('#setup');
|
const setupDiv = document.querySelector('#setup');
|
||||||
if (setupDiv) {
|
if (setupDiv) {
|
||||||
setupDiv.classList.remove('hidden');
|
setupDiv.classList.remove('hidden');
|
||||||
@ -235,13 +237,7 @@ function sendMessage(e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollToBottom() {
|
|
||||||
var container = document.getElementById("messages-container");
|
|
||||||
container.scrollTop = container.scrollHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMessageAdded(from, message, avatar) {
|
function onMessageAdded(from, message, avatar) {
|
||||||
|
|
||||||
const $div = document.createElement('div');
|
const $div = document.createElement('div');
|
||||||
$div.classList.add('message');
|
$div.classList.add('message');
|
||||||
|
|
||||||
@ -260,16 +256,14 @@ function onMessageAdded(from, message, avatar) {
|
|||||||
$text.classList.add('message-text');
|
$text.classList.add('message-text');
|
||||||
|
|
||||||
// Render Markdown content
|
// Render Markdown content
|
||||||
const md = window.markdownit();
|
const markdownContent = marked(message);
|
||||||
$text.innerHTML = md.render(message);
|
$text.innerHTML = markdownContent;
|
||||||
|
|
||||||
$content.appendChild($header);
|
$content.appendChild($header);
|
||||||
$content.appendChild($text);
|
$content.appendChild($text);
|
||||||
$div.appendChild($content);
|
$div.appendChild($content);
|
||||||
|
|
||||||
document.querySelector('#messages').appendChild($div);
|
document.querySelector('#messages').appendChild($div);
|
||||||
scrollToBottom();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
async function updateIcon(username, avatarBuffer) {
|
async function updateIcon(username, avatarBuffer) {
|
||||||
// Update the icon in the local HTML if necessary
|
// Update the icon in the local HTML if necessary
|
||||||
|
Loading…
Reference in New Issue
Block a user