mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 22:49:23 -05:00
Recents must not show temporary fake messages
This commit is contained in:
parent
42f5b0a6b8
commit
8aa4b7bf7f
@ -352,6 +352,30 @@ angular.module('eventHandlerService', [])
|
|||||||
resetRoomMessages(room_id);
|
resetRoomMessages(room_id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the last message event of a room
|
||||||
|
* @param {String} room_id the room id
|
||||||
|
* @param {Boolean} filterFake true to not take into account fake messages
|
||||||
|
* @returns {undefined | Event} the last message event if available
|
||||||
|
*/
|
||||||
|
getLastMessage: function(room_id, filterEcho) {
|
||||||
|
var lastMessage;
|
||||||
|
|
||||||
|
var room = $rootScope.events.rooms[room_id];
|
||||||
|
if (room) {
|
||||||
|
for (var i = room.messages.length - 1; i >= 0; i--) {
|
||||||
|
var message = room.messages[i];
|
||||||
|
|
||||||
|
if (!filterEcho || undefined === message.echo_msg_state) {
|
||||||
|
lastMessage = message;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastMessage;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the room users number, ie the number of members who has joined the room.
|
* Compute the room users number, ie the number of members who has joined the room.
|
||||||
* @param {String} room_id the room id
|
* @param {String} room_id the room id
|
||||||
|
@ -17,8 +17,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('RecentsController', ['matrixService', 'matrixFilter'])
|
angular.module('RecentsController', ['matrixService', 'matrixFilter'])
|
||||||
.controller('RecentsController', ['$rootScope',
|
.controller('RecentsController', ['$rootScope', '$scope', 'eventHandlerService',
|
||||||
function($rootScope) {
|
function($rootScope, $scope, eventHandlerService) {
|
||||||
|
|
||||||
|
// Expose the service to the view
|
||||||
|
$scope.eventHandlerService = eventHandlerService;
|
||||||
|
|
||||||
// $rootScope of the parent where the recents component is included can override this value
|
// $rootScope of the parent where the recents component is included can override this value
|
||||||
// in order to highlight a specific room in the list
|
// in order to highlight a specific room in the list
|
||||||
|
@ -35,14 +35,9 @@ angular.module('RecentsController')
|
|||||||
// And time sort them
|
// And time sort them
|
||||||
// The room with the lastest message at first
|
// The room with the lastest message at first
|
||||||
filtered.sort(function (roomA, roomB) {
|
filtered.sort(function (roomA, roomB) {
|
||||||
var lastMsgRoomA, lastMsgRoomB;
|
|
||||||
|
|
||||||
if (roomA.messages && 0 < roomA.messages.length) {
|
var lastMsgRoomA = eventHandlerService.getLastMessage(roomA.room_id, true);
|
||||||
lastMsgRoomA = roomA.messages[roomA.messages.length - 1];
|
var lastMsgRoomB = eventHandlerService.getLastMessage(roomB.room_id, true);
|
||||||
}
|
|
||||||
if (roomB.messages && 0 < roomB.messages.length) {
|
|
||||||
lastMsgRoomB = roomB.messages[roomB.messages.length - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Invite message does not have a body message nor ts
|
// Invite message does not have a body message nor ts
|
||||||
// Puth them at the top of the list
|
// Puth them at the top of the list
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<td class="recentsRoomSummaryTS">
|
<td class="recentsRoomSummaryTS">
|
||||||
<!-- Use a temp var as alias to the last room message.
|
<!-- Use a temp var as alias to the last room message.
|
||||||
Declaring it in this way ensures the data-binding -->
|
Declaring it in this way ensures the data-binding -->
|
||||||
{{lastMsg = room.messages[room.messages.length - 1];""}}
|
{{ lastMsg = eventHandlerService.getLastMessage(room.room_id, true);"" }}
|
||||||
|
|
||||||
{{ (lastMsg.ts) | date:'MMM d HH:mm' }}
|
{{ (lastMsg.ts) | date:'MMM d HH:mm' }}
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user