diff --git a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/DMResponse.java b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/DMResponse.java
index 8f74ccab5..39bd370d7 100644
--- a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/DMResponse.java
+++ b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/twitter/model/DMResponse.java
@@ -667,6 +667,8 @@ public class DMResponse implements Parcelable {
String userId;
@JsonField(name = "join_time")
long joinTime;
+ @JsonField(name = "last_read_event_id")
+ String lastReadEventId;
public String getUserId() {
return userId;
@@ -676,6 +678,10 @@ public class DMResponse implements Parcelable {
return joinTime;
}
+ public String getLastReadEventId() {
+ return lastReadEventId;
+ }
+
@Override
public int describeContents() {
return 0;
diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMessageConversation.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMessageConversation.java
index 92ec396b6..cd5616b31 100644
--- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMessageConversation.java
+++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMessageConversation.java
@@ -23,6 +23,7 @@ package org.mariotaku.twidere.model;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.annotation.Nullable;
import android.support.annotation.StringDef;
import com.bluelinelabs.logansquare.annotation.JsonField;
@@ -142,10 +143,17 @@ public class ParcelableMessageConversation implements Parcelable {
@CursorField(value = Conversations.REQUEST_CURSOR)
public String request_cursor;
+ /**
+ * Last read id of current user
+ */
@JsonField(name = "last_read_id")
@CursorField(value = Conversations.LAST_READ_ID)
+ @Nullable
public String last_read_id;
+ /**
+ * Last read timestamp of current user
+ */
@JsonField(name = "last_read_timestamp")
@CursorField(value = Conversations.LAST_READ_TIMESTAMP)
public long last_read_timestamp;
diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/message/GetMessagesTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/message/GetMessagesTask.kt
index 9f23e8370..0989f2b96 100644
--- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/message/GetMessagesTask.kt
+++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/message/GetMessagesTask.kt
@@ -343,6 +343,8 @@ class GetMessagesTask(
fun createDatabaseUpdateData(context: Context, account: AccountDetails, response: DMResponse):
DatabaseUpdateData {
+ val accountKey = account.key
+
val respConversations = response.conversations.orEmpty()
val respEntries = response.entries.orEmpty()
val respUsers = response.users.orEmpty()
@@ -388,12 +390,12 @@ class GetMessagesTask(
conversation.conversation_avatar = v.avatarImageHttps
conversation.request_cursor = response.cursor
conversation.conversation_extras_type = ParcelableMessageConversation.ExtrasType.TWITTER_OFFICIAL
- conversation.last_read_id = v.lastReadEventId
- val longEventId = v.lastReadEventId.toLong(-1)
+ conversation.last_read_id = v.participants.first { it.userId == accountKey.id }?.lastReadEventId
+ val longEventId = conversation.last_read_id.toLong(-1)
// Find recent message timestamp
conversation.last_read_timestamp = messagesMap[k]?.filter { message ->
- if (message.id == v.lastReadEventId) return@filter true
- if (longEventId > 0 && longEventId < message.id.toLong(-1)) return@filter true
+ if (message.id == conversation.last_read_id) return@filter true
+ if (longEventId > 0 && longEventId >= message.id.toLong(-1)) return@filter true
return@filter false
}?.maxBy(ParcelableMessage::message_timestamp)?.message_timestamp ?: -1
conversation.conversation_extras = TwitterOfficialConversationExtras().apply {
diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/ContentNotificationManager.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/ContentNotificationManager.kt
index 3349325b9..2fdc6ff2c 100644
--- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/ContentNotificationManager.kt
+++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/ContentNotificationManager.kt
@@ -240,6 +240,10 @@ class ContentNotificationManager(
Utils.sendPebbleNotification(context, context.getString(R.string.interactions), pebbleNotificationStringBuilder.toString())
}
+ fun showMessages(pref: AccountPreferences) {
+
+ }
+
private fun applyNotificationPreferences(builder: NotificationCompat.Builder, pref: AccountPreferences, defaultFlags: Int) {
var notificationDefaults = 0
if (AccountPreferences.isNotificationHasLight(defaultFlags)) {