diff --git a/src/TextForEvent.js b/src/TextForEvent.js index de12cec502..ed06cc2199 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -248,6 +248,25 @@ function textForPowerEvent(event) { }); } +function textForWidgetEvent(event) { + const senderName = event.sender ? event.sender.name : event.getSender(); + const prevWidgetName = event.getPrevContent() ? event.getPrevContent().name : null; + let widgetName = event.getContent() ? event.getContent().name : prevWidgetName; + + // Apply sentence case + widgetName = widgetName ? widgetName[0].toUpperCase() + widgetName.slice(1).toLowerCase() + ' ' : ''; + + if (event.getContent().url) { + return _t('%(senderName)s added a %(widgetName)swidget', { + senderName, widgetName, + }); + } else { + return _t('%(senderName)s removed a %(widgetName)swidget', { + senderName, widgetName, + }); + } +} + var handlers = { 'm.room.message': textForMessageEvent, 'm.room.name': textForRoomNameEvent, @@ -260,6 +279,8 @@ var handlers = { 'm.room.history_visibility': textForHistoryVisibilityEvent, 'm.room.encryption': textForEncryptionEvent, 'm.room.power_levels': textForPowerEvent, + + 'im.vector.modular.widgets': textForWidgetEvent, }; module.exports = { diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 776d8a264b..a6f8ed5542 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -44,6 +44,8 @@ var eventTileTypes = { 'm.room.history_visibility' : 'messages.TextualEvent', 'm.room.encryption' : 'messages.TextualEvent', 'm.room.power_levels' : 'messages.TextualEvent', + + 'im.vector.modular.widgets': 'messages.TextualEvent', }; var MAX_READ_AVATARS = 5; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 83be31de4b..0cd463fe8b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -969,5 +969,7 @@ "Automatically replace plain text Emoji": "Automatically replace plain text Emoji", "Failed to upload image": "Failed to upload image", "Failed to update group": "Failed to update group", - "Hide avatars in user and room mentions": "Hide avatars in user and room mentions" + "Hide avatars in user and room mentions": "Hide avatars in user and room mentions", + "%(senderName)s added a %(widgetName)swidget": "%(senderName)s added a %(widgetName)swidget", + "%(senderName)s removed a %(widgetName)swidget": "%(senderName)s removed a %(widgetName)swidget" }