Skip to content

Commit

Permalink
Fix reading messages
Browse files Browse the repository at this point in the history
  • Loading branch information
terrysahaidak committed Oct 9, 2016
1 parent 4eea5c4 commit cadcf19
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions app/modules/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,20 @@ export function readMessages(roomId, changedRows) {
.filter(rowId => (changedRows[rowId] === true))
.filter(rowId => (listView.data[rowId].unread === true))

console.log('UNREAD', visibleAndUnread)

if (!visibleAndUnread.length) {
return
}

dispatch({type: READ_MESSAGES, roomId, visibleAndUnread})

// try {
// await Api.readMessages(
// token, id, roomId, visibleAndUnread.map(item => listView.data[item].id)
// )
// dispatch({type: READ_MESSAGES_OK, roomId, visibleAndUnread})
// } catch (error) {
// dispatch({type: READ_MESSAGES_ERROR, error: error.message, roomId, visibleAndUnread})
// }
try {
await Api.readMessages(
token, id, roomId, visibleAndUnread.map(item => listView.data[item].id)
)
dispatch({type: READ_MESSAGES_OK, roomId, visibleAndUnread})
} catch (error) {
dispatch({type: READ_MESSAGES_ERROR, error: error.message, roomId, visibleAndUnread})
}
}
}

Expand Down

0 comments on commit cadcf19

Please sign in to comment.