mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Show room topic change in the chat history and in the recents
This commit is contained in:
parent
8dcb6f24b5
commit
7e7eb0efc1
@ -35,6 +35,7 @@ angular.module('eventHandlerService', [])
|
|||||||
var POWERLEVEL_EVENT = "POWERLEVEL_EVENT";
|
var POWERLEVEL_EVENT = "POWERLEVEL_EVENT";
|
||||||
var CALL_EVENT = "CALL_EVENT";
|
var CALL_EVENT = "CALL_EVENT";
|
||||||
var NAME_EVENT = "NAME_EVENT";
|
var NAME_EVENT = "NAME_EVENT";
|
||||||
|
var TOPIC_EVENT = "TOPIC_EVENT";
|
||||||
|
|
||||||
var initialSyncDeferred = $q.defer();
|
var initialSyncDeferred = $q.defer();
|
||||||
|
|
||||||
@ -170,24 +171,39 @@ angular.module('eventHandlerService', [])
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Can this just be a generic "I am a room state event, can haz store?"
|
// TODO: Can this just be a generic "I am a room state event, can haz store?"
|
||||||
var handleRoomTopic = function(event, isLiveEvent) {
|
var handleRoomTopic = function(event, isLiveEvent, isStateEvent) {
|
||||||
console.log("handleRoomTopic live="+isLiveEvent);
|
console.log("handleRoomTopic live="+isLiveEvent);
|
||||||
|
|
||||||
initRoom(event.room_id);
|
initRoom(event.room_id);
|
||||||
|
|
||||||
|
// Add topic changes as if they were a room message
|
||||||
|
if (!isStateEvent) {
|
||||||
|
if (isLiveEvent) {
|
||||||
|
$rootScope.events.rooms[event.room_id].messages.push(event);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$rootScope.events.rooms[event.room_id].messages.unshift(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// live events always update, but non-live events only update if the
|
// live events always update, but non-live events only update if the
|
||||||
// ts is later.
|
// ts is later.
|
||||||
|
var latestData = true;
|
||||||
if (!isLiveEvent) {
|
if (!isLiveEvent) {
|
||||||
var eventTs = event.ts;
|
var eventTs = event.ts;
|
||||||
var storedEvent = $rootScope.events.rooms[event.room_id][event.type];
|
var storedEvent = $rootScope.events.rooms[event.room_id][event.type];
|
||||||
if (storedEvent) {
|
if (storedEvent) {
|
||||||
if (storedEvent.ts > eventTs) {
|
if (storedEvent.ts > eventTs) {
|
||||||
// ignore it, we have a newer one already.
|
// ignore it, we have a newer one already.
|
||||||
return;
|
latestData = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$rootScope.events.rooms[event.room_id][event.type] = event;
|
if (latestData) {
|
||||||
|
$rootScope.events.rooms[event.room_id][event.type] = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rootScope.$broadcast(TOPIC_EVENT, event, isLiveEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
var handleCallEvent = function(event, isLiveEvent) {
|
var handleCallEvent = function(event, isLiveEvent) {
|
||||||
@ -229,6 +245,7 @@ angular.module('eventHandlerService', [])
|
|||||||
POWERLEVEL_EVENT: POWERLEVEL_EVENT,
|
POWERLEVEL_EVENT: POWERLEVEL_EVENT,
|
||||||
CALL_EVENT: CALL_EVENT,
|
CALL_EVENT: CALL_EVENT,
|
||||||
NAME_EVENT: NAME_EVENT,
|
NAME_EVENT: NAME_EVENT,
|
||||||
|
TOPIC_EVENT: TOPIC_EVENT,
|
||||||
|
|
||||||
handleEvent: function(event, isLiveEvent, isStateEvent) {
|
handleEvent: function(event, isLiveEvent, isStateEvent) {
|
||||||
// Avoid duplicated events
|
// Avoid duplicated events
|
||||||
@ -279,7 +296,7 @@ angular.module('eventHandlerService', [])
|
|||||||
handleRoomName(event, isLiveEvent);
|
handleRoomName(event, isLiveEvent);
|
||||||
break;
|
break;
|
||||||
case 'm.room.topic':
|
case 'm.room.topic':
|
||||||
handleRoomTopic(event, isLiveEvent);
|
handleRoomTopic(event, isLiveEvent, isStateEvent);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("Unable to handle event type " + event.type);
|
console.log("Unable to handle event type " + event.type);
|
||||||
|
@ -68,6 +68,11 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand
|
|||||||
$rootScope.rooms[event.room_id] = event;
|
$rootScope.rooms[event.room_id] = event;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$rootScope.$on(eventHandlerService.TOPIC_EVENT, function(ngEvent, event, isLive) {
|
||||||
|
if (isLive) {
|
||||||
|
$rootScope.rooms[event.room_id].lastMsg = event;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,6 +76,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-switch-when="m.room.topic">
|
||||||
|
{{ room.lastMsg.user_id | mUserDisplayName: room.room_id }} changed the topic to: {{ room.lastMsg.content.topic }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div ng-switch-default>
|
<div ng-switch-default>
|
||||||
<div ng-if="room.lastMsg.type.indexOf('m.call.') === 0">
|
<div ng-if="room.lastMsg.type.indexOf('m.call.') === 0">
|
||||||
Call
|
Call
|
||||||
|
@ -113,6 +113,11 @@
|
|||||||
ng-click="$parent.fullScreenImageURL = msg.content.url"/>
|
ng-click="$parent.fullScreenImageURL = msg.content.url"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<span ng-if="'m.room.topic' === msg.type">
|
||||||
|
{{ members[msg.user_id].displayname || msg.user_id }} changed the topic to: {{ msg.content.topic }}
|
||||||
|
</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="rightBlock">
|
<td class="rightBlock">
|
||||||
|
Loading…
Reference in New Issue
Block a user