mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
Update last seen state on desktop sync send
// FREEBIE
This commit is contained in:
parent
2395b79bfc
commit
8cd50d1e82
@ -1443,7 +1443,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
@Override
|
||||
protected Void doInBackground(Long... params) {
|
||||
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);
|
||||
MarkReadReceiver.process(context, messageIds);
|
||||
|
@ -476,7 +476,7 @@ public class ConversationListFragment extends Fragment
|
||||
DatabaseFactory.getThreadDatabase(getActivity()).archiveConversation(threadId);
|
||||
|
||||
if (!read) {
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(getActivity()).setRead(threadId);
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(getActivity()).setRead(threadId, false);
|
||||
MessageNotifier.updateNotification(getActivity(), masterSecret);
|
||||
MarkReadReceiver.process(getActivity(), messageIds);
|
||||
}
|
||||
|
@ -264,10 +264,14 @@ public class ThreadDatabase extends Database {
|
||||
notifyConversationListListeners();
|
||||
}
|
||||
|
||||
public List<MarkedMessageInfo> setRead(long threadId) {
|
||||
public List<MarkedMessageInfo> setRead(long threadId, boolean lastSeen) {
|
||||
ContentValues contentValues = new ContentValues(1);
|
||||
contentValues.put(READ, 1);
|
||||
|
||||
if (lastSeen) {
|
||||
contentValues.put(LAST_SEEN, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] {threadId+""});
|
||||
|
||||
|
@ -373,7 +373,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
}
|
||||
|
||||
if (threadId != null) {
|
||||
DatabaseFactory.getThreadDatabase(getContext()).setRead(threadId);
|
||||
DatabaseFactory.getThreadDatabase(getContext()).setRead(threadId, true);
|
||||
MessageNotifier.updateNotification(getContext(), masterSecret.getMasterSecret().orNull());
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,7 @@ public class AndroidAutoHeardReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
for (long threadId : threadIds) {
|
||||
Log.i(TAG, "Marking meassage as read: " + threadId);
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
||||
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
|
||||
|
||||
messageIdsCollection.addAll(messageIds);
|
||||
}
|
||||
|
@ -90,8 +90,7 @@ public class AndroidAutoReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false);
|
||||
}
|
||||
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(replyThreadId);
|
||||
DatabaseFactory.getThreadDatabase(context).setLastSeen(replyThreadId);
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(replyThreadId, true);
|
||||
|
||||
MessageNotifier.updateNotification(context, masterSecret);
|
||||
MarkReadReceiver.process(context, messageIds);
|
||||
|
@ -45,10 +45,8 @@ public class MarkReadReceiver extends MasterSecretBroadcastReceiver {
|
||||
|
||||
for (long threadId : threadIds) {
|
||||
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);
|
||||
|
||||
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
|
||||
}
|
||||
|
||||
process(context, messageIdsCollection);
|
||||
|
@ -223,7 +223,7 @@ public class MessageNotifier {
|
||||
.getRecipientsForThreadId(threadId);
|
||||
|
||||
if (isVisible) {
|
||||
List<MarkedMessageInfo> messageIds = threads.setRead(threadId);
|
||||
List<MarkedMessageInfo> messageIds = threads.setRead(threadId, false);
|
||||
MarkReadReceiver.process(context, messageIds);
|
||||
}
|
||||
|
||||
|
@ -80,8 +80,7 @@ public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver {
|
||||
threadId = MessageSender.send(context, masterSecret, reply, -1, false);
|
||||
}
|
||||
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
||||
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
|
||||
List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context).setRead(threadId, true);
|
||||
|
||||
MessageNotifier.updateNotification(context, masterSecret);
|
||||
MarkReadReceiver.process(context, messageIds);
|
||||
|
Loading…
x
Reference in New Issue
Block a user