ui: channels preset tag (#6850)

This commit is contained in:
spaced4ndy
2026-04-21 15:59:02 +00:00
committed by GitHub
parent 27b06dfb38
commit 6f86c5af2e
5 changed files with 32 additions and 29 deletions
@@ -2094,6 +2094,7 @@ data class GroupInfo (
ChatFeature.Calls -> false
}
override val timedMessagesTTL: Int? get() = with(fullGroupPreferences.timedMessages) { if (on) ttl else null }
val isChannel: Boolean get() = groupProfile.isChannel
override val displayName get() = localAlias.ifEmpty { groupProfile.displayName }
override val fullName get() = groupProfile.fullName
override val shortDescr get() = groupProfile.shortDescr
@@ -2213,6 +2214,8 @@ data class GroupProfile (
val groupPreferences: GroupPreferences? = null,
val memberAdmission: GroupMemberAdmission? = null
): NamedChat {
val isChannel: Boolean get() = publicGroup?.groupType == GroupType.Channel
companion object {
val sampleData = GroupProfile(
displayName = "team",
@@ -4594,30 +4597,21 @@ sealed class MsgChatLink {
val iconRes: ImageResource
get() = when (this) {
is Group -> when (groupProfile.publicGroup?.groupType) {
GroupType.Channel -> MR.images.ic_bigtop_updates_circle_filled
else -> MR.images.ic_supervised_user_circle_filled
}
is Group -> if (groupProfile.isChannel) MR.images.ic_bigtop_updates_circle_filled else MR.images.ic_supervised_user_circle_filled
is Contact -> if (business) MR.images.ic_work_filled_padded else MR.images.ic_account_circle_filled
is Invitation -> MR.images.ic_account_circle_filled
}
val smallIconRes: ImageResource
get() = when (this) {
is Group -> when (groupProfile.publicGroup?.groupType) {
GroupType.Channel -> MR.images.ic_bigtop_updates
else -> MR.images.ic_group
}
is Group -> if (groupProfile.isChannel) MR.images.ic_bigtop_updates else MR.images.ic_group
is Contact -> if (business) MR.images.ic_work else MR.images.ic_person
is Invitation -> MR.images.ic_person
}
fun infoLine(signed: Boolean): String {
var s = when (this) {
is Group -> when (groupProfile.publicGroup?.groupType) {
GroupType.Channel -> generalGetString(MR.strings.chat_link_channel)
else -> generalGetString(MR.strings.chat_link_group)
}
is Group -> if (groupProfile.isChannel) generalGetString(MR.strings.chat_link_channel) else generalGetString(MR.strings.chat_link_group)
is Contact -> if (business) generalGetString(MR.strings.chat_link_business_address) else generalGetString(MR.strings.chat_link_contact_address)
is Invitation -> generalGetString(MR.strings.chat_link_one_time)
}
@@ -46,7 +46,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.serialization.json.Json
import kotlin.time.Duration.Companion.seconds
enum class PresetTagKind { GROUP_REPORTS, FAVORITES, CONTACTS, GROUPS, BUSINESS, NOTES }
enum class PresetTagKind { GROUP_REPORTS, FAVORITES, CONTACTS, GROUPS, CHANNELS, BUSINESS, NOTES }
sealed class ActiveFilter {
data class PresetTag(val tag: PresetTagKind) : ActiveFilter()
@@ -1236,7 +1236,11 @@ fun presetTagMatchesChat(tag: PresetTagKind, chatInfo: ChatInfo, chatStats: Chat
else -> false
}
PresetTagKind.GROUPS -> when (chatInfo) {
is ChatInfo.Group -> chatInfo.groupInfo.businessChat == null
is ChatInfo.Group -> chatInfo.groupInfo.businessChat == null && !chatInfo.groupInfo.isChannel
else -> false
}
PresetTagKind.CHANNELS -> when (chatInfo) {
is ChatInfo.Group -> chatInfo.groupInfo.isChannel
else -> false
}
PresetTagKind.BUSINESS -> when (chatInfo) {
@@ -1255,6 +1259,7 @@ private fun presetTagLabel(tag: PresetTagKind, active: Boolean): Pair<ImageResou
PresetTagKind.FAVORITES -> (if (active) MR.images.ic_star_filled else MR.images.ic_star) to MR.strings.chat_list_favorites
PresetTagKind.CONTACTS -> (if (active) MR.images.ic_person_filled else MR.images.ic_person) to MR.strings.chat_list_contacts
PresetTagKind.GROUPS -> (if (active) MR.images.ic_group_filled else MR.images.ic_group) to MR.strings.chat_list_groups
PresetTagKind.CHANNELS -> (if (active) MR.images.ic_bigtop_updates_circle_filled else MR.images.ic_bigtop_updates) to MR.strings.chat_list_channels
PresetTagKind.BUSINESS -> (if (active) MR.images.ic_work_filled else MR.images.ic_work) to MR.strings.chat_list_businesses
PresetTagKind.NOTES -> (if (active) MR.images.ic_folder_closed_filled else MR.images.ic_folder_closed) to MR.strings.chat_list_notes
}
@@ -497,6 +497,7 @@
<string name="chat_list_favorites">Favorites</string>
<string name="chat_list_contacts">Contacts</string>
<string name="chat_list_groups">Groups</string>
<string name="chat_list_channels">Channels</string>
<string name="chat_list_businesses">Businesses</string>
<string name="chat_list_notes">Notes</string>
<string name="chat_list_group_reports">Reports</string>