Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,13 @@
"@unknownUserName": {
"description": "Name placeholder to use for a user when we don't know their name."
},
"youLabel": "(you)",
"@youLabel": {
"description": "Label shown after the current user's display name in direct messages."
},
"dmsWithYourselfPageTitle": "DMs with yourself",
"@dmsWithYourselfPageTitle": {
"description": "Message list page title for a DM group that only includes yourself."
"description": "Label shown after the self-user's name on the 'Direct messages' page"
},
"messageListGroupYouAndOthers": "You and {others}",
"@messageListGroupYouAndOthers": {
Expand Down
8 changes: 7 additions & 1 deletion lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,13 @@ abstract class ZulipLocalizations {
/// **'(unknown user)'**
String get unknownUserName;

/// Message list page title for a DM group that only includes yourself.
/// Label shown after the current user's display name in direct messages.
///
/// In en, this message translates to:
/// **'(you)'**
String get youLabel;

/// Label shown after the self-user's name on the 'Direct messages' page
///
/// In en, this message translates to:
/// **'DMs with yourself'**
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ class ZulipLocalizationsDe extends ZulipLocalizations {
@override
String get unknownUserName => '(Nutzer:in unbekannt)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DNs mit dir selbst';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_el.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsEl extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsEs extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ class ZulipLocalizationsFr extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_he.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsHe extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_hu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsHu extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ class ZulipLocalizationsIt extends ZulipLocalizations {
@override
String get unknownUserName => '(utente sconosciuto)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'MD con te stesso';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
@override
String get unknownUserName => '(不明なユーザー)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => '自分とのDM';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_nb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
@override
String get unknownUserName => '(nieznany użytkownik)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DM do siebie';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
@override
String get unknownUserName => '(неизвестный пользователь)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'ЛС с собой';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_sk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_sl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ class ZulipLocalizationsSl extends ZulipLocalizations {
@override
String get unknownUserName => '(neznan uporabnik)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'Neposredna sporočila s samim seboj';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_uk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ class ZulipLocalizationsUk extends ZulipLocalizations {
@override
String get unknownUserName => '(невідомий користувач)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'Особисті повідомлення із собою';

Expand Down
3 changes: 3 additions & 0 deletions lib/generated/l10n/zulip_localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ class ZulipLocalizationsZh extends ZulipLocalizations {
@override
String get unknownUserName => '(unknown user)';

@override
String get youLabel => '(you)';

@override
String get dmsWithYourselfPageTitle => 'DMs with yourself';

Expand Down
59 changes: 50 additions & 9 deletions lib/widgets/recent_dm_conversations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import '../generated/l10n/zulip_localizations.dart';
import '../model/narrow.dart';
import '../model/recent_dm_conversations.dart';
import '../model/unreads.dart';
import '../model/store.dart';

import 'color.dart';
import 'icons.dart';
import 'message_list.dart';
import 'new_dm_sheet.dart';
Expand Down Expand Up @@ -169,26 +172,64 @@ class RecentDmConversationsItem extends StatelessWidget {

static const double _avatarSize = 32;

TextSpan _buildUserTitleSpan(
BuildContext context, {
required int userId,
required PerAccountStore store,
}) {
final designVariables = DesignVariables.of(context);
final List<InlineSpan> spans = <InlineSpan>[];

// Use store.userDisplayName so rendering rules remain consistent.
spans.add(TextSpan(text: store.userDisplayName(userId)));

// Status emoji inserted after name (keeps existing emoji rendering).
spans.add(
Comment on lines +183 to +187
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments don't make any sense for someone coming and reading the code in this file after this PR is merged. (What's the "existing" emoji rendering? What does it mean to "keep" it?) They therefore don't belong in the code.

They do make sense as (somewhat verbose) explanations of the diff in this PR.

Specifically, they read a lot like comments that an LLM coding tool might insert, when asked to write a change like this, to explain the diff to you.

That sort of comment isn't helpful in a PR. When you send a PR for us to review, you need to already understand it yourself. Then you need to reread it to make sure it expresses your thoughts clearly and concisely. See our AI policy:
https://zulip.readthedocs.io/en/latest/contributing/contributing.html#ai-use-policy-and-guidelines

(When there is something to say about the code diff, rather than the resulting code, the home for that is the commit messages rather than in-code comments. See https://github.com/zulip/zulip-mobile/blob/main/docs/style.md#commit-messages-code . But the comments here are too redundant to be necessary at all.)

UserStatusEmoji.asWidgetSpan(
userId: userId,
fontSize: 17,
textScaler: MediaQuery.textScalerOf(context),
),
);
Comment on lines +191 to +193
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't match the formatting of the existing code around it. Have you read the existing code yourself? Please take the time to do so. Having an AI tool look at the code is not a substitute.

This particular instance is especially clear because this very diff is moving this code from elsewhere in the file, where it looks like so:

          UserStatusEmoji.asWidgetSpan(userId: store.selfUserId,
            fontSize: 17, textScaler: MediaQuery.textScalerOf(context)),


// If this is the self user, add the localized "(you)" label.
if (userId == store.selfUserId) {
final youLabel = ZulipLocalizations.of(context).youLabel;
spans.add(
TextSpan(
text: ' $youLabel',
style: TextStyle(
color: designVariables.labelMenuButton.withFadedAlpha(0.5),
),
),
);
}

return TextSpan(children: spans);
}

@override
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);
final designVariables = DesignVariables.of(context);

final InlineSpan title;
final Widget avatar;
int? userIdForPresence;

switch (narrow.otherRecipientIds) { // TODO dedupe with DM items in [InboxPage]
case []:
title = TextSpan(text: store.selfUser.fullName, children: [
UserStatusEmoji.asWidgetSpan(userId: store.selfUserId,
fontSize: 17, textScaler: MediaQuery.textScalerOf(context)),
]);
title = _buildUserTitleSpan(
context,
userId: store.selfUserId,
Comment on lines +221 to +223
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this doesn't match the indentation style used in this project or any other.

store: store,
);
avatar = AvatarImage(userId: store.selfUserId, size: _avatarSize);
case [var otherUserId]:
title = TextSpan(text: store.userDisplayName(otherUserId), children: [
UserStatusEmoji.asWidgetSpan(userId: otherUserId,
fontSize: 17, textScaler: MediaQuery.textScalerOf(context)),
]);
title = _buildUserTitleSpan(
context,
userId: otherUserId,
store: store,
);
avatar = AvatarImage(userId: otherUserId, size: _avatarSize);
userIdForPresence = otherUserId;
default:
Expand Down
29 changes: 25 additions & 4 deletions test/widgets/recent_dm_conversations_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import '../model/binding.dart';
import '../model/test_store.dart';
import '../test_navigation.dart';
import 'checks.dart';
import 'finders.dart';
import 'test_app.dart';

late PerAccountStore store;
Expand Down Expand Up @@ -172,13 +171,35 @@ void main() {

void checkTitle(WidgetTester tester, String expectedText, [int? expectedLines]) {
// TODO(#232): syntax like `check(find(…), findsOneWidget)`
final widget = tester.widget(find.descendant(
final matchedFinder = find.descendant(
of: find.byType(RecentDmConversationsItem),
// The title might contain a WidgetSpan (for status emoji); exclude
// the resulting placeholder character from the text to be matched.
matching: findText(expectedText, includePlaceholders: false)));
matching: find.byWidgetPredicate(
(widget) {
if (widget is! Text) return false;
final textWidget = widget;
final fullText =
textWidget.data ??
textWidget.textSpan?.toPlainText() ?? '';
return fullText.startsWith(expectedText);
},
description: 'Text starting with "$expectedText"',
),
);

check(matchedFinder).findsOne();

// Grab the matched Text widget (use first in case of multiple matches).
final Text titleWidget = tester.widget<Text>(matchedFinder.first);
final String fullText =
titleWidget.data ??
titleWidget.textSpan?.toPlainText() ?? '';

// (Optional) extra sanity check: ensure the fullText actually starts with the expected string.
check(fullText.startsWith(expectedText)).isTrue();
if (expectedLines != null) {
final renderObject = tester.renderObject<RenderParagraph>(find.byWidget(widget));
final renderObject = tester.renderObject<RenderParagraph>(matchedFinder.first);
check(renderObject.size.height).equals(
20.0 // line height
* expectedLines);
Expand Down