Commit c9cd2e39 authored by MrMan's avatar MrMan

Fix bug, if would never happen

parent 69756d27
......@@ -219,26 +219,21 @@ let TinderMatchStore = Reflux.createStore({
}
});
// Save important information from the match for a brand new match
if (!_.has(this.state.matches, matchId)) {
// Handle brand new match
let matchedUserId = "";
if(!_.isUndefined(m.person)) {
// If m.person has been provided, use that to find the matched user ID, and use it to update the state
// Initial match object should contain at least
matchedUserId = m.person._id;
} else if(!_.isEmpty(m.messages)) {
// Attempt to derive matched user ID from a message
let first = _.first(m.messages);
matchedUserId = m.message.to === currentUser._id ? m.message.from : m.message.to;
}
// Save matched user ID, initial match object to internal matches
this.state.matches[matchId].matchedUserId = matchedUserId;
this.state.matches[matchId].matchObj = m;
// Attempt to discover the correct matchedUserId
let matchedUserId = "";
if(!_.isUndefined(m.person)) {
// If m.person has been provided, use that to find the matched user ID, and use it to update the state
// Initial match object should contain at least
matchedUserId = m.person._id;
} else if(!_.isEmpty(m.messages)) {
// Attempt to derive matched user ID from a message
matchedUserId = m.message.to === currentUser._id ? m.message.from : m.message.to;
}
// Save matched user ID, initial match object to internal matches
this.state.matches[matchId].matchedUserId = matchedUserId;
this.state.matches[matchId].matchObj = m;
// If there is pre-existing match object, but we're getting piecemeal updates, there's a problem
if (!_.has(this.state.matches, matchId) && _.isUndefined(m.person)) {
// TODO: Need to request fresh updates/specific match info in hopes of getting proper data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment