From 5a1853210e458fe7a66a64faf931219e727e8a93 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 10 Dec 2015 13:58:06 +0000 Subject: [PATCH] Handle the fact that newer homeservers return lists rather than dicts --- src/components/structures/RoomView.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 176d61b42e..025e0f1a4f 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -505,6 +505,15 @@ module.exports = React.createClass({ var results = this.state.searchResults.search_categories.room_events.results; var roomIdGroups = this.state.searchResults.search_categories.room_events.groups.room_id; + if (Array.isArray(results)) { + // Old search API used to return results as a event_id -> result dict, but now + // returns a straightforward list. + results = results.reduce(function(prev, curr) { + prev[curr.result.event_id] = curr; + return prev; + }, {}); + } + Object.keys(roomIdGroups) .sort(function(a, b) { roomIdGroups[a].order - roomIdGroups[b].order }) // WHY NOT RETURN AN ORDERED ARRAY?!?!?! .forEach(function(roomId)