do not highlight users when not participating. fixes #2865

This commit is contained in:
Daniel Gultsch 2018-03-12 16:00:02 +01:00
parent 8dc17a96ba
commit 22d98bd162
2 changed files with 16 additions and 11 deletions

View File

@ -1663,6 +1663,7 @@ public class XmppConnectionService extends Service {
return conversation; return conversation;
} }
conversation = databaseBackend.findConversation(account, jid); conversation = databaseBackend.findConversation(account, jid);
Log.d(Config.LOGTAG,"loaded from db: "+conversation.getNextMessage());
final boolean loadMessagesFromDb; final boolean loadMessagesFromDb;
if (conversation != null) { if (conversation != null) {
conversation.setStatus(Conversation.STATUS_AVAILABLE); conversation.setStatus(Conversation.STATUS_AVAILABLE);
@ -1732,6 +1733,7 @@ public class XmppConnectionService extends Service {
public void archiveConversation(Conversation conversation) { public void archiveConversation(Conversation conversation) {
getNotificationService().clear(conversation); getNotificationService().clear(conversation);
conversation.setStatus(Conversation.STATUS_ARCHIVED); conversation.setStatus(Conversation.STATUS_ARCHIVED);
conversation.setNextMessage(null);
synchronized (this.conversations) { synchronized (this.conversations) {
getMessageArchiveService().kill(conversation); getMessageArchiveService().kill(conversation);
if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getMode() == Conversation.MODE_MULTI) {
@ -3028,12 +3030,7 @@ public class XmppConnectionService extends Service {
} }
public void updateConversation(final Conversation conversation) { public void updateConversation(final Conversation conversation) {
mDatabaseWriterExecutor.execute(new Runnable() { mDatabaseWriterExecutor.execute(() -> databaseBackend.updateConversation(conversation));
@Override
public void run() {
databaseBackend.updateConversation(conversation);
}
});
} }
private void reconnectAccount(final Account account, final boolean force, final boolean interactive) { private void reconnectAccount(final Account account, final boolean force, final boolean interactive) {

View File

@ -876,10 +876,15 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (message.getConversation().getMode() == Conversation.MODE_MULTI) { if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
Jid user = message.getCounterpart(); Jid user = message.getCounterpart();
if (user != null && !user.isBareJid()) { if (user != null && !user.isBareJid()) {
if (!message.getConversation().getMucOptions().isUserInRoom(user)) { final MucOptions mucOptions = message.getConversation().getMucOptions();
if (mucOptions.participating() || message.getConversation().getNextCounterpart() != null) {
if (!mucOptions.isUserInRoom(user)) {
Toast.makeText(getActivity(), activity.getString(R.string.user_has_left_conference, user.getResource()), Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), activity.getString(R.string.user_has_left_conference, user.getResource()), Toast.LENGTH_SHORT).show();
} }
highlightInConference(user.getResource()); highlightInConference(user.getResource());
} else {
Toast.makeText(getActivity(),R.string.you_are_not_participating, Toast.LENGTH_SHORT).show();
}
} }
return; return;
} else { } else {
@ -1732,7 +1737,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
if (this.conversation != null) { if (this.conversation != null) {
final String msg = this.binding.textinput.getText().toString(); final String msg = this.binding.textinput.getText().toString();
if (this.conversation.setNextMessage(msg)) { if (this.conversation.getStatus() != Conversation.STATUS_ARCHIVED && this.conversation.setNextMessage(msg)) {
this.activity.xmppConnectionService.updateConversation(this.conversation); this.activity.xmppConnectionService.updateConversation(this.conversation);
} }
updateChatState(this.conversation, msg); updateChatState(this.conversation, msg);
@ -1867,8 +1872,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
//do nothing //do nothing
} }
} else { } else {
final MucOptions mucOptions = conversation.getMucOptions();
if (mucOptions.participating() || conversation.getNextCounterpart() != null) {
highlightInConference(nick); highlightInConference(nick);
} }
}
} else { } else {
appendText(text); appendText(text);
} }