Skip to content

Commit

Permalink
TW-181: avatar not change after update
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and hoangdat committed Sep 22, 2023
1 parent 371ef61 commit 39e09c5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
16 changes: 0 additions & 16 deletions lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -81,21 +80,6 @@ class ChatListController extends State<ChatList>

String? activeSpaceId;

late final profileMemoizers = <Client?, AsyncMemoizer<Profile>>{};

Future<Profile?> 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<Profile>();
}

void resetActiveSpaceId() {
setState(() {
activeSpaceId = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat_list/chat_list_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ChatListViewBody extends StatelessWidget {
const SizedBox(height: 16),
FutureBuilder<Profile?>(
// ignore: unnecessary_cast
future: controller.fetchOwnProfile(client: client),
future: client.fetchOwnProfile(getFromRooms: false),
builder: (context, snapshotProfile) {
if (snapshotProfile.connectionState !=
ConnectionState.done) {
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/chat_list/client_chooser_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ClientChooserButton extends StatelessWidget {
int clientCount = 0;
matrix.accountBundles.forEach((key, value) => clientCount += value.length);
return FutureBuilder<Profile?>(
future: controller.fetchOwnProfile(client: matrix.client),
future: matrix.client.fetchOwnProfile(getFromRooms: false),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator.adaptive());
Expand Down Expand Up @@ -338,7 +338,7 @@ class _ProfileWidgetState extends State<ProfileWidget> {
@override
Widget build(BuildContext context) {
return FutureBuilder<Profile?>(
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());
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class SettingsController extends State<Settings> with ConnectPageMixin {
profileFuture ??= client.getProfileFromUserId(
client.userID!,
cache: !profileUpdated,
getFromRooms: !profileUpdated,
getFromRooms: false,
);
return SettingsView(this);
}
Expand Down

0 comments on commit 39e09c5

Please sign in to comment.