improved my last read timestamp
This commit is contained in:
parent
4bd54354fa
commit
168abbd100
|
@ -667,6 +667,8 @@ public class DMResponse implements Parcelable {
|
||||||
String userId;
|
String userId;
|
||||||
@JsonField(name = "join_time")
|
@JsonField(name = "join_time")
|
||||||
long joinTime;
|
long joinTime;
|
||||||
|
@JsonField(name = "last_read_event_id")
|
||||||
|
String lastReadEventId;
|
||||||
|
|
||||||
public String getUserId() {
|
public String getUserId() {
|
||||||
return userId;
|
return userId;
|
||||||
|
@ -676,6 +678,10 @@ public class DMResponse implements Parcelable {
|
||||||
return joinTime;
|
return joinTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLastReadEventId() {
|
||||||
|
return lastReadEventId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -23,6 +23,7 @@ package org.mariotaku.twidere.model;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.StringDef;
|
import android.support.annotation.StringDef;
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||||
|
@ -142,10 +143,17 @@ public class ParcelableMessageConversation implements Parcelable {
|
||||||
@CursorField(value = Conversations.REQUEST_CURSOR)
|
@CursorField(value = Conversations.REQUEST_CURSOR)
|
||||||
public String request_cursor;
|
public String request_cursor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last read id of <b>current</b> user
|
||||||
|
*/
|
||||||
@JsonField(name = "last_read_id")
|
@JsonField(name = "last_read_id")
|
||||||
@CursorField(value = Conversations.LAST_READ_ID)
|
@CursorField(value = Conversations.LAST_READ_ID)
|
||||||
|
@Nullable
|
||||||
public String last_read_id;
|
public String last_read_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last read timestamp of <b>current</b> user
|
||||||
|
*/
|
||||||
@JsonField(name = "last_read_timestamp")
|
@JsonField(name = "last_read_timestamp")
|
||||||
@CursorField(value = Conversations.LAST_READ_TIMESTAMP)
|
@CursorField(value = Conversations.LAST_READ_TIMESTAMP)
|
||||||
public long last_read_timestamp;
|
public long last_read_timestamp;
|
||||||
|
|
|
@ -343,6 +343,8 @@ class GetMessagesTask(
|
||||||
|
|
||||||
fun createDatabaseUpdateData(context: Context, account: AccountDetails, response: DMResponse):
|
fun createDatabaseUpdateData(context: Context, account: AccountDetails, response: DMResponse):
|
||||||
DatabaseUpdateData {
|
DatabaseUpdateData {
|
||||||
|
val accountKey = account.key
|
||||||
|
|
||||||
val respConversations = response.conversations.orEmpty()
|
val respConversations = response.conversations.orEmpty()
|
||||||
val respEntries = response.entries.orEmpty()
|
val respEntries = response.entries.orEmpty()
|
||||||
val respUsers = response.users.orEmpty()
|
val respUsers = response.users.orEmpty()
|
||||||
|
@ -388,12 +390,12 @@ class GetMessagesTask(
|
||||||
conversation.conversation_avatar = v.avatarImageHttps
|
conversation.conversation_avatar = v.avatarImageHttps
|
||||||
conversation.request_cursor = response.cursor
|
conversation.request_cursor = response.cursor
|
||||||
conversation.conversation_extras_type = ParcelableMessageConversation.ExtrasType.TWITTER_OFFICIAL
|
conversation.conversation_extras_type = ParcelableMessageConversation.ExtrasType.TWITTER_OFFICIAL
|
||||||
conversation.last_read_id = v.lastReadEventId
|
conversation.last_read_id = v.participants.first { it.userId == accountKey.id }?.lastReadEventId
|
||||||
val longEventId = v.lastReadEventId.toLong(-1)
|
val longEventId = conversation.last_read_id.toLong(-1)
|
||||||
// Find recent message timestamp
|
// Find recent message timestamp
|
||||||
conversation.last_read_timestamp = messagesMap[k]?.filter { message ->
|
conversation.last_read_timestamp = messagesMap[k]?.filter { message ->
|
||||||
if (message.id == v.lastReadEventId) return@filter true
|
if (message.id == conversation.last_read_id) return@filter true
|
||||||
if (longEventId > 0 && longEventId < message.id.toLong(-1)) return@filter true
|
if (longEventId > 0 && longEventId >= message.id.toLong(-1)) return@filter true
|
||||||
return@filter false
|
return@filter false
|
||||||
}?.maxBy(ParcelableMessage::message_timestamp)?.message_timestamp ?: -1
|
}?.maxBy(ParcelableMessage::message_timestamp)?.message_timestamp ?: -1
|
||||||
conversation.conversation_extras = TwitterOfficialConversationExtras().apply {
|
conversation.conversation_extras = TwitterOfficialConversationExtras().apply {
|
||||||
|
|
|
@ -240,6 +240,10 @@ class ContentNotificationManager(
|
||||||
Utils.sendPebbleNotification(context, context.getString(R.string.interactions), pebbleNotificationStringBuilder.toString())
|
Utils.sendPebbleNotification(context, context.getString(R.string.interactions), pebbleNotificationStringBuilder.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showMessages(pref: AccountPreferences) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private fun applyNotificationPreferences(builder: NotificationCompat.Builder, pref: AccountPreferences, defaultFlags: Int) {
|
private fun applyNotificationPreferences(builder: NotificationCompat.Builder, pref: AccountPreferences, defaultFlags: Int) {
|
||||||
var notificationDefaults = 0
|
var notificationDefaults = 0
|
||||||
if (AccountPreferences.isNotificationHasLight(defaultFlags)) {
|
if (AccountPreferences.isNotificationHasLight(defaultFlags)) {
|
||||||
|
|
Loading…
Reference in New Issue