Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Conversation

@Sam1301
Copy link
Member

@Sam1301 Sam1301 commented Jan 7, 2017

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.

  • listen for add, remove and update operations for subscription type events
  • listen for muted topics events.
  • in user configuration response, also get unsubscribed streams to ensure streams are not null in the message list.

@smarx
Copy link

smarx commented Jan 7, 2017

Automated message from Dropbox CLA bot

@Sam1301, it looks like you've already signed the Dropbox CLA. Thanks!

@kunall17
Copy link
Collaborator

kunall17 commented Jan 7, 2017

Awesome work @Sam1301 but can you please put the second commit into a new PR!

@Sam1301
Copy link
Member Author

Sam1301 commented Jan 7, 2017

sure 👍

@Sam1301 Sam1301 changed the title Add stream object to messages and correct emoji paths Add stream object to messages Jan 7, 2017
@Sam1301
Copy link
Member Author

Sam1301 commented Jan 8, 2017

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.

@kunall17
Copy link
Collaborator

kunall17 commented Jan 9, 2017

Nice work!
Works as expected.

@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!
There is no noticeable UI change as sam1301 stated no re-login required!
Here is the Databases.zip (contains the old and the newly updated database after running the project through this branch) if any one wants to check/debug!

Person person = Person.getOrUpdate(app, m.getSenderEmail(), m.getSenderFullName(), m.getAvatarUrl());
m.setSender(person);
Stream stream = Stream.getByName(app, m.getRecipients());
m.setStream(stream);
Copy link
Member

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?

Copy link
Member Author

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.

@timabbott
Copy link
Member

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) {
Copy link
Collaborator

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?

Copy link
Member Author

@Sam1301 Sam1301 Jan 14, 2017

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.

Copy link
Collaborator

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

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, made the changes 👍

@kunall17
Copy link
Collaborator

@vishwesh3 @saketkumar95 It would be great if you guys could help testing this big PR, this fixes the unread count + messages.streams columns?

@Sam1301 Sam1301 changed the title Add stream object to messages Fix unread counts and null streams Jan 16, 2017
@yadav-rahul
Copy link
Collaborator

yadav-rahul commented Jan 16, 2017

@kunall17 Though I am still a newbie to Zulip but Can I test it too?

@kunall17
Copy link
Collaborator

@yadav-rahul Sure go ahead.. 👍

@jainkuniya
Copy link
Member

sure.

@kunall17
Copy link
Collaborator

@Sam1301 The new bubble looks good for small numbers, but for double digits the round shape looks small!
Also how about displaying the unread count in the toolbar like Zulip (12) ?

@Sam1301
Copy link
Member Author

Sam1301 commented Jan 16, 2017

@kunall17 Thanks, I will make the changes 👍

@Sam1301
Copy link
Member Author

Sam1301 commented Jan 17, 2017

@kunall17
Copy link
Collaborator

@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!
So we can merge the fixing part?
The expandable adapter will be up and working again!

@Sam1301
Copy link
Member Author

Sam1301 commented Jan 19, 2017

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?

@timabbott
Copy link
Member

@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).

@kunall17
Copy link
Collaborator

@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)); }
Copy link
Member

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...

Copy link
Member Author

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?

Copy link
Member

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. :(.

Copy link
Member Author

@Sam1301 Sam1301 Jan 20, 2017

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 :)

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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 :)

@Sam1301 Sam1301 changed the title Fix unread counts and null streams Fix null streams Jan 23, 2017

@SerializedName("subscribers")
private List<Integer> subscribers;
private List<String> subscribers;
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

@kunall17
Copy link
Collaborator

Looks good to me now
LGTM @timabbott !

@timabbott
Copy link
Member

Merged, thanks @Sam1301!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants