-
Notifications
You must be signed in to change notification settings - Fork 246
Fix null streams #283
Fix null streams #283
Conversation
|
Automated message from Dropbox CLA bot @Sam1301, it looks like you've already signed the Dropbox CLA. Thanks! |
|
Awesome work @Sam1301 but can you please put the second commit into a new PR! |
|
sure 👍 |
9e45fb8 to
e096378
Compare
|
As stream objects will be added to each message, we would need to reset the existing database which has null values for streams in each message. Hence, I have suggested to bump up the database version which would reset the database and new messages will be fetched. |
|
Nice work! @timabbott LGTM, just FYI this upgrades the database version hence all the existing data are dropped and reloaded we have to take this big step because the streams saved in the messages table are null therefore which is causing problems in other features! |
| Person person = Person.getOrUpdate(app, m.getSenderEmail(), m.getSenderFullName(), m.getAvatarUrl()); | ||
| m.setSender(person); | ||
| Stream stream = Stream.getByName(app, m.getRecipients()); | ||
| m.setStream(stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work for messages sent to an individual rather than a stream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, I totally missed that, after giving it some thought I think setting streams to null for private messages can be a potential solution.
08b3508 to
b607659
Compare
|
OK; may be worth some careful testing; @kunall17 @saketkumar95 does one of you have time? |
|
|
||
| for (Person person : people) { | ||
| if (person.id != app.getYou().id || people.length == 1) { | ||
| if (!person.getEmail().equals(app.getYou().getEmail()) || people.length == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the problem using ID's here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the person object here has id 0 because the user configuration response we receive is not deserialized into a person object with an id as it is supposed to be auto-generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the person ID is auto generated so it shouldn't be the same and if you check the dumped databases i posted the person have unique ID's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, made the changes 👍
b607659 to
223465f
Compare
|
@vishwesh3 @saketkumar95 It would be great if you guys could help testing this big PR, this fixes the unread count + messages.streams columns? |
|
@kunall17 Though I am still a newbie to Zulip but Can I test it too? |
|
@yadav-rahul Sure go ahead.. 👍 |
|
sure. |
|
@Sam1301 The new bubble looks good for small numbers, but for double digits the round shape looks small! |
|
@kunall17 Thanks, I will make the changes 👍 |
|
Update
|
|
@Sam1301 I think we should this PR, and fix unread counts in another one because we are facing issue if the pointer is very low from the latest message ID then the android app will not fetch those messages and hence we have lesser unread counts, which is not the right thing to display! |
|
Since we only fetch 100 messages below the latest pointer, we won't get the correct number of unread counts for all the messages past that. Can we change this and fetch all the messages after the current pointer? |
cb25d84 to
07bc283
Compare
|
@Sam1301 we probably want to limit it in some way. The backend is happy fetching up to ~1k messages, but if a user is somehow 25K messages behind, the request will fail. What we do on web is run a loop fetching in batches of 400 until we get to current. We also offer the user the opportunity to "declare bankruptcy" if they have more than ~500 unread messages. I think for practical purposes, once the user has over 1000 unread messages beyond the pointer, that's more than they're realistically going to scroll through anyway, so we could probably just stop at some point as a solution for now (there's not a cheap way to query the backend for grand total unread messages by recipient). |
|
@Sam1301 Awesome Work! 👍 @timabbott Now this PR has no unread counts commit's so we can merge this one! :) |
| app.getDao(Stream.class).createIfNotExists(stream); | ||
| } | ||
| // catch the new stream object with auto-generated id | ||
| stream = app.getDao(Stream.class).createIfNotExists(new Stream(name)); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to generate IDs for Stream objects? Streams have an ID on the backend...
I guess maybe fixing that would be harder to fix...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think when stream is null, and a new stream object is created... using Stream(name) constructor, it doesn't get an id assigned to it and streams with id 0 are stored in the database with createIfNotExists, hence I tried to generate the ids. Am I mistaken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should explain more. I think your code is probably correct for how the Android app works today. But what I think is going on here that is probably not ideal is that Zulip servers give streams an ID, and the Android app gives streams an ID (here), and those IDs have nothing to do with each other. :(.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the stream objects have id given from server which are deserialized into id field in stream class here. I guess my concern is if the stream is null after querying for it in the database, we would be making a new stream object for it with id zero and store it in the database. Eventually, other stream objects generated this way would also have id 0 as well. Storing these in the database might cause a unique constraint exception. Am I mistaken? I just want to clarify this doubt :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, storing a made-up stream ID for it might also cause a unique constraint exception if/when the stream that actually has that ID on the backend shows up, right? More rare, but still a problem. Hrm.
It seems like there are 2 possible correct solutions here:
- The same approach the web client uses, namely that we fetch from the server the complete list of streams we're subscribed to on startup, and maintain that list over time using the events system, so that this condition never happens.
- We modified the way messages are sent down to clients to optionally include the Stream ID in the display_recipient field (or something), so that the correct stream ID would be available here.
What do you think we should do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the approach followed in the web client. That seems less susceptible to future bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for giving me such a nice explanation, I learned a lot from this pr :)
07bc283 to
43b5203
Compare
a9477f6 to
de99727
Compare
de99727 to
805f1bc
Compare
|
|
||
| @SerializedName("subscribers") | ||
| private List<Integer> subscribers; | ||
| private List<String> subscribers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These subscribers is the list of email right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
|
Looks good to me now |
|
Merged, thanks @Sam1301! |
EDIT:
Currently stream objects retrieved from messages are null throughout the project. I have corrected this by querying a stream object when we fetch new messages.