use of org.thoughtcrime.securesms.database.MessageDatabase.MarkedMessageInfo in project Signal-Android by signalapp.
the class ThreadDatabase method setReadSince.
public List<MarkedMessageInfo> setReadSince(Map<Long, Long> threadIdToSinceTimestamp, boolean lastSeen) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
List<MarkedMessageInfo> smsRecords = new LinkedList<>();
List<MarkedMessageInfo> mmsRecords = new LinkedList<>();
boolean needsSync = false;
db.beginTransaction();
try {
ContentValues contentValues = new ContentValues(2);
contentValues.put(READ, ReadStatus.READ.serialize());
for (Map.Entry<Long, Long> entry : threadIdToSinceTimestamp.entrySet()) {
long threadId = entry.getKey();
long sinceTimestamp = entry.getValue();
if (lastSeen) {
contentValues.put(LAST_SEEN, sinceTimestamp == -1 ? System.currentTimeMillis() : sinceTimestamp);
}
ThreadRecord previous = getThreadRecord(threadId);
smsRecords.addAll(SignalDatabase.sms().setMessagesReadSince(threadId, sinceTimestamp));
mmsRecords.addAll(SignalDatabase.mms().setMessagesReadSince(threadId, sinceTimestamp));
SignalDatabase.sms().setReactionsSeen(threadId, sinceTimestamp);
SignalDatabase.mms().setReactionsSeen(threadId, sinceTimestamp);
int unreadCount = SignalDatabase.mmsSms().getUnreadCount(threadId);
contentValues.put(UNREAD_COUNT, unreadCount);
db.update(TABLE_NAME, contentValues, ID_WHERE, SqlUtil.buildArgs(threadId));
if (previous != null && previous.isForcedUnread()) {
SignalDatabase.recipients().markNeedsSync(previous.getRecipient().getId());
needsSync = true;
}
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
notifyVerboseConversationListeners(threadIdToSinceTimestamp.keySet());
notifyConversationListListeners();
if (needsSync) {
StorageSyncHelper.scheduleSyncForDataChange();
}
return Util.concatenatedList(smsRecords, mmsRecords);
}
use of org.thoughtcrime.securesms.database.MessageDatabase.MarkedMessageInfo in project Signal-Android by signalapp.
the class SendViewedReceiptJob method enqueue.
/**
* Enqueues all the necessary jobs for viewed receipts, ensuring that they're all within the
* maximum size.
*/
public static void enqueue(long threadId, @NonNull RecipientId recipientId, List<MarkedMessageInfo> markedMessageInfos) {
JobManager jobManager = ApplicationDependencies.getJobManager();
List<List<MarkedMessageInfo>> messageIdChunks = Util.chunk(markedMessageInfos, MAX_TIMESTAMPS);
if (messageIdChunks.size() > 1) {
Log.w(TAG, "Large receipt count! Had to break into multiple chunks. Total count: " + markedMessageInfos.size());
}
for (List<MarkedMessageInfo> chunk : messageIdChunks) {
List<Long> sentTimestamps = chunk.stream().map(info -> info.getSyncMessageId().getTimetamp()).collect(Collectors.toList());
List<MessageId> messageIds = chunk.stream().map(MarkedMessageInfo::getMessageId).collect(Collectors.toList());
jobManager.add(new SendViewedReceiptJob(threadId, recipientId, sentTimestamps, messageIds));
}
}
use of org.thoughtcrime.securesms.database.MessageDatabase.MarkedMessageInfo in project Signal-Android by WhisperSystems.
the class ConversationListFragment method handleMarkAllRead.
private void handleMarkAllRead() {
Context context = requireContext();
SignalExecutors.BOUNDED.execute(() -> {
List<MarkedMessageInfo> messageIds = SignalDatabase.threads().setAllThreadsRead();
ApplicationDependencies.getMessageNotifier().updateNotification(context);
MarkReadReceiver.process(context, messageIds);
});
}
use of org.thoughtcrime.securesms.database.MessageDatabase.MarkedMessageInfo in project Signal-Android by WhisperSystems.
the class ConversationListFragment method handleMarkAsRead.
private void handleMarkAsRead(@NonNull Collection<Long> ids) {
Context context = requireContext();
SimpleTask.run(getViewLifecycleOwner().getLifecycle(), () -> {
List<MarkedMessageInfo> messageIds = SignalDatabase.threads().setRead(ids, false);
ApplicationDependencies.getMessageNotifier().updateNotification(context);
MarkReadReceiver.process(context, messageIds);
return null;
}, none -> {
endActionModeIfActive();
});
}
use of org.thoughtcrime.securesms.database.MessageDatabase.MarkedMessageInfo in project Signal-Android by WhisperSystems.
the class ThreadDatabase method setReadSince.
public List<MarkedMessageInfo> setReadSince(Map<Long, Long> threadIdToSinceTimestamp, boolean lastSeen) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
List<MarkedMessageInfo> smsRecords = new LinkedList<>();
List<MarkedMessageInfo> mmsRecords = new LinkedList<>();
boolean needsSync = false;
db.beginTransaction();
try {
ContentValues contentValues = new ContentValues(2);
contentValues.put(READ, ReadStatus.READ.serialize());
for (Map.Entry<Long, Long> entry : threadIdToSinceTimestamp.entrySet()) {
long threadId = entry.getKey();
long sinceTimestamp = entry.getValue();
if (lastSeen) {
contentValues.put(LAST_SEEN, sinceTimestamp == -1 ? System.currentTimeMillis() : sinceTimestamp);
}
ThreadRecord previous = getThreadRecord(threadId);
smsRecords.addAll(SignalDatabase.sms().setMessagesReadSince(threadId, sinceTimestamp));
mmsRecords.addAll(SignalDatabase.mms().setMessagesReadSince(threadId, sinceTimestamp));
SignalDatabase.sms().setReactionsSeen(threadId, sinceTimestamp);
SignalDatabase.mms().setReactionsSeen(threadId, sinceTimestamp);
int unreadCount = SignalDatabase.mmsSms().getUnreadCount(threadId);
contentValues.put(UNREAD_COUNT, unreadCount);
db.update(TABLE_NAME, contentValues, ID_WHERE, SqlUtil.buildArgs(threadId));
if (previous != null && previous.isForcedUnread()) {
SignalDatabase.recipients().markNeedsSync(previous.getRecipient().getId());
needsSync = true;
}
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
notifyVerboseConversationListeners(threadIdToSinceTimestamp.keySet());
notifyConversationListListeners();
if (needsSync) {
StorageSyncHelper.scheduleSyncForDataChange();
}
return Util.concatenatedList(smsRecords, mmsRecords);
}
Aggregations