mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 21:29:54 +01:00
Only remove PendingContact from UI when removed from DB
This commit is contained in:
@@ -79,8 +79,10 @@ public interface ContactManager {
|
|||||||
/**
|
/**
|
||||||
* Removes a {@link PendingContact} that is in state
|
* Removes a {@link PendingContact} that is in state
|
||||||
* {@link PendingContactState FAILED}.
|
* {@link PendingContactState FAILED}.
|
||||||
|
* @param commitAction an action to run on the main thread after removing.
|
||||||
*/
|
*/
|
||||||
void removePendingContact(PendingContact pendingContact) throws DbException;
|
void removePendingContact(PendingContact pendingContact,
|
||||||
|
Runnable commitAction) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the contact with the given ID.
|
* Returns the contact with the given ID.
|
||||||
|
|||||||
@@ -222,9 +222,15 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePendingContact(PendingContact pendingContact) {
|
public void removePendingContact(PendingContact pendingContact,
|
||||||
|
Runnable commitAction) throws DbException {
|
||||||
// TODO replace with real implementation
|
// TODO replace with real implementation
|
||||||
pendingContacts.remove(pendingContact);
|
pendingContacts.remove(pendingContact);
|
||||||
|
try {
|
||||||
|
Thread.sleep(250);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
db.transaction(true, txn -> txn.attach(commitAction));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ public class PendingContactListActivity extends BriarActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailedPendingContactRemoved(PendingContact pendingContact) {
|
public void onFailedPendingContactRemoved(PendingContact pendingContact) {
|
||||||
adapter.remove(pendingContact);
|
viewModel.removePendingContact(pendingContact,
|
||||||
viewModel.removePendingContact(pendingContact);
|
() -> adapter.remove(pendingContact));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPendingContactsChanged(Collection<PendingContact> contacts) {
|
private void onPendingContactsChanged(Collection<PendingContact> contacts) {
|
||||||
|
|||||||
@@ -81,10 +81,12 @@ public class PendingContactListViewModel extends AndroidViewModel
|
|||||||
return pendingContacts;
|
return pendingContacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removePendingContact(PendingContact pendingContact) {
|
void removePendingContact(PendingContact pendingContact,
|
||||||
|
Runnable commitAction) {
|
||||||
dbExecutor.execute(() -> {
|
dbExecutor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
contactManager.removePendingContact(pendingContact);
|
contactManager
|
||||||
|
.removePendingContact(pendingContact, commitAction);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
logException(LOG, WARNING, e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user