fix to set ConversationType for "Note to self"

Fix to check if a conversation is "Note to self" by checking the ConversationType instead to check conversation name by hardcoded string

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2024-04-17 11:55:24 +02:00
parent b9b449f0bf
commit 94257242a3
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
5 changed files with 11 additions and 15 deletions

View File

@ -28,7 +28,6 @@ import com.nextcloud.talk.extensions.loadConversationAvatar
import com.nextcloud.talk.extensions.loadNoteToSelfAvatar
import com.nextcloud.talk.extensions.loadSystemAvatar
import com.nextcloud.talk.extensions.loadUserAvatar
import com.nextcloud.talk.models.domain.ConversationModel
import com.nextcloud.talk.models.json.chat.ChatMessage
import com.nextcloud.talk.models.json.conversations.Conversation
import com.nextcloud.talk.models.json.conversations.Conversation.ConversationType
@ -36,7 +35,6 @@ import com.nextcloud.talk.ui.StatusDrawable
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.SpreedFeatures
import com.nextcloud.talk.utils.ConversationUtils
import com.nextcloud.talk.utils.DisplayUtils
import eu.davidea.flexibleadapter.FlexibleAdapter
@ -170,19 +168,12 @@ class ConversationItem(
}
}
ConversationType.DUMMY -> {
if (ConversationUtils.isNoteToSelfConversation(
ConversationModel.mapToConversationModel(model)
)
) {
holder.binding.dialogAvatar.loadNoteToSelfAvatar()
}
}
ConversationType.ROOM_GROUP_CALL,
ConversationType.FORMER_ONE_TO_ONE,
ConversationType.ROOM_PUBLIC_CALL ->
holder.binding.dialogAvatar.loadConversationAvatar(user, model, false, viewThemeUtils)
ConversationType.NOTE_TO_SELF ->
holder.binding.dialogAvatar.loadNoteToSelfAvatar()
else -> holder.binding.dialogAvatar.visibility = View.GONE
}

View File

@ -122,7 +122,8 @@ enum class ConversationType {
ROOM_GROUP_CALL,
ROOM_PUBLIC_CALL,
ROOM_SYSTEM,
FORMER_ONE_TO_ONE
FORMER_ONE_TO_ONE,
NOTE_TO_SELF
}
enum class ParticipantType {

View File

@ -238,7 +238,8 @@ data class Conversation(
ROOM_GROUP_CALL,
ROOM_PUBLIC_CALL,
ROOM_SYSTEM,
FORMER_ONE_TO_ONE
FORMER_ONE_TO_ONE,
NOTE_TO_SELF
}
enum class ObjectType {

View File

@ -23,6 +23,8 @@ public class EnumRoomTypeConverter extends IntBasedTypeConverter<Conversation.Co
return Conversation.ConversationType.ROOM_SYSTEM;
case 5:
return Conversation.ConversationType.FORMER_ONE_TO_ONE;
case 6:
return Conversation.ConversationType.NOTE_TO_SELF;
default:
return Conversation.ConversationType.DUMMY;
}
@ -43,6 +45,8 @@ public class EnumRoomTypeConverter extends IntBasedTypeConverter<Conversation.Co
return 4;
case FORMER_ONE_TO_ONE:
return 5;
case NOTE_TO_SELF:
return 6;
default:
return 0;
}

View File

@ -13,7 +13,6 @@ import com.nextcloud.talk.models.json.capabilities.SpreedCapability
object ConversationUtils {
private val TAG = ConversationUtils::class.java.simpleName
private const val NOTE_TO_SELF = "Note to self"
fun isPublic(conversation: ConversationModel): Boolean {
return ConversationType.ROOM_PUBLIC_CALL == conversation.type
@ -76,6 +75,6 @@ object ConversationUtils {
}
fun isNoteToSelfConversation(currentConversation: ConversationModel?): Boolean {
return currentConversation != null && currentConversation.name == NOTE_TO_SELF
return currentConversation != null && currentConversation.type == ConversationType.NOTE_TO_SELF
}
}