mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-02 14:35:21 +00:00
Don't let outgoing messages trigger last seen divider
Closes #6306 // FREEBIE
This commit is contained in:
parent
1d3f1cc79e
commit
8f96cff104
@ -289,7 +289,7 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
|
|||||||
Cursor cursor = getCursorAtPositionOrThrow(i);
|
Cursor cursor = getCursorAtPositionOrThrow(i);
|
||||||
MessageRecord messageRecord = getMessageRecord(cursor);
|
MessageRecord messageRecord = getMessageRecord(cursor);
|
||||||
|
|
||||||
if (messageRecord.getDateReceived() <= lastSeen) {
|
if (messageRecord.isOutgoing() || messageRecord.getDateReceived() <= lastSeen) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,7 +345,8 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
|
|||||||
Cursor cursor = getCursorAtPositionOrThrow(position);
|
Cursor cursor = getCursorAtPositionOrThrow(position);
|
||||||
MessageRecord messageRecord = getMessageRecord(cursor);
|
MessageRecord messageRecord = getMessageRecord(cursor);
|
||||||
|
|
||||||
return messageRecord.getDateReceived();
|
if (messageRecord.isOutgoing()) return 0;
|
||||||
|
else return messageRecord.getDateReceived();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -412,6 +412,7 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
||||||
|
Log.w(TAG, "onLoadFinished");
|
||||||
ConversationLoader loader = (ConversationLoader)cursorLoader;
|
ConversationLoader loader = (ConversationLoader)cursorLoader;
|
||||||
|
|
||||||
if (list.getAdapter() != null) {
|
if (list.getAdapter() != null) {
|
||||||
@ -427,10 +428,16 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
getListAdapter().changeCursor(cursor);
|
getListAdapter().changeCursor(cursor);
|
||||||
|
|
||||||
|
int lastSeenPosition = getListAdapter().findLastSeenPosition(lastSeen);
|
||||||
|
|
||||||
if (firstLoad) {
|
if (firstLoad) {
|
||||||
scrollToLastSeenPosition(lastSeen);
|
scrollToLastSeenPosition(lastSeenPosition);
|
||||||
firstLoad = false;
|
firstLoad = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastSeenPosition <= 0) {
|
||||||
|
setLastSeen(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,9 +448,7 @@ public class ConversationFragment extends Fragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scrollToLastSeenPosition(long lastSeen) {
|
private void scrollToLastSeenPosition(final int lastSeenPosition) {
|
||||||
final int lastSeenPosition = getListAdapter().findLastSeenPosition(lastSeen);
|
|
||||||
|
|
||||||
if (lastSeenPosition > 0) {
|
if (lastSeenPosition > 0) {
|
||||||
list.post(new Runnable() {
|
list.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -451,8 +456,6 @@ public class ConversationFragment extends Fragment
|
|||||||
((LinearLayoutManager)list.getLayoutManager()).scrollToPositionWithOffset(lastSeenPosition, list.getHeight());
|
((LinearLayoutManager)list.getLayoutManager()).scrollToPositionWithOffset(lastSeenPosition, list.getHeight());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
setLastSeen(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,6 +911,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
long messageId = insertMediaMessage(masterSecret, addresses, message.getBody(),
|
long messageId = insertMediaMessage(masterSecret, addresses, message.getBody(),
|
||||||
message.getAttachments(), contentValues);
|
message.getAttachments(), contentValues);
|
||||||
|
|
||||||
|
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
|
||||||
jobManager.add(new TrimThreadJob(context, threadId));
|
jobManager.add(new TrimThreadJob(context, threadId));
|
||||||
|
|
||||||
return messageId;
|
return messageId;
|
||||||
|
@ -614,6 +614,7 @@ public class SmsDatabase extends MessagingDatabase {
|
|||||||
long messageId = db.insert(TABLE_NAME, ADDRESS, contentValues);
|
long messageId = db.insert(TABLE_NAME, ADDRESS, contentValues);
|
||||||
|
|
||||||
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
|
DatabaseFactory.getThreadDatabase(context).update(threadId, true);
|
||||||
|
DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);
|
||||||
notifyConversationListeners(threadId);
|
notifyConversationListeners(threadId);
|
||||||
jobManager.add(new TrimThreadJob(context, threadId));
|
jobManager.add(new TrimThreadJob(context, threadId));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user