use of org.thoughtcrime.securesms.database.MessageDatabase.MessageUpdate in project Signal-Android by WhisperSystems.
the class MmsSmsDatabase method incrementReceiptCounts.
/**
* Wraps multiple receipt updates in a transaction and triggers the proper updates.
*
* @return All of the messages that didn't result in updates.
*/
@NonNull
private Collection<SyncMessageId> incrementReceiptCounts(@NonNull List<SyncMessageId> syncMessageIds, long timestamp, @NonNull MessageDatabase.ReceiptType receiptType) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
ThreadDatabase threadDatabase = SignalDatabase.threads();
Set<MessageUpdate> messageUpdates = new HashSet<>();
Collection<SyncMessageId> unhandled = new HashSet<>();
db.beginTransaction();
try {
for (SyncMessageId id : syncMessageIds) {
Set<MessageUpdate> updates = incrementReceiptCountInternal(id, timestamp, receiptType);
if (updates.size() > 0) {
messageUpdates.addAll(updates);
} else {
unhandled.add(id);
}
}
for (MessageUpdate update : messageUpdates) {
threadDatabase.updateSilently(update.getThreadId(), false);
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(update.getMessageId());
ApplicationDependencies.getDatabaseObserver().notifyVerboseConversationListeners(Collections.singleton(update.getThreadId()));
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (messageUpdates.size() > 0) {
notifyConversationListListeners();
}
}
return unhandled;
}
use of org.thoughtcrime.securesms.database.MessageDatabase.MessageUpdate in project Signal-Android by signalapp.
the class MmsSmsDatabase method incrementReceiptCounts.
/**
* Wraps multiple receipt updates in a transaction and triggers the proper updates.
*
* @return All of the messages that didn't result in updates.
*/
@NonNull
private Collection<SyncMessageId> incrementReceiptCounts(@NonNull List<SyncMessageId> syncMessageIds, long timestamp, @NonNull MessageDatabase.ReceiptType receiptType) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
ThreadDatabase threadDatabase = SignalDatabase.threads();
Set<MessageUpdate> messageUpdates = new HashSet<>();
Collection<SyncMessageId> unhandled = new HashSet<>();
db.beginTransaction();
try {
for (SyncMessageId id : syncMessageIds) {
Set<MessageUpdate> updates = incrementReceiptCountInternal(id, timestamp, receiptType);
if (updates.size() > 0) {
messageUpdates.addAll(updates);
} else {
unhandled.add(id);
}
}
for (MessageUpdate update : messageUpdates) {
threadDatabase.updateSilently(update.getThreadId(), false);
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(update.getMessageId());
ApplicationDependencies.getDatabaseObserver().notifyVerboseConversationListeners(Collections.singleton(update.getThreadId()));
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
if (messageUpdates.size() > 0) {
notifyConversationListListeners();
}
}
return unhandled;
}
use of org.thoughtcrime.securesms.database.MessageDatabase.MessageUpdate in project Signal-Android by WhisperSystems.
the class MmsSmsDatabase method incrementReceiptCount.
/**
* Wraps a single receipt update in a transaction and triggers the proper updates.
*
* @return Whether or not some thread was updated.
*/
private boolean incrementReceiptCount(SyncMessageId syncMessageId, long timestamp, @NonNull MessageDatabase.ReceiptType receiptType) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
ThreadDatabase threadDatabase = SignalDatabase.threads();
Set<MessageUpdate> messageUpdates = new HashSet<>();
db.beginTransaction();
try {
messageUpdates = incrementReceiptCountInternal(syncMessageId, timestamp, receiptType);
for (MessageUpdate messageUpdate : messageUpdates) {
threadDatabase.update(messageUpdate.getThreadId(), false);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
for (MessageUpdate threadUpdate : messageUpdates) {
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(threadUpdate.getMessageId());
}
}
return messageUpdates.size() > 0;
}
use of org.thoughtcrime.securesms.database.MessageDatabase.MessageUpdate in project Signal-Android by signalapp.
the class MmsSmsDatabase method incrementReceiptCount.
/**
* Wraps a single receipt update in a transaction and triggers the proper updates.
*
* @return Whether or not some thread was updated.
*/
private boolean incrementReceiptCount(SyncMessageId syncMessageId, long timestamp, @NonNull MessageDatabase.ReceiptType receiptType) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
ThreadDatabase threadDatabase = SignalDatabase.threads();
Set<MessageUpdate> messageUpdates = new HashSet<>();
db.beginTransaction();
try {
messageUpdates = incrementReceiptCountInternal(syncMessageId, timestamp, receiptType);
for (MessageUpdate messageUpdate : messageUpdates) {
threadDatabase.update(messageUpdate.getThreadId(), false);
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
for (MessageUpdate threadUpdate : messageUpdates) {
ApplicationDependencies.getDatabaseObserver().notifyMessageUpdateObservers(threadUpdate.getMessageId());
}
}
return messageUpdates.size() > 0;
}
Aggregations