Fix message deletion & connectivity bug

This commit is contained in:
Niels Andriesse 2020-01-17 10:06:32 +11:00
parent 362256dc94
commit ec2691a918
3 changed files with 49 additions and 39 deletions

View File

@ -510,7 +510,6 @@ public class ConversationFragment extends Fragment
builder.setMessage(getActivity().getResources().getQuantityString(R.plurals.ConversationFragment_this_will_permanently_delete_all_n_selected_messages, messagesCount, messagesCount));
builder.setCancelable(true);
// Loki - The delete option is only visible to the user in a public chat
LokiPublicChat publicChat = DatabaseFactory.getLokiThreadDatabase(getContext()).getPublicChat(threadId);
builder.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
@ -522,6 +521,7 @@ public class ConversationFragment extends Fragment
{
@Override
protected Void doInBackground(MessageRecord... messageRecords) {
if (publicChat != null) {
ArrayList<Long> serverIDs = new ArrayList<>();
ArrayList<Long> ignoredMessages = new ArrayList<>();
ArrayList<Long> failedMessages = new ArrayList<>();
@ -559,6 +559,15 @@ public class ConversationFragment extends Fragment
return null;
});
}
} else {
for (MessageRecord messageRecord : messageRecords) {
if (messageRecord.isMms()) {
DatabaseFactory.getMmsDatabase(getActivity()).delete(messageRecord.getId());
} else {
DatabaseFactory.getSmsDatabase(getActivity()).deleteMessage(messageRecord.getId());
}
}
}
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, messageRecords.toArray(new MessageRecord[messageRecords.size()]));

View File

@ -40,11 +40,12 @@ class DisplayNameActivity : BaseActionBarActivity() {
TextSecurePreferences.setProfileName(this, displayName)
TextSecurePreferences.setHasSeenWelcomeScreen(this, true)
TextSecurePreferences.setPromptedPushRegistration(this, true)
val application = ApplicationContext.getInstance(this)
application.setUpStorageAPIIfNeeded()
application.setUpP2PAPI()
val publicChatAPI = ApplicationContext.getInstance(this).lokiPublicChatAPI
if (publicChatAPI != null) {
// TODO: This won't be necessary anymore when we don't auto-join the Loki Public Chat anymore
val application = ApplicationContext.getInstance(this)
application.setUpStorageAPIIfNeeded()
application.createDefaultPublicChatsIfNeeded()
val servers = DatabaseFactory.getLokiThreadDatabase(this).getAllPublicChatServers()
servers.forEach { publicChatAPI.setDisplayName(displayName, it) }

View File

@ -80,7 +80,7 @@ class JoinPublicChatActivity : PassphraseRequiredActionBarActivity(), ScanQRCode
finish()
}.failUi {
hideLoader()
Toast.makeText(this, "Couldn't Join Channel", Toast.LENGTH_SHORT).show()
Toast.makeText(this, "Couldn't join channel", Toast.LENGTH_SHORT).show()
}
}
// endregion