Skip to content

Commit 48bc6ab

Browse files
committed
handle unknown users everywhere
1 parent 03dfdf1 commit 48bc6ab

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

lib/widgets/emoji_reaction.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/foundation.dart';
22
import 'package:flutter/material.dart';
3+
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';
34

45
import '../api/model/model.dart';
56
import '../api/route/messages.dart';
@@ -143,6 +144,7 @@ class ReactionChip extends StatelessWidget {
143144
@override
144145
Widget build(BuildContext context) {
145146
final store = PerAccountStoreWidget.of(context);
147+
final zulipLocalizations = ZulipLocalizations.of(context);
146148

147149
final reactionType = reactionWithVotes.reactionType;
148150
final emojiCode = reactionWithVotes.emojiCode;
@@ -157,7 +159,7 @@ class ReactionChip extends StatelessWidget {
157159
? userIds.map((id) {
158160
return id == store.selfUserId
159161
? 'You'
160-
: store.users[id]?.fullName ?? '(unknown user)'; // TODO(i18n)
162+
: store.users[id]?.fullName ?? zulipLocalizations.unknownUserName;
161163
}).join(', ')
162164
: userIds.length.toString();
163165

lib/widgets/inbox.dart

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';
23

34
import '../api/model/model.dart';
45
import '../model/narrow.dart';
@@ -368,18 +369,19 @@ class _DmItem extends StatelessWidget {
368369
@override
369370
Widget build(BuildContext context) {
370371
final store = PerAccountStoreWidget.of(context);
372+
final zulipLocalizations = ZulipLocalizations.of(context);
371373
final selfUser = store.users[store.selfUserId]!;
372374

373375
final designVariables = DesignVariables.of(context);
374376

375377
final title = switch (narrow.otherRecipientIds) { // TODO dedupe with [RecentDmConversationsItem]
376378
[] => selfUser.fullName,
377-
[var otherUserId] => store.users[otherUserId]?.fullName ?? '(unknown user)',
379+
[var otherUserId] => store.users[otherUserId]?.fullName ?? zulipLocalizations.unknownUserName,
378380

379381
// TODO(i18n): List formatting, like you can do in JavaScript:
380382
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya', 'Shu'])
381383
// // 'Chris、Greg、Alya、Shu'
382-
_ => narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)').join(', '),
384+
_ => narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName).join(', '),
383385
};
384386

385387
return Material(

lib/widgets/message_list.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ class MessageListAppBarTitle extends StatelessWidget {
322322
Widget build(BuildContext context) {
323323
final zulipLocalizations = ZulipLocalizations.of(context);
324324

325+
// TODO(i18n): provide tranlations just as 'zulipLocalizations.unknownUserName'
326+
// for 'unknown channel'
325327
switch (narrow) {
326328
case CombinedFeedNarrow():
327329
return Text(zulipLocalizations.combinedFeedPageTitle);
@@ -349,7 +351,7 @@ class MessageListAppBarTitle extends StatelessWidget {
349351
if (otherRecipientIds.isEmpty) {
350352
return const Text("DMs with yourself");
351353
} else {
352-
final names = otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)');
354+
final names = otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName);
353355
return Text("DMs with ${names.join(", ")}"); // TODO show avatars
354356
}
355357
}

lib/widgets/recent_dm_conversations.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class RecentDmConversationsItem extends StatelessWidget {
9393
Widget build(BuildContext context) {
9494
final store = PerAccountStoreWidget.of(context);
9595
final selfUser = store.users[store.selfUserId]!;
96+
final zulipLocalizations = ZulipLocalizations.of(context);
9697

9798
final designVariables = DesignVariables.of(context);
9899

@@ -107,13 +108,13 @@ class RecentDmConversationsItem extends StatelessWidget {
107108
// (should we offer a "spam folder" style summary screen of recent
108109
// 1:1 DM conversations from muted users?)
109110
final otherUser = store.users[otherUserId];
110-
title = otherUser?.fullName ?? '(unknown user)';
111+
title = otherUser?.fullName ?? zulipLocalizations.unknownUserName;
111112
avatar = AvatarImage(userId: otherUserId, size: _avatarSize);
112113
default:
113114
// TODO(i18n): List formatting, like you can do in JavaScript:
114115
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya'])
115116
// // 'Chris、Greg、Alya'
116-
title = narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? '(unknown user)').join(', ');
117+
title = narrow.otherRecipientIds.map((id) => store.users[id]?.fullName ?? zulipLocalizations.unknownUserName).join(', ');
117118
avatar = ColoredBox(color: designVariables.groupDmConversationIconBg,
118119
child: Center(
119120
child: Icon(color: designVariables.groupDmConversationIcon,

0 commit comments

Comments
 (0)