|
|
@ -25,6 +25,7 @@ export class ChatApp extends DtpApp { |
|
|
|
static get SFX_CHAT_MESSAGE ( ) { return 'chat-message'; } |
|
|
|
static get SFX_CHAT_REACTION ( ) { return 'reaction'; } |
|
|
|
static get SFX_CHAT_REACTION_REMOVE ( ) { return 'reaction-remove'; } |
|
|
|
static get SFX_CHAT_MESSAGE_REMOVE ( ) { return 'message-remove'; } |
|
|
|
|
|
|
|
constructor (user) { |
|
|
|
super(DTP_COMPONENT_NAME, user); |
|
|
@ -75,6 +76,7 @@ export class ChatApp extends DtpApp { |
|
|
|
this.audio.loadSound(ChatApp.SFX_CHAT_MESSAGE, '/static/sfx/chat-message.mp3'), |
|
|
|
this.audio.loadSound(ChatApp.SFX_CHAT_REACTION, '/static/sfx/reaction.mp3'), |
|
|
|
this.audio.loadSound(ChatApp.SFX_CHAT_REACTION_REMOVE, '/static/sfx/reaction-remove.mp3'), |
|
|
|
this.audio.loadSound(ChatApp.SFX_CHAT_MESSAGE_REMOVE, '/static/sfx/message-deleted.mp3'), |
|
|
|
]); |
|
|
|
} catch (error) { |
|
|
|
this.log.error('startAudio', 'failed to load sound', { error }); |
|
|
@ -262,6 +264,22 @@ export class ChatApp extends DtpApp { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
async deleteChatMessage (event) { |
|
|
|
const target = event.currentTarget || event.target; |
|
|
|
const messageId = target.getAttribute('data-message-id'); |
|
|
|
|
|
|
|
event.preventDefault(); |
|
|
|
event.stopPropagation(); |
|
|
|
|
|
|
|
try { |
|
|
|
const response = await fetch(`/chat/message/${messageId}`, { method: 'DELETE' }); |
|
|
|
await this.processResponse(response); |
|
|
|
} catch (error) { |
|
|
|
this.log.error('deleteChatMessage', 'failed to delete chat message', { error }); |
|
|
|
UIkit.modal.alert(`Failed to delete chat message: ${error.message}`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async toggleMessageReaction (event) { |
|
|
|
const target = event.currentTarget || event.target; |
|
|
|
const messageId = target.getAttribute('data-message-id'); |
|
|
|