Update last seen state on desktop sync send

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-02-22 15:05:35 -08:00
parent 2395b79bfc
commit 8cd50d1e82
9 changed files with 13 additions and 14 deletions

View File

@ -1443,7 +1443,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override @Override
protected Void doInBackground(Long... params) { protected Void doInBackground(Long... params) {
Context context = ConversationActivity.this; Context context = ConversationActivity.this;
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(params[0]); List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(params[0], false);
MessageNotifier.updateNotification(context, masterSecret); MessageNotifier.updateNotification(context, masterSecret);
MarkReadReceiver.process(context, messageIds); MarkReadReceiver.process(context, messageIds);

View File

@ -476,7 +476,7 @@ public class ConversationListFragment extends Fragment
DatabaseFactory.getThreadDatabase(getActivity()).archiveConversation(threadId); DatabaseFactory.getThreadDatabase(getActivity()).archiveConversation(threadId);
if (!read) { if (!read) {
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(getActivity()).setRead(threadId); List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(getActivity()).setRead(threadId, false);
MessageNotifier.updateNotification(getActivity(), masterSecret); MessageNotifier.updateNotification(getActivity(), masterSecret);
MarkReadReceiver.process(getActivity(), messageIds); MarkReadReceiver.process(getActivity(), messageIds);
} }

View File

@ -264,10 +264,14 @@ public class ThreadDatabase extends Database {
notifyConversationListListeners(); notifyConversationListListeners();
} }
public List<MarkedMessageInfo> setRead(long threadId) { public List<MarkedMessageInfo> setRead(long threadId, boolean lastSeen) {
ContentValues contentValues = new ContentValues(1); ContentValues contentValues = new ContentValues(1);
contentValues.put(READ, 1); contentValues.put(READ, 1);
if (lastSeen) {
contentValues.put(LAST_SEEN, System.currentTimeMillis());
}
SQLiteDatabase db = databaseHelper.getWritableDatabase(); SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] {threadId+""}); db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] {threadId+""});

View File

@ -373,7 +373,7 @@ public class PushDecryptJob extends ContextJob {
} }
if (threadId != null) { if (threadId != null) {
DatabaseFactory.getThreadDatabase(getContext()).setRead(threadId); DatabaseFactory.getThreadDatabase(getContext()).setRead(threadId, true);
MessageNotifier.updateNotification(getContext(), masterSecret.getMasterSecret().orNull()); MessageNotifier.updateNotification(getContext(), masterSecret.getMasterSecret().orNull());
} }

View File

@ -61,8 +61,7 @@ public class AndroidAutoHeardReceiver extends MasterSecretBroadcastReceiver {
for (long threadId : threadIds) { for (long threadId : threadIds) {
Log.i(TAG, "Marking meassage as read: " + threadId); Log.i(TAG, "Marking meassage as read: " + threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId); List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
messageIdsCollection.addAll(messageIds); messageIdsCollection.addAll(messageIds);
} }

View File

@ -90,8 +90,7 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false); replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false);
} }
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(replyThreadId); List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(replyThreadId, true);
DatabaseFactory.getThreadDatabase(context).setLastSeen(replyThreadId);
MessageNotifier.updateNotification(context, masterSecret); MessageNotifier.updateNotification(context, masterSecret);
MarkReadReceiver.process(context, messageIds); MarkReadReceiver.process(context, messageIds);

View File

@ -45,10 +45,8 @@ public class MarkReadReceiver extends MasterSecretBroadcastReceiver {
for (long threadId : threadIds) { for (long threadId : threadIds) {
Log.w(TAG, "Marking as read: " + threadId); Log.w(TAG, "Marking as read: " + threadId);
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId); List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
messageIdsCollection.addAll(messageIds); messageIdsCollection.addAll(messageIds);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
} }
process(context, messageIdsCollection); process(context, messageIdsCollection);

View File

@ -223,7 +223,7 @@ public class MessageNotifier {
.getRecipientsForThreadId(threadId); .getRecipientsForThreadId(threadId);
if (isVisible) { if (isVisible) {
List<MarkedMessageInfo> messageIds = threads.setRead(threadId); List<MarkedMessageInfo> messageIds = threads.setRead(threadId, false);
MarkReadReceiver.process(context, messageIds); MarkReadReceiver.process(context, messageIds);
} }

View File

@ -80,8 +80,7 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
threadId = MessageSender.send(context, masterSecret, reply, -1, false); threadId = MessageSender.send(context, masterSecret, reply, -1, false);
} }
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId); List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
MessageNotifier.updateNotification(context, masterSecret); MessageNotifier.updateNotification(context, masterSecret);
MarkReadReceiver.process(context, messageIds); MarkReadReceiver.process(context, messageIds);