mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-20 21:34:03 +01:00
getRoomEventIndex: improved speed for what it is used
This commit is contained in:
parent
44998ca450
commit
8dcb6f24b5
1 changed files with 4 additions and 3 deletions
|
@ -205,12 +205,13 @@ angular.module('eventHandlerService', [])
|
||||||
*/
|
*/
|
||||||
var getRoomEventIndex = function(room_id, event_id) {
|
var getRoomEventIndex = function(room_id, event_id) {
|
||||||
var index;
|
var index;
|
||||||
|
|
||||||
var room = $rootScope.events.rooms[room_id];
|
var room = $rootScope.events.rooms[room_id];
|
||||||
if (room) {
|
if (room) {
|
||||||
for (var i = 0; i < room.messages.length; i++) {
|
// Start looking from the tail since the first goal of this function
|
||||||
|
// is to find a messaged among the latest ones
|
||||||
|
for (var i = room.messages.length - 1; i > 0; i--) {
|
||||||
var message = room.messages[i];
|
var message = room.messages[i];
|
||||||
console.log(message.event_id);
|
|
||||||
if (event_id === message.event_id) {
|
if (event_id === message.event_id) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue