forked from upstream-mirrors/quik
Fix draft being sorted at the bottom
In some cases, if no date was set, it would get sorted to the bottom
This commit is contained in:
@@ -36,7 +36,7 @@ class QkRealmMigration @Inject constructor(
|
|||||||
) : RealmMigration {
|
) : RealmMigration {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SchemaVersion: Long = 12
|
const val SchemaVersion: Long = 13
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
@@ -239,10 +239,6 @@ class QkRealmMigration @Inject constructor(
|
|||||||
// Because there was never any property associated with which conversation/recipients a scheduled message was for,
|
// Because there was never any property associated with which conversation/recipients a scheduled message was for,
|
||||||
// we can't update this field on a realm migration. It will be set to a default of 0
|
// we can't update this field on a realm migration. It will be set to a default of 0
|
||||||
|
|
||||||
version++
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version == 11L) {
|
|
||||||
realm.schema.create("MessageContentFilter")
|
realm.schema.create("MessageContentFilter")
|
||||||
.addField("id", Long::class.java, FieldAttribute.PRIMARY_KEY, FieldAttribute.REQUIRED)
|
.addField("id", Long::class.java, FieldAttribute.PRIMARY_KEY, FieldAttribute.REQUIRED)
|
||||||
.addField("value", String::class.java, FieldAttribute.REQUIRED)
|
.addField("value", String::class.java, FieldAttribute.REQUIRED)
|
||||||
@@ -253,6 +249,12 @@ class QkRealmMigration @Inject constructor(
|
|||||||
version++
|
version++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (version == 12L) {
|
||||||
|
realm.schema.get("Conversation")
|
||||||
|
?.addField("draftDate", Long::class.java, FieldAttribute.REQUIRED)
|
||||||
|
version++
|
||||||
|
}
|
||||||
|
|
||||||
check(version >= newVersion) { "Migration missing from v$oldVersion to v$newVersion" }
|
check(version >= newVersion) { "Migration missing from v$oldVersion to v$newVersion" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,6 +353,7 @@ class ConversationRepositoryImpl @Inject constructor(
|
|||||||
|
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
conversation?.takeIf { it.isValid }?.draft = draft
|
conversation?.takeIf { it.isValid }?.draft = draft
|
||||||
|
conversation?.takeIf { it.isValid }?.draftDate = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ open class Conversation(
|
|||||||
var recipients: RealmList<Recipient> = RealmList(),
|
var recipients: RealmList<Recipient> = RealmList(),
|
||||||
var lastMessage: Message? = null,
|
var lastMessage: Message? = null,
|
||||||
var draft: String = "",
|
var draft: String = "",
|
||||||
|
var draftDate: Long = 0,
|
||||||
|
|
||||||
var blockingClient: Int? = null,
|
var blockingClient: Int? = null,
|
||||||
var blockReason: String? = null,
|
var blockReason: String? = null,
|
||||||
@@ -38,7 +39,7 @@ open class Conversation(
|
|||||||
var name: String = "" // For group chats, the user is allowed to set a custom title for the conversation
|
var name: String = "" // For group chats, the user is allowed to set a custom title for the conversation
|
||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
|
|
||||||
val date: Long get() = lastMessage?.date ?: 0
|
val date: Long get() = lastMessage?.date ?: if (draft.isNotEmpty()) draftDate else 0
|
||||||
val snippet: String? get() = lastMessage?.getSummary()
|
val snippet: String? get() = lastMessage?.getSummary()
|
||||||
val unread: Boolean get() = lastMessage?.read == false
|
val unread: Boolean get() = lastMessage?.read == false
|
||||||
val me: Boolean get() = lastMessage?.isMe() == true
|
val me: Boolean get() = lastMessage?.isMe() == true
|
||||||
|
|||||||
Reference in New Issue
Block a user