From 39e09c5d64152c61e953a487be9037b15d7dfc12 Mon Sep 17 00:00:00 2001 From: sherlock Date: Thu, 21 Sep 2023 17:26:08 +0700 Subject: [PATCH] TW-181: avatar not change after update --- lib/pages/chat_list/chat_list.dart | 16 ---------------- lib/pages/chat_list/chat_list_body.dart | 2 +- lib/pages/chat_list/client_chooser_button.dart | 4 ++-- lib/pages/settings/settings.dart | 2 +- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index a7a327c67b..029a77c640 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:adaptive_dialog/adaptive_dialog.dart'; -import 'package:async/async.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/di/global/get_it_initializer.dart'; import 'package:fluffychat/domain/model/recovery_words/recovery_words.dart'; @@ -81,21 +80,6 @@ class ChatListController extends State String? activeSpaceId; - late final profileMemoizers = >{}; - - Future fetchOwnProfile({required Client client}) { - if (!profileMemoizers.containsKey(client)) { - profileMemoizers[client] = AsyncMemoizer(); - } - return profileMemoizers[client]!.runOnce(() async { - return await client.fetchOwnProfile(); - }); - } - - void updateProfile(Client? client) { - profileMemoizers[client] = AsyncMemoizer(); - } - void resetActiveSpaceId() { setState(() { activeSpaceId = null; diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index 676536ea13..cc4cef5b31 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -77,7 +77,7 @@ class ChatListViewBody extends StatelessWidget { const SizedBox(height: 16), FutureBuilder( // ignore: unnecessary_cast - future: controller.fetchOwnProfile(client: client), + future: client.fetchOwnProfile(getFromRooms: false), builder: (context, snapshotProfile) { if (snapshotProfile.connectionState != ConnectionState.done) { diff --git a/lib/pages/chat_list/client_chooser_button.dart b/lib/pages/chat_list/client_chooser_button.dart index bacc985ae5..018f7355ab 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -123,7 +123,7 @@ class ClientChooserButton extends StatelessWidget { int clientCount = 0; matrix.accountBundles.forEach((key, value) => clientCount += value.length); return FutureBuilder( - future: controller.fetchOwnProfile(client: matrix.client), + future: matrix.client.fetchOwnProfile(getFromRooms: false), builder: (context, snapshot) { if (!snapshot.hasData) { return const Center(child: CircularProgressIndicator.adaptive()); @@ -338,7 +338,7 @@ class _ProfileWidgetState extends State { @override Widget build(BuildContext context) { return FutureBuilder( - future: widget.controller.fetchOwnProfile(client: widget.client), + future: widget.client.fetchOwnProfile(getFromRooms: false), builder: (context, snapshot) { if (!snapshot.hasData) { return const Center(child: CircularProgressIndicator.adaptive()); diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index 6631237c2a..cbc33c6b0e 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -213,7 +213,7 @@ class SettingsController extends State with ConnectPageMixin { profileFuture ??= client.getProfileFromUserId( client.userID!, cache: !profileUpdated, - getFromRooms: !profileUpdated, + getFromRooms: false, ); return SettingsView(this); }