mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-26 01:37:43 +00:00
Only update thread friend request status on message send if we haven't sent a previous request.
Always send self sync messages to our primary device. Cache conversation input enabled so that subsequent calls don't cause it to flicker.
This commit is contained in:
parent
5c1ec4c06d
commit
41e0934dd4
@ -329,6 +329,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
protected HidingLinearLayout quickAttachmentToggle;
|
protected HidingLinearLayout quickAttachmentToggle;
|
||||||
protected HidingLinearLayout inlineAttachmentToggle;
|
protected HidingLinearLayout inlineAttachmentToggle;
|
||||||
private InputPanel inputPanel;
|
private InputPanel inputPanel;
|
||||||
|
private boolean alwaysEnableInputPanel = false;
|
||||||
|
|
||||||
private LinkPreviewViewModel linkPreviewViewModel;
|
private LinkPreviewViewModel linkPreviewViewModel;
|
||||||
private ConversationSearchViewModel searchViewModel;
|
private ConversationSearchViewModel searchViewModel;
|
||||||
@ -2202,7 +2203,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateInputPanel() {
|
private void updateInputPanel() {
|
||||||
if (recipient.isGroupRecipient() || isNoteToSelf()) {
|
/*
|
||||||
|
alwaysEnableInputPanel caches whether we have enabled the input once.
|
||||||
|
|
||||||
|
This stops the case where the input panel disables and enables rapidly.
|
||||||
|
- This can occur when we are not friends with the current thread BUT multi-device tells us that we are friends with another one of their devices.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (recipient.isGroupRecipient() || isNoteToSelf() || alwaysEnableInputPanel) {
|
||||||
setInputPanelEnabled(true);
|
setInputPanelEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2212,9 +2220,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
boolean isPending = friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_SENDING || friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_SENT || friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_RECEIVED;
|
boolean isPending = friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_SENDING || friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_SENT || friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_RECEIVED;
|
||||||
setInputPanelEnabled(!isPending);
|
setInputPanelEnabled(!isPending);
|
||||||
|
|
||||||
|
alwaysEnableInputPanel = friendRequestStatus == LokiThreadFriendRequestStatus.FRIENDS;
|
||||||
|
|
||||||
// This promise correctly updates the UI for multidevice
|
// This promise correctly updates the UI for multidevice
|
||||||
if (friendRequestStatus != LokiThreadFriendRequestStatus.FRIENDS) {
|
if (friendRequestStatus != LokiThreadFriendRequestStatus.FRIENDS) {
|
||||||
MultiDeviceUtilities.shouldEnableUserInput(this, recipient).success(shouldEnableInput -> {
|
MultiDeviceUtilities.shouldEnableUserInput(this, recipient).success(shouldEnableInput -> {
|
||||||
|
alwaysEnableInputPanel = shouldEnableInput;
|
||||||
setInputPanelEnabled(shouldEnableInput);
|
setInputPanelEnabled(shouldEnableInput);
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
});
|
});
|
||||||
|
@ -303,7 +303,8 @@ public abstract class PushSendJob extends SendJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected SignalServiceSyncMessage buildSelfSendSyncMessage(@NonNull Context context, @NonNull SignalServiceDataMessage message, Optional<UnidentifiedAccessPair> syncAccess) {
|
protected SignalServiceSyncMessage buildSelfSendSyncMessage(@NonNull Context context, @NonNull SignalServiceDataMessage message, Optional<UnidentifiedAccessPair> syncAccess) {
|
||||||
String localNumber = TextSecurePreferences.getLocalNumber(context);
|
String primary = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||||
|
String localNumber = primary != null ? primary : TextSecurePreferences.getLocalNumber(context);
|
||||||
SentTranscriptMessage transcript = new SentTranscriptMessage(localNumber,
|
SentTranscriptMessage transcript = new SentTranscriptMessage(localNumber,
|
||||||
message.getTimestamp(),
|
message.getTimestamp(),
|
||||||
message,
|
message,
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package org.thoughtcrime.securesms.loki
|
package org.thoughtcrime.securesms.loki
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import nl.komponents.kovenant.Promise
|
|
||||||
import nl.komponents.kovenant.ui.alwaysUi
|
|
||||||
import nl.komponents.kovenant.ui.successUi
|
import nl.komponents.kovenant.ui.successUi
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.util.Util
|
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI
|
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus
|
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
||||||
import java.lang.IllegalStateException
|
import java.lang.IllegalStateException
|
||||||
@ -20,13 +16,20 @@ object FriendRequestHandler {
|
|||||||
val recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId) ?: return
|
val recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId) ?: return
|
||||||
if (!recipient.address.isPhone) { return }
|
if (!recipient.address.isPhone) { return }
|
||||||
|
|
||||||
// Update thread status
|
val currentFriendStatus = DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadId)
|
||||||
|
// Update thread status if we haven't sent a friend request before
|
||||||
|
if (currentFriendStatus != LokiThreadFriendRequestStatus.REQUEST_RECEIVED &&
|
||||||
|
currentFriendStatus != LokiThreadFriendRequestStatus.REQUEST_SENT &&
|
||||||
|
currentFriendStatus != LokiThreadFriendRequestStatus.FRIENDS
|
||||||
|
) {
|
||||||
val threadFriendStatus = when (type) {
|
val threadFriendStatus = when (type) {
|
||||||
ActionType.Sending -> LokiThreadFriendRequestStatus.REQUEST_SENDING
|
ActionType.Sending -> LokiThreadFriendRequestStatus.REQUEST_SENDING
|
||||||
ActionType.Failed -> LokiThreadFriendRequestStatus.NONE
|
ActionType.Failed -> LokiThreadFriendRequestStatus.NONE
|
||||||
ActionType.Sent -> LokiThreadFriendRequestStatus.REQUEST_SENT
|
ActionType.Sent -> LokiThreadFriendRequestStatus.REQUEST_SENT
|
||||||
}
|
}
|
||||||
DatabaseFactory.getLokiThreadDatabase(context).setFriendRequestStatus(threadId, threadFriendStatus)
|
DatabaseFactory.getLokiThreadDatabase(context).setFriendRequestStatus(threadId, threadFriendStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update message status
|
// Update message status
|
||||||
if (messageId >= 0) {
|
if (messageId >= 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user