From 4c4ebcb272160843f540977006d0195d03414719 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Mon, 28 Oct 2024 16:04:16 -0400 Subject: [PATCH] don't call fetchOwnProfile is userID is null --- .../chat_list/client_chooser_button.dart | 119 ++++++++++-------- 1 file changed, 64 insertions(+), 55 deletions(-) diff --git a/lib/pages/chat_list/client_chooser_button.dart b/lib/pages/chat_list/client_chooser_button.dart index 34fda564b..0ac5ff0a8 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -214,62 +214,71 @@ class ClientChooserButton extends StatelessWidget { var clientCount = 0; matrix.accountBundles.forEach((key, value) => clientCount += value.length); - return FutureBuilder( - future: matrix.client.fetchOwnProfile(), - builder: (context, snapshot) => Stack( - alignment: Alignment.center, - children: [ - // #Pangea - // ...List.generate( - // clientCount, - // (index) => KeyBoardShortcuts( - // keysToPress: _buildKeyboardShortcut(index + 1), - // helpLabel: L10n.of(context)!.switchToAccount(index + 1), - // onKeysPressed: () => _handleKeyboardShortcut( - // matrix, - // index, - // context, - // ), - // child: const SizedBox.shrink(), - // ), - // ), - // KeyBoardShortcuts( - // keysToPress: { - // LogicalKeyboardKey.controlLeft, - // LogicalKeyboardKey.tab, - // }, - // helpLabel: L10n.of(context)!.nextAccount, - // onKeysPressed: () => _nextAccount(matrix, context), - // child: const SizedBox.shrink(), - // ), - // KeyBoardShortcuts( - // keysToPress: { - // LogicalKeyboardKey.controlLeft, - // LogicalKeyboardKey.shiftLeft, - // LogicalKeyboardKey.tab, - // }, - // helpLabel: L10n.of(context)!.previousAccount, - // onKeysPressed: () => _previousAccount(matrix, context), - // child: const SizedBox.shrink(), - // ), - // Pangea# - PopupMenuButton( - onSelected: (o) => _clientSelected(o, context), - itemBuilder: _bundleMenuItems, - child: Material( - color: Colors.transparent, - borderRadius: BorderRadius.circular(99), - child: Avatar( - mxContent: snapshot.data?.avatarUrl, - name: snapshot.data?.displayName ?? - matrix.client.userID!.localpart, - size: 32, - ), + // #Pangea + return matrix.client.userID == null + ? const SizedBox( + height: 16, + width: 16, + child: CircularProgressIndicator.adaptive(), + ) + : + // Pangea# + FutureBuilder( + future: matrix.client.fetchOwnProfile(), + builder: (context, snapshot) => Stack( + alignment: Alignment.center, + children: [ + // #Pangea + // ...List.generate( + // clientCount, + // (index) => KeyBoardShortcuts( + // keysToPress: _buildKeyboardShortcut(index + 1), + // helpLabel: L10n.of(context)!.switchToAccount(index + 1), + // onKeysPressed: () => _handleKeyboardShortcut( + // matrix, + // index, + // context, + // ), + // child: const SizedBox.shrink(), + // ), + // ), + // KeyBoardShortcuts( + // keysToPress: { + // LogicalKeyboardKey.controlLeft, + // LogicalKeyboardKey.tab, + // }, + // helpLabel: L10n.of(context)!.nextAccount, + // onKeysPressed: () => _nextAccount(matrix, context), + // child: const SizedBox.shrink(), + // ), + // KeyBoardShortcuts( + // keysToPress: { + // LogicalKeyboardKey.controlLeft, + // LogicalKeyboardKey.shiftLeft, + // LogicalKeyboardKey.tab, + // }, + // helpLabel: L10n.of(context)!.previousAccount, + // onKeysPressed: () => _previousAccount(matrix, context), + // child: const SizedBox.shrink(), + // ), + // Pangea# + PopupMenuButton( + onSelected: (o) => _clientSelected(o, context), + itemBuilder: _bundleMenuItems, + child: Material( + color: Colors.transparent, + borderRadius: BorderRadius.circular(99), + child: Avatar( + mxContent: snapshot.data?.avatarUrl, + name: snapshot.data?.displayName ?? + matrix.client.userID!.localpart, + size: 32, + ), + ), + ), + ], ), - ), - ], - ), - ); + ); } Set? _buildKeyboardShortcut(int index) {