Skip to content
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

Fix incorrectly incrementing IDs before sending to server. #1026

Merged
merged 4 commits into from Feb 5, 2019

Conversation

charlag
Copy link
Collaborator

@charlag charlag commented Feb 2, 2019

Fix #1022
It seems to be working but I've made so many stupid errors before and while fixing it now that I'm not sure about anything anymore. I want to write some tests for that but I'm not sure when I'll do it. I would appreciate if someone else tried it out before merging.

@charlag
Copy link
Collaborator Author

charlag commented Feb 3, 2019

Started with tests, setup is usually the longest part, should be able to cover other logic tomorrow.

@charlag
Copy link
Collaborator Author

charlag commented Feb 3, 2019

I think I'm done with it for now. So glad I wrote tests, found so many sneaky things, even in the dumbest 2 line implementation of String#inc().

(LENGTH(serverId) < LENGTH(:maxId) OR LENGTH(serverId) == LENGTH(:maxId) AND serverId < :maxId)
AND
(LENGTH(serverId) > LENGTH(:sinceId) OR LENGTH(serverId) == LENGTH(:sinceId) AND serverId > :sinceId)
""")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use parentheses to make the boolean operation precedence explicit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking about it but actually either works. Maybe should still do it.


// Used for stubbing Android implementation without slow & buggy Robolectric things
@Suppress("unused")
class SpannableString(private val text: CharSequence) : Spannable {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this should be merged with the one in SpanUtilsTest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a copy of that one, it just must have exactly this name. I'm not sure yet how to merge them.

listOf(
"122" to "123",
"12A" to "12B",
"1" to "2"
Copy link
Collaborator

Choose a reason for hiding this comment

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

No test case for something ending with z?

Copy link
Collaborator

Choose a reason for hiding this comment

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

or 9?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

inc() is very dumb and I just let it increase any character, really. Even if it's z it should become something bigger.

@connyduck
Copy link
Collaborator

It fixes the bug and the code looks fine for me, so I think we should merge it? Got a lot of complaints about the timeline not loading on nightly.

@charlag
Copy link
Collaborator Author

charlag commented Feb 5, 2019

I hit the bug like five times. Now I'm on this branch without any problems so far.

@connyduck connyduck merged commit 6395281 into master Feb 5, 2019
@connyduck connyduck deleted the fix-gap-detection branch February 5, 2019 19:33
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.

Tusky not loading new toots
3 participants