Merge pull request #1312 from matrix-org/luke/feature-widget-timeline-events
Implement TextualEvent tiles for im.vector.modular.widgetspull/21833/head
commit
cab3123bd8
|
@ -248,6 +248,28 @@ function textForPowerEvent(event) {
|
|||
});
|
||||
}
|
||||
|
||||
function textForWidgetEvent(event) {
|
||||
const senderName = event.sender ? event.sender.name : event.getSender();
|
||||
const previousContent = event.getPrevContent() || {};
|
||||
const {name, type, url} = event.getContent() || {};
|
||||
let widgetName = widgetName || name || type || previousContent.type || '';
|
||||
|
||||
// Apply sentence case
|
||||
widgetName = widgetName ? widgetName[0].toUpperCase() + widgetName.slice(1).toLowerCase() + ' ' : '';
|
||||
|
||||
// If the widget was removed, its content should be {}, but this is sufficiently
|
||||
// equivalent to that condition.
|
||||
if (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 +282,8 @@ var handlers = {
|
|||
'm.room.history_visibility': textForHistoryVisibilityEvent,
|
||||
'm.room.encryption': textForEncryptionEvent,
|
||||
'm.room.power_levels': textForPowerEvent,
|
||||
|
||||
'im.vector.modular.widgets': textForWidgetEvent,
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -970,5 +970,7 @@
|
|||
"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",
|
||||
"%(senderName)s added a %(widgetName)swidget": "%(senderName)s added a %(widgetName)swidget",
|
||||
"%(senderName)s removed a %(widgetName)swidget": "%(senderName)s removed a %(widgetName)swidget",
|
||||
"Robot check is currently unavailable on desktop - please use a <a>web browser</a>": "Robot check is currently unavailable on desktop - please use a <a>web browser</a>"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue