Skip to content

Allow elements to be moved to start of FirebaseArray (potential fix for #129) #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 10, 2016

Conversation

ramblex
Copy link
Contributor

@ramblex ramblex commented Oct 7, 2016

When using FirebaseTableViewDataSource I was seeing something like the following when moving an object to the start of a list.

Assertions: failed: caught "NSRangeException", "*** -[__NSArrayM insertObject:atIndex:]: index 9223372036854775807 beyond bounds [0 .. 8]"

It looks like it was caused by the FIRDataEventTypeChildMoved being sent a previousChildKey that doesn't exist in the array (presumably ""). This is similar to #129 and is potentially a fix for that.

Copy link
Contributor

@morganchen12 morganchen12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @ramblex!

@@ -123,7 +123,11 @@ - (void)initListeners {
NSUInteger fromIndex = [self indexForKey:snapshot.key];
[self.snapshots removeObjectAtIndex:fromIndex];

NSUInteger toIndex = [self indexForKey:previousChildKey] + 1;
NSUInteger toIndex = 0;
NSUInteger prevIndex = [self indexForKey:previousChildKey];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be handling the case where the previous child key is nil as well here

};

// Move 8 to the start
[self.observable sendEvent:FIRDataEventTypeChildMoved withObject:self.snap previousKey:@"" error:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a case like this where previous key is nil as well? Other than that this change looks good.

@ramblex
Copy link
Contributor Author

ramblex commented Oct 9, 2016

I've added in the changes. I'm not sure exactly why the CI build failed.. there's quite a few Canceling tests due to timeout in Checking test manager availability messages.

Copy link
Contributor

@morganchen12 morganchen12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry about CI, changes LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants