kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix crash when deleting threads directly after backup restore.
rodzic
0a7a7cf5a9
commit
51a521594f
|
@ -905,7 +905,8 @@ public class ThreadDatabase extends Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteConversation(long threadId) {
|
public void deleteConversation(long threadId) {
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
|
RecipientId recipientIdForThreadId = getRecipientIdForThreadId(threadId);
|
||||||
|
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
|
@ -922,11 +923,12 @@ public class ThreadDatabase extends Database {
|
||||||
|
|
||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
ConversationUtil.clearShortcuts(context, Collections.singleton(threadId));
|
ConversationUtil.clearShortcuts(context, Collections.singleton(recipientIdForThreadId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteConversations(Set<Long> selectedConversations) {
|
public void deleteConversations(Set<Long> selectedConversations) {
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||||
|
List<RecipientId> recipientIdsForThreadIds = getRecipientIdsForThreadIds(selectedConversations);
|
||||||
|
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
|
@ -952,7 +954,7 @@ public class ThreadDatabase extends Database {
|
||||||
|
|
||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
notifyConversationListeners(selectedConversations);
|
notifyConversationListeners(selectedConversations);
|
||||||
ConversationUtil.clearShortcuts(context, selectedConversations);
|
ConversationUtil.clearShortcuts(context, recipientIdsForThreadIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAllConversations() {
|
public void deleteAllConversations() {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
import androidx.core.app.Person;
|
import androidx.core.app.Person;
|
||||||
import androidx.core.content.pm.ShortcutInfoCompat;
|
import androidx.core.content.pm.ShortcutInfoCompat;
|
||||||
|
@ -26,10 +25,10 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConversationUtil encapsulates support for Android 11+'s new Conversations system
|
* ConversationUtil encapsulates support for Android 11+'s new Conversations system
|
||||||
|
@ -92,11 +91,9 @@ public final class ConversationUtil {
|
||||||
/**
|
/**
|
||||||
* Clears the shortcuts tied to a given thread.
|
* Clears the shortcuts tied to a given thread.
|
||||||
*/
|
*/
|
||||||
public static void clearShortcuts(@NonNull Context context, @NonNull Set<Long> threadIds) {
|
public static void clearShortcuts(@NonNull Context context, @NonNull Collection<RecipientId> recipientIds) {
|
||||||
SignalExecutors.BOUNDED.execute(() -> {
|
SignalExecutors.BOUNDED.execute(() -> {
|
||||||
List<RecipientId> recipientIds = DatabaseFactory.getThreadDatabase(context).getRecipientIdsForThreadIds(threadIds);
|
ShortcutManagerCompat.removeLongLivedShortcuts(context, Stream.of(recipientIds).withoutNulls().map(ConversationUtil::getShortcutId).toList());
|
||||||
|
|
||||||
ShortcutManagerCompat.removeLongLivedShortcuts(context, Stream.of(recipientIds).map(ConversationUtil::getShortcutId).toList());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue