removed bubble chat from rooms

This commit is contained in:
defnax 2026-07-06 20:50:20 +02:00
parent 4742a87040
commit f6a9dbef41
2 changed files with 82 additions and 2 deletions

View File

@ -56,6 +56,16 @@ function sortLobbies(lobbies) {
return []; // return empty array instead of undefined
}
function getNicknameColor(id, name) {
const hashString = id && id !== '00000000000000000000000000000000' ? id : (name || '');
let hash = 0;
for (let i = 0; i < hashString.length; i++) {
hash = hashString.charCodeAt(i) + ((hash << 5) - hash);
}
const hue = Math.abs(hash) % 360;
return `hsl(${hue}, 75%, 35%)`;
}
// ***************************** models ***********************************
const MobileState = {
@ -191,6 +201,20 @@ const Message = () => {
const text = (msg.msg || msg.message || '')
.replaceAll('<br/>', '\n')
.replace(new RegExp('<style[^<]*</style>|<[^>]*>', 'gm'), '');
const chatType = ChatLobbyModel.currentLobby && ChatLobbyModel.currentLobby.chatType;
const isRoom = chatType === 3;
if (isRoom) {
const nickColor = getNicknameColor(gxsId, username);
return m(
'.message.compact',
m('span.datetime', datetime),
m('span.username', { style: { color: nickColor } }, username + ':'),
m('span.messagetext', text)
);
}
return m(
'.message' + (msg.incoming ? '.incoming' : '.outgoing'),
m('span.datetime', datetime),
@ -637,10 +661,12 @@ const ChatConversationView = () => {
scrollChatToBottom();
},
view: () => {
const chatType = ChatLobbyModel.currentLobby && ChatLobbyModel.currentLobby.chatType;
const isRoom = chatType === 3;
return m('.chat-hub-conversation-layout', [
m('.chat-hub-conversation-main', [
m(
'.chat-hub-messages',
'.chat-hub-messages' + (isRoom ? '.compact-container' : ''),
{
oncreate: () => scrollChatToBottom(),
onupdate: () => scrollChatToBottom(),
@ -1036,6 +1062,7 @@ const LayoutSingle = () => {
view: (vnode) => {
const chatType = ChatLobbyModel.currentLobby.chatType;
const isPrivate = chatType === 1 || chatType === 2;
const isRoom = chatType === 3;
return m(
'.node-panel.chat-panel.chat-room',
{
@ -1046,7 +1073,11 @@ const LayoutSingle = () => {
},
[
m('.chat-overlay', { onclick: () => MobileState.closeAll() }),
m('.messages', { onclick: () => MobileState.closeAll() }, ChatLobbyModel.messages),
m(
'.messages' + (isRoom ? '.compact-container' : ''),
{ onclick: () => MobileState.closeAll() },
ChatLobbyModel.messages
),
m(
'.chatMessage',
{},

View File

@ -1064,4 +1064,53 @@ textarea.chatMsg {
gap: 0.5rem;
border-radius: 0.375rem;
}
/* Compact Room Chat Style (No bubbles, unique nickname colors) */
.chat-hub-messages.compact-container,
.messages.compact-container {
gap: 0.25rem !important;
padding: 0.75rem 1rem !important;
background-color: #ffffff !important;
display: flex !important;
flex-direction: column !important;
.message.compact {
display: block !important;
max-width: 100% !important;
padding: 0.15rem 0 !important;
border-radius: 0 !important;
background-color: transparent !important;
border: none !important;
box-shadow: none !important;
align-self: flex-start !important;
font-size: 0.9rem !important;
line-height: 1.4 !important;
margin: 0 !important;
.datetime {
color: #808080 !important;
margin-right: 0.5rem !important;
font-size: 0.8rem !important;
font-family: monospace !important;
opacity: 1 !important;
display: inline-block !important;
}
.username {
font-weight: bold !important;
margin-right: 0.35rem !important;
font-size: 0.9rem !important;
display: inline-block !important;
}
.messagetext {
color: #1e293b !important;
white-space: pre-wrap !important;
word-break: break-word !important;
display: inline !important;
margin: 0 !important;
}
}
}