From f2a310531acea39b60b2852abe45385ca435696b Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Fri, 19 Jan 2018 15:30:34 -0600 Subject: [PATCH] Adjust for another go --- app/lib/rocketchat.js | 5 +---- app/views/RoomsListView/index.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 188178a8..781ed211 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -432,13 +432,10 @@ const RocketChat = { } return subscription; }); - + database.write(() => { data.forEach(subscription => database.create('subscriptions', subscription, true)); - }); - - database.write(() => { rooms.forEach(room => database.create('rooms', room, true)); }); diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index c1d63f6e..69f39d00 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -81,7 +81,7 @@ export default class RoomsListView extends React.Component { } getLastMessage = (subscription) => { - const room = database.objects('rooms').sorted('_updatedAt', true).slice().find(({ _id }) => _id === subscription.rid); + const [ room ] = database.objects('rooms').filtered('_id = $0', subscription.rid).slice(); console.log('ROOM', room); return room.lastMessage; }