clean up conversation history after swtiching to a different conversation
This commit is contained in:
parent
de952cc959
commit
f00e168752
|
@ -19,6 +19,7 @@ public final class Config {
|
||||||
public static final int MESSAGE_MERGE_WINDOW = 20;
|
public static final int MESSAGE_MERGE_WINDOW = 20;
|
||||||
|
|
||||||
public static final int PAGE_SIZE = 50;
|
public static final int PAGE_SIZE = 50;
|
||||||
|
public static final int MAX_NUM_PAGES = 3;
|
||||||
|
|
||||||
public static final int PROGRESS_UI_UPDATE_INTERVAL = 750;
|
public static final int PROGRESS_UI_UPDATE_INTERVAL = 750;
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,16 @@ public class Conversation extends AbstractEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void trim() {
|
||||||
|
synchronized (this.messages) {
|
||||||
|
final int size = messages.size();
|
||||||
|
final int maxsize = Config.PAGE_SIZE * Config.MAX_NUM_PAGES;
|
||||||
|
if (size > maxsize) {
|
||||||
|
this.messages.subList(0, size - maxsize).clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void findUnsentMessagesWithOtrEncryption(OnMessageFound onMessageFound) {
|
public void findUnsentMessagesWithOtrEncryption(OnMessageFound onMessageFound) {
|
||||||
synchronized (this.messages) {
|
synchronized (this.messages) {
|
||||||
for (Message message : this.messages) {
|
for (Message message : this.messages) {
|
||||||
|
@ -265,10 +275,6 @@ public class Conversation extends AbstractEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProfilePhotoString() {
|
|
||||||
return this.getContact().getProfilePhoto();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccountUuid() {
|
public String getAccountUuid() {
|
||||||
return this.accountUuid;
|
return this.accountUuid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -554,6 +554,7 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
if (this.conversation != null) {
|
if (this.conversation != null) {
|
||||||
this.conversation.setNextMessage(mEditMessage.getText().toString());
|
this.conversation.setNextMessage(mEditMessage.getText().toString());
|
||||||
|
this.conversation.trim();
|
||||||
}
|
}
|
||||||
this.activity = (ConversationActivity) getActivity();
|
this.activity = (ConversationActivity) getActivity();
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
|
|
Loading…
Reference in a new issue