fix: replace the mark read receiver (from notifications) to use the new set last seen mark read logic

This commit is contained in:
0x330a 2023-02-21 14:44:32 +11:00
parent 621e564023
commit 0dff619aa9
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C
2 changed files with 7 additions and 10 deletions

View File

@ -12,8 +12,11 @@ import androidx.core.app.NotificationManagerCompat;
import com.annimon.stream.Collectors; import com.annimon.stream.Collectors;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import org.session.libsession.database.StorageProtocol;
import org.session.libsession.messaging.MessagingModuleConfiguration;
import org.session.libsession.messaging.messages.control.ReadReceipt; import org.session.libsession.messaging.messages.control.ReadReceipt;
import org.session.libsession.messaging.sending_receiving.MessageSender; import org.session.libsession.messaging.sending_receiving.MessageSender;
import org.session.libsession.snode.SnodeAPI;
import org.session.libsession.utilities.Address; import org.session.libsession.utilities.Address;
import org.session.libsession.utilities.TextSecurePreferences; import org.session.libsession.utilities.TextSecurePreferences;
import org.session.libsession.utilities.recipients.Recipient; import org.session.libsession.utilities.recipients.Recipient;
@ -26,7 +29,6 @@ import org.thoughtcrime.securesms.dependencies.DatabaseComponent;
import org.thoughtcrime.securesms.service.ExpiringMessageManager; import org.thoughtcrime.securesms.service.ExpiringMessageManager;
import org.thoughtcrime.securesms.util.SessionMetaProtocol; import org.thoughtcrime.securesms.util.SessionMetaProtocol;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -51,18 +53,12 @@ public class MarkReadReceiver extends BroadcastReceiver {
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
List<MarkedMessageInfo> messageIdsCollection = new LinkedList<>(); long currentTime = SnodeAPI.getNowWithOffset();
for (long threadId : threadIds) { for (long threadId : threadIds) {
Log.i(TAG, "Marking as read: " + threadId); Log.i(TAG, "Marking as read: " + threadId);
List<MarkedMessageInfo> messageIds = DatabaseComponent.get(context).threadDatabase().setRead(threadId, true); StorageProtocol storage = MessagingModuleConfiguration.getShared().getStorage();
messageIdsCollection.addAll(messageIds); storage.markConversationAsRead(threadId,currentTime);
} }
process(context, messageIdsCollection);
ApplicationContext.getInstance(context).messageNotifier.updateNotification(context);
return null; return null;
} }
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

View File

@ -56,6 +56,7 @@ object SnodeAPI {
*/ */
internal var clockOffset = 0L internal var clockOffset = 0L
@JvmStatic
val nowWithOffset val nowWithOffset
get() = System.currentTimeMillis() + clockOffset get() = System.currentTimeMillis() + clockOffset