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

Show unread counts in the stream drawer #120

Closed
wants to merge 11 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@kunall17
Collaborator

kunall17 commented Aug 12, 2016

Uses the pointer to approximate the unread counts

Fixes #57

Old screenshot

EDIT: New screenshot

@smarx

This comment has been minimized.

smarx commented Aug 12, 2016

Automated message from Dropbox CLA bot

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

@timabbott

This comment has been minimized.

Member

timabbott commented Aug 12, 2016

Cool! Taking a quick look at the UI, I notice that the alignment of the unread counts in the streams vs. topics seems a bit off.

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Aug 12, 2016

Updated code + new screenshot added as well!

@niftynei

This comment has been minimized.

Contributor

niftynei commented Aug 16, 2016

hey @kunall17 the code for this looks pretty good. i got a crash on first open though:

08-16 19:33:49.778 E/Error   (  949): oops
08-16 19:33:49.778 E/Error   (  949): java.lang.RuntimeException: java.sql.SQLException: Could not perform raw query for SELECT s.id as _id,  s.name, s.color, count(case when m.id > -1 or messages.read = 1 then 1 end) as unread FROM streams as s LEFT JOIN messages as m ON s.id=m.stream group by s.name order by s.name COLLATE NOCASE
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.dao.RuntimeExceptionDao.queryRaw(RuntimeExceptionDao.java:483)
08-16 19:33:49.778 E/Error   (  949):   at com.zulip.android.activities.ZulipActivity$17.call(ZulipActivity.java:625)
08-16 19:33:49.778 E/Error   (  949):   at com.zulip.android.activities.ZulipActivity$17.call(ZulipActivity.java:621)
08-16 19:33:49.778 E/Error   (  949):   at com.zulip.android.activities.ZulipActivity.setupListViewAdapter(ZulipActivity.java:638)
08-16 19:33:49.778 E/Error   (  949):   at com.zulip.android.activities.ZulipActivity.checkAndSetupStreamsDrawer(ZulipActivity.java:747)
08-16 19:33:49.778 E/Error   (  949):   at com.zulip.android.activities.ZulipActivity.onCreate(ZulipActivity.java:409)
08-16 19:33:49.778 E/Error   (  949):   at android.app.Activity.performCreate(Activity.java:6251)
08-16 19:33:49.778 E/Error   (  949):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
08-16 19:33:49.778 E/Error   (  949):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
08-16 19:33:49.778 E/Error   (  949):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
08-16 19:33:49.778 E/Error   (  949):   at android.app.ActivityThread.-wrap11(ActivityThread.java)
08-16 19:33:49.778 E/Error   (  949):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
08-16 19:33:49.778 E/Error   (  949):   at android.os.Handler.dispatchMessage(Handler.java:102)
08-16 19:33:49.778 E/Error   (  949):   at android.os.Looper.loop(Looper.java:148)
08-16 19:33:49.778 E/Error   (  949):   at android.app.ActivityThread.main(ActivityThread.java:5422)
08-16 19:33:49.778 E/Error   (  949):   at java.lang.reflect.Method.invoke(Native Method)
08-16 19:33:49.778 E/Error   (  949):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-16 19:33:49.778 E/Error   (  949):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-16 19:33:49.778 E/Error   (  949): Caused by: java.sql.SQLException: Could not perform raw query for SELECT s.id as _id,  s.name, s.color, count(case when m.id > -1 or messages.read = 1 then 1 end) as unread FROM streams as s LEFT JOIN messages as m ON s.id=m.stream group by s.name order by s.name COLLATE NOCASE
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:25)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.dao.BaseDaoImpl.queryRaw(BaseDaoImpl.java:618)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.dao.RuntimeExceptionDao.queryRaw(RuntimeExceptionDao.java:480)
08-16 19:33:49.778 E/Error   (  949):   ... 17 more
08-16 19:33:49.778 E/Error   (  949): Caused by: java.sql.SQLException: Problems executing Android query: SELECT s.id as _id,  s.name, s.color, count(case when m.id > -1 or messages.read = 1 then 1 end) as unread FROM streams as s LEFT JOIN messages as m ON s.id=m.stream group by s.name order by s.name COLLATE NOCASE
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:27)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.android.AndroidCompiledStatement.getCursor(AndroidCompiledStatement.java:197)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.android.AndroidCompiledStatement.runQuery(AndroidCompiledStatement.java:72)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.stmt.SelectIterator.<init>(SelectIterator.java:57)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.stmt.RawResultsImpl.<init>(RawResultsImpl.java:30)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.stmt.StatementExecutor.queryRaw(StatementExecutor.java:276)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.dao.BaseDaoImpl.queryRaw(BaseDaoImpl.java:616)
08-16 19:33:49.778 E/Error   (  949):   ... 18 more
08-16 19:33:49.778 E/Error   (  949): Caused by: android.database.sqlite.SQLiteException: no such column: messages.read (code 1): , while compiling: SELECT s.id as _id,  s.name, s.color, count(case when m.id > -1 or messages.read = 1 then 1 end) as unread FROM streams as s LEFT JOIN messages as m ON s.id=m.stream group by s.name order by s.name COLLATE NOCASE
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
08-16 19:33:49.778 E/Error   (  949):   at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
08-16 19:33:49.778 E/Error   (  949):   at com.j256.ormlite.andr
@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Aug 17, 2016

Updated..:)

@niftynei

This comment has been minimized.

Contributor

niftynei commented Aug 22, 2016

Hey @kunall17. This code looks good but I've noticed a couple of issues with the functionality.

  1. The padding on the stream topics is really big (picture below)
  2. Clicking on a stream topic no longer narrows to that topic
  3. The read counts don't update as I read things

screenshot_20160822-155936

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Aug 23, 2016

Updated the branch!

@niftynei

This comment has been minimized.

Contributor

niftynei commented Aug 23, 2016

Thanks, this looks really great 💯

@niftynei niftynei closed this Aug 23, 2016

@timabbott

This comment has been minimized.

Member

timabbott commented Aug 23, 2016

Just a quick question -- does this also submit changes to which messages are read to the Zulip server?

@kunall17

This comment has been minimized.

Collaborator

kunall17 commented Aug 24, 2016

Na this doesn't have any interaction with the server, but yeah one easy fix would be update the pointer from the server as this relies on two things

  • The pointer it self
  • And a column in the messages table called 'read' which updates to true when the message is attached to the list.

And for checking if the message is unread the pointer is compared to message ID OR this column 'read' is checked!

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