Skip to content

Commit d5beee6

Browse files
committed
Compact chat list: no You: prefix in one-to-one chats, drafts show in compact group rows
1 parent 4caa599 commit d5beee6

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
- Privacy and Security: while loading, the Bio row no longer reads "Groups" and the invites row has its usual title.
3737
- Extras › More Profile Settings: the custom number no longer runs into its "Number" label; "Accent Saturation" fits on one line.
3838
- Protected Archive: the fixed archive policy reads "Stay in Archive — Always" instead of repeating "Always".
39-
- Compact Chat List: the row is centred (it had an empty band under the text), the Archived Chats row is compact too, the unread badge sits on the line of text, and a draft or folder tags no longer spill onto the next row. Compact Message Preview alone gets the same one-line row.
39+
- Compact Chat List: the row is centred (it had an empty band under the text), the Archived Chats row is compact too, the unread badge sits on the line of text, and a draft or folder tags no longer spill onto the next row. Compact Message Preview alone gets the same one-line row. No "You:" in front of your own message in a one-to-one chat, and a group's draft shows in a compact row.
4040
- Text fields in settings: a title passed without a colour (Deleted/Edited Message Mark, Number) was black on a dark theme; the title also no longer runs into the text.
4141
- Appearance › themes: the selected theme has a checkmark, without a disclosure arrow on rows that open nothing.
4242
- Title Case for the remaining Extras names (Messages and Composer, Calls and Audio, Tab Bar, Avatar Glow, …); "Use System Text Size" and "Wi-Fi" spelled correctly.

‎Tests/Branding/test_compact_chat_list.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ def test_either_setting_makes_one_line(self):
1919
self.assertIn('if singleLinePreview {\n useInlineAuthorPrefix = true', self.text)
2020
self.assertIn('if !itemTags.isEmpty || singleLinePreview {\n authorAttributedString = nil', self.text)
2121
self.assertIn('if singleLinePreview, !forumThreads.isEmpty {', self.text)
22+
# No "You:" in front of your own message in a one-to-one chat, as in the regular row.
23+
self.assertIn('if !(singleLinePreview && isOneToOne) {', self.text)
2224

2325
def test_no_second_line_below_the_row(self):
2426
# Folder tags sit on a line under the text and drafts on an author line; both go in a one-line row.
2527
self.assertIn('itemTags = singleLinePreview ? [] : peerData.tags', self.text)
2628
self.assertIn('if !itemTags.isEmpty || singleLinePreview {\n let tempAttributedText = foldLineBreaks(draftText)', self.text)
27-
media_draft = self.text.split('if inlineAuthorPrefix == nil, let mediaDraftContentType {', 1)[1].split('} else if inlineAuthorPrefix == nil, let draftState', 1)[0]
29+
# A group's inline author prefix in a compact row does not hide its draft.
30+
self.assertIn('let draftAllowed = inlineAuthorPrefix == nil || (singleLinePreview && !isGroupReferenceRow)', self.text)
31+
media_draft = self.text.split('if draftAllowed, let mediaDraftContentType {', 1)[1].split('} else if draftAllowed, let draftState', 1)[0]
2832
self.assertIn('if singleLinePreview {', media_draft)
2933
self.assertIn('authorAttributedString = nil', media_draft)
3034

‎submodules/ChatListUI/Sources/Node/ChatListItem.swift‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,8 +2943,16 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
29432943

29442944
if useInlineAuthorPrefix && !isLastMessageFiltered {
29452945
if case let .user(author) = messages.last?.author {
2946+
// A one-to-one chat shows no author for your own message (the regular row doesn't either); the
2947+
// archive row, which mixes chats, and groups do.
2948+
var isOneToOne = messages.last?.id.peerId.namespace == Namespaces.Peer.CloudUser || messages.last?.id.peerId.namespace == Namespaces.Peer.SecretChat
2949+
if case .groupReference = item.content {
2950+
isOneToOne = false
2951+
}
29462952
if author.id == item.context.account.peerId {
2947-
inlineAuthorPrefix = item.presentationData.strings.DialogList_You
2953+
if !(singleLinePreview && isOneToOne) {
2954+
inlineAuthorPrefix = item.presentationData.strings.DialogList_You
2955+
}
29482956
} else if messages.last?.id.peerId.namespace != Namespaces.Peer.CloudUser && messages.last?.id.peerId.namespace != Namespaces.Peer.SecretChat {
29492957
inlineAuthorPrefix = EnginePeer.user(author).compactDisplayTitle
29502958
}
@@ -3087,7 +3095,14 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
30873095
foldedRichTextPreview = nil
30883096
}
30893097

3090-
if inlineAuthorPrefix == nil, let mediaDraftContentType {
3098+
// A draft wins over the last message. Only the archive row's author prefix keeps it out; a compact
3099+
// row's prefix is there because the row has one line, not to hide a draft.
3100+
var isGroupReferenceRow = false
3101+
if case .groupReference = item.content {
3102+
isGroupReferenceRow = true
3103+
}
3104+
let draftAllowed = inlineAuthorPrefix == nil || (singleLinePreview && !isGroupReferenceRow)
3105+
if draftAllowed, let mediaDraftContentType {
30913106
hasDraft = true
30923107
authorAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_Draft, font: textFont, textColor: theme.messageDraftTextColor)
30933108

@@ -3105,7 +3120,7 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
31053120
attributedText = attributedTextWithDraft
31063121
authorAttributedString = nil
31073122
}
3108-
} else if inlineAuthorPrefix == nil, let draftState = draftState {
3123+
} else if draftAllowed, let draftState = draftState {
31093124
hasDraft = true
31103125
let draftText = stringWithAppliedEntities(draftState.text, entities: draftState.entities, baseColor: theme.messageTextColor, linkColor: theme.messageTextColor, baseFont: textFont, linkFont: textFont, boldFont: textFont, italicFont: textFont, boldItalicFont: textFont, fixedFont: textFont, blockQuoteFont: textFont, message: nil)
31113126

0 commit comments

Comments
 (0)