mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 13:14:58 +08:00
split handlers into state and non-states
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
2ba0a801c4
commit
6a4e3792d4
@ -291,12 +291,15 @@ function textForWidgetEvent(event) {
|
|||||||
|
|
||||||
const handlers = {
|
const handlers = {
|
||||||
'm.room.message': textForMessageEvent,
|
'm.room.message': textForMessageEvent,
|
||||||
'm.room.name': textForRoomNameEvent,
|
|
||||||
'm.room.topic': textForTopicEvent,
|
|
||||||
'm.room.member': textForMemberEvent,
|
|
||||||
'm.call.invite': textForCallInviteEvent,
|
'm.call.invite': textForCallInviteEvent,
|
||||||
'm.call.answer': textForCallAnswerEvent,
|
'm.call.answer': textForCallAnswerEvent,
|
||||||
'm.call.hangup': textForCallHangupEvent,
|
'm.call.hangup': textForCallHangupEvent,
|
||||||
|
};
|
||||||
|
|
||||||
|
const stateHandlers = {
|
||||||
|
'm.room.name': textForRoomNameEvent,
|
||||||
|
'm.room.topic': textForTopicEvent,
|
||||||
|
'm.room.member': textForMemberEvent,
|
||||||
'm.room.third_party_invite': textForThreePidInviteEvent,
|
'm.room.third_party_invite': textForThreePidInviteEvent,
|
||||||
'm.room.history_visibility': textForHistoryVisibilityEvent,
|
'm.room.history_visibility': textForHistoryVisibilityEvent,
|
||||||
'm.room.encryption': textForEncryptionEvent,
|
'm.room.encryption': textForEncryptionEvent,
|
||||||
@ -307,8 +310,8 @@ const handlers = {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
textForEvent: function(ev) {
|
textForEvent: function(ev) {
|
||||||
const hdlr = handlers[ev.getType()];
|
const handler = ev.isState() ? stateHandlers[ev.getType()] : handlers[ev.getType()];
|
||||||
if (!hdlr) return '';
|
if (handler) return handler(ev);
|
||||||
return hdlr(ev);
|
return '';
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user