Skip to content

Commit

Permalink
patched bug for users starting new chats
Browse files Browse the repository at this point in the history
  • Loading branch information
kykrueger committed Nov 5, 2016
1 parent 7159511 commit 7e43811
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,19 @@ public static Promise<String, BError, Void> checkForRemoteThreadWithUsers(List<B
public void onDataChange(DataSnapshot allThreadsForUser) {
// Check all of the user's threads (only the threadIds are here)
Boolean lastThread = false;
Iterator<DataSnapshot> allThreadsForUserIterator;
allThreadsForUserIterator = allThreadsForUser.getChildren().iterator();
while(allThreadsForUserIterator.hasNext()){
int threadNumber = 0;

if (allThreadsForUser.getChildrenCount() == 0) {
deferred.reject(new BError(404, "Could not find existing Thread"));
}

for(DataSnapshot threadOfUser : allThreadsForUser.getChildren()){
threadNumber = threadNumber + 1;

// Stop searching if the thread has already been found
if (deferred.isResolved()) break;

DataSnapshot threadOfUser = allThreadsForUserIterator.next();
if(!allThreadsForUserIterator.hasNext()) lastThread = true;
if(allThreadsForUser.getChildrenCount() == threadNumber) lastThread = true;
final Boolean lastThreadFinal = lastThread;

DatabaseReference threadRef = FirebasePaths.threadRef(threadOfUser.getKey());
Expand Down

0 comments on commit 7e43811

Please sign in to comment.