mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
fix: Better profile caching in settings
This commit is contained in:
parent
4e7cd9bf46
commit
e6f3f0bb5e
@ -34,6 +34,12 @@ class SettingsController extends State<Settings> {
|
|||||||
bool crossSigningCached;
|
bool crossSigningCached;
|
||||||
Future<bool> megolmBackupCachedFuture;
|
Future<bool> megolmBackupCachedFuture;
|
||||||
bool megolmBackupCached;
|
bool megolmBackupCached;
|
||||||
|
bool profileUpdated = false;
|
||||||
|
|
||||||
|
void updateProfile() => setState(() {
|
||||||
|
profileUpdated = true;
|
||||||
|
profile = profileFuture = null;
|
||||||
|
});
|
||||||
|
|
||||||
void logoutAction() async {
|
void logoutAction() async {
|
||||||
if (await showOkCancelAlertDialog(
|
if (await showOkCancelAlertDialog(
|
||||||
@ -186,15 +192,14 @@ class SettingsController extends State<Settings> {
|
|||||||
matrix.client.setDisplayName(matrix.client.userID, input.single),
|
matrix.client.setDisplayName(matrix.client.userID, input.single),
|
||||||
);
|
);
|
||||||
if (success.error == null) {
|
if (success.error == null) {
|
||||||
setState(() {
|
updateProfile();
|
||||||
profileFuture = null;
|
|
||||||
profile = null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAvatarAction() async {
|
void setAvatarAction() async {
|
||||||
final action = await showConfirmationDialog<AvatarAction>(
|
final action = profile?.avatar == null
|
||||||
|
? AvatarAction.change
|
||||||
|
: await showConfirmationDialog<AvatarAction>(
|
||||||
context: context,
|
context: context,
|
||||||
title: L10n.of(context).pleaseChoose,
|
title: L10n.of(context).pleaseChoose,
|
||||||
actions: [
|
actions: [
|
||||||
@ -218,10 +223,7 @@ class SettingsController extends State<Settings> {
|
|||||||
future: () => matrix.client.setAvatarUrl(matrix.client.userID, null),
|
future: () => matrix.client.setAvatarUrl(matrix.client.userID, null),
|
||||||
);
|
);
|
||||||
if (success.error == null) {
|
if (success.error == null) {
|
||||||
setState(() {
|
updateProfile();
|
||||||
profileFuture = null;
|
|
||||||
profile = null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -251,10 +253,7 @@ class SettingsController extends State<Settings> {
|
|||||||
future: () => matrix.client.setAvatar(file),
|
future: () => matrix.client.setAvatar(file),
|
||||||
);
|
);
|
||||||
if (success.error == null) {
|
if (success.error == null) {
|
||||||
setState(() {
|
updateProfile();
|
||||||
profileFuture = null;
|
|
||||||
profile = null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,8 +390,8 @@ class SettingsController extends State<Settings> {
|
|||||||
profileFuture ??= client
|
profileFuture ??= client
|
||||||
.getProfileFromUserId(
|
.getProfileFromUserId(
|
||||||
client.userID,
|
client.userID,
|
||||||
cache: false,
|
cache: !profileUpdated,
|
||||||
getFromRooms: false,
|
getFromRooms: !profileUpdated,
|
||||||
)
|
)
|
||||||
.then((p) {
|
.then((p) {
|
||||||
if (mounted) setState(() => profile = p);
|
if (mounted) setState(() => profile = p);
|
||||||
|
Loading…
Reference in New Issue
Block a user