File tree 4 files changed +12
-6
lines changed 4 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ mixin UserStore {
9
9
/// i.e. the account the person using this app is logged into.
10
10
///
11
11
/// This always equals the [Account.userId] on [PerAccountStore.account] .
12
+ ///
13
+ /// For the corresponding [User] object, see [selfUser] .
12
14
int get selfUserId;
13
15
14
16
/// All known users in the realm, by [User.userId] .
@@ -31,6 +33,12 @@ mixin UserStore {
31
33
/// Consider using [userDisplayName] .
32
34
Map <int , User > get users;
33
35
36
+ /// The [User] object for the "self-user",
37
+ /// i.e. the account the person using this app is logged into.
38
+ ///
39
+ /// When only the user ID is needed, see [selfUserId] .
40
+ User get selfUser => users[selfUserId]! ;
41
+
34
42
/// The name to show the given user as in the UI, even for unknown users.
35
43
///
36
44
/// This is the user's [User.fullName] if the user is known,
Original file line number Diff line number Diff line change @@ -1408,9 +1408,8 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
1408
1408
case ChannelNarrow (: final streamId):
1409
1409
case TopicNarrow (: final streamId):
1410
1410
final channel = store.streams[streamId];
1411
- final selfUser = store.users[store.selfUserId]! ;
1412
1411
if (channel == null || ! store.hasPostingPermission (inChannel: channel,
1413
- user: selfUser, byDate: DateTime .now ())) {
1412
+ user: store. selfUser, byDate: DateTime .now ())) {
1414
1413
return _ErrorBanner (label:
1415
1414
ZulipLocalizations .of (context).errorBannerCannotPostInChannelLabel);
1416
1415
}
Original file line number Diff line number Diff line change @@ -385,7 +385,7 @@ class _DmItem extends StatelessWidget {
385
385
final designVariables = DesignVariables .of (context);
386
386
387
387
final title = switch (narrow.otherRecipientIds) { // TODO dedupe with [RecentDmConversationsItem]
388
- [] => store.users[store.selfUserId] ! .fullName,
388
+ [] => store.selfUser .fullName,
389
389
[var otherUserId] => store.userDisplayName (otherUserId),
390
390
391
391
// TODO(i18n): List formatting, like you can do in JavaScript:
Original file line number Diff line number Diff line change @@ -85,9 +85,8 @@ class RecentDmConversationsItem extends StatelessWidget {
85
85
final Widget avatar;
86
86
switch (narrow.otherRecipientIds) { // TODO dedupe with DM items in [InboxPage]
87
87
case []:
88
- final selfUser = store.users[store.selfUserId]! ;
89
- title = selfUser.fullName;
90
- avatar = AvatarImage (userId: selfUser.userId, size: _avatarSize);
88
+ title = store.selfUser.fullName;
89
+ avatar = AvatarImage (userId: store.selfUserId, size: _avatarSize);
91
90
case [var otherUserId]:
92
91
// TODO(#296) actually don't show this row if the user is muted?
93
92
// (should we offer a "spam folder" style summary screen of recent
You can’t perform that action at this time.
0 commit comments