Browse Source

quick fixes & updates

- removed system message announce for chat join/part
- allow a message with only an image or video (no text content)
- changed "Leave room" to "Return to home" for exit button
- changed chat timeout to one second
develop
Rob Colbert 1 year ago
parent
commit
18d4723edc
  1. 14
      app/services/chat.js
  2. 2
      app/views/chat/room/view.pug
  3. 10
      client/js/chat-client.js

14
app/services/chat.js

@ -308,22 +308,15 @@ export default class ChatService extends SiteService {
numeral(roomData.stats.presentCount).format('0,0'), numeral(roomData.stats.presentCount).format('0,0'),
); );
// const systemMessage = {
// created: NOW.toISOString(),
// content: `${member.displayName || member.username} has entered the room.`,
// };
this.dtp.emitter this.dtp.emitter
.to(room._id.toString()) .to(room._id.toString())
.emit('chat-control', { .emit('chat-control', {
displayList, displayList,
audio: { playSound: 'chat-room-connect' }, audio: { playSound: 'chat-room-connect' },
// systemMessages: [systemMessage],
}); });
} }
async chatRoomCheckOut (room, member) { async chatRoomCheckOut (room, member) {
const NOW = new Date();
const roomData = await ChatRoom.findOneAndUpdate( const roomData = await ChatRoom.findOneAndUpdate(
{ _id: room._id }, { _id: room._id },
{ {
@ -359,12 +352,7 @@ export default class ChatService extends SiteService {
numeral(roomData.stats.presentCount).format('0,0'), numeral(roomData.stats.presentCount).format('0,0'),
); );
const systemMessage = { this.dtp.emitter.to(room._id.toString()).emit('chat-control', { displayList });
created: NOW.toISOString(),
content: `<a href="/member/${member.username}", uk-tooltip="Visit ${member.username}">@${member.username}</a> has connected to the room.`,
};
this.dtp.emitter.to(room._id.toString()).emit('chat-control', { displayList, systemMessages: [systemMessage] });
} }
async sendRoomMessage (room, author, messageDefinition, imageFiles, videoFiles) { async sendRoomMessage (room, author, messageDefinition, imageFiles, videoFiles) {

2
app/views/chat/room/view.pug

@ -68,7 +68,7 @@ block view-content
a(href=`/chat/room/${room._id}/settings`, uk-tooltip={ title: 'Configure room settings' }).uk-link-reset a(href=`/chat/room/${room._id}/settings`, uk-tooltip={ title: 'Configure room settings' }).uk-link-reset
i.fa-solid.fa-cog i.fa-solid.fa-cog
.uk-width-auto .uk-width-auto
a(href="/", uk-tooltip={ title: 'Leave room' }).uk-link-reset a(href="/", uk-tooltip={ title: 'Return to home' }).uk-link-reset
i.fa-solid.fa-person-through-window i.fa-solid.fa-person-through-window
.chat-media .chat-media

10
client/js/chat-client.js

@ -41,6 +41,8 @@ export class ChatApp extends DtpApp {
messages: [ ], messages: [ ],
messageMenu: document.querySelector('.chat-message-menu'), messageMenu: document.querySelector('.chat-message-menu'),
input: document.querySelector('#chat-input-text'), input: document.querySelector('#chat-input-text'),
imageFiles: document.querySelector('#image-files'),
videoFile: document.querySelector('#video-file'),
sendButton: document.querySelector('#chat-send-btn'), sendButton: document.querySelector('#chat-send-btn'),
isAtBottom: true, isAtBottom: true,
}; };
@ -253,7 +255,9 @@ export class ChatApp extends DtpApp {
const content = this.chat.input.value; const content = this.chat.input.value;
this.chat.input.value = ''; this.chat.input.value = '';
if (content.length === 0) { if ((content.length === 0) &&
(!this.chat.imageFiles.value) &&
(!this.chat.videoFile.value)) {
return true; return true;
} }
@ -269,13 +273,15 @@ export class ChatApp extends DtpApp {
} }
// set focus back to chat input // set focus back to chat input
this.chat.imageFiles.value = null;
this.chat.videoFile = null;
this.chat.input.focus(); this.chat.input.focus();
this.chat.sendButton.setAttribute('disabled', ''); this.chat.sendButton.setAttribute('disabled', '');
this.chatTimeout = setTimeout(( ) => { this.chatTimeout = setTimeout(( ) => {
delete this.chatTimeout; delete this.chatTimeout;
this.chat.sendButton.removeAttribute('disabled'); this.chat.sendButton.removeAttribute('disabled');
}, 5000); }, 1000);
return true; return true;
} }

Loading…
Cancel
Save