add dynamic hinting and latching for PMPs

This commit is contained in:
Henry Hiles 2026-11-26 16:06:08 -05:00
commit c786344bf2
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -87,26 +87,22 @@ class AccountDataController extends Notifier<AccountData> {
Future<void> setRoomProfile(String roomId, String profileId) async {
const type = AccountData.perMessageProfilesKey;
final current = ref
final rooms = ref.read(RoomsController.provider.notifier);
final previous = ref
.read(RoomsController.provider)[roomId]
?.accountData[type];
final content = {...?previous, "default_profile_id": profileId};
await ref
.read(ClientController.provider.notifier)
.setAccountData(
.new(
type: type,
roomId: roomId,
content: {...?current, "default_profile_id": profileId},
),
);
await ref
.read(RoomsController.provider.notifier)
.awaitRooms(
(rooms) =>
rooms[roomId]?.accountData[type]?["default_profile_id"] ==
profileId,
);
// Shown straight away, rather than once it comes down sync
rooms.setAccountData(roomId, type, content);
try {
await ref
.read(ClientController.provider.notifier)
.setAccountData(.new(type: type, roomId: roomId, content: content));
} catch (_) {
rooms.setAccountData(roomId, type, previous);
rethrow;
}
}
/// Saves [rule] of [kind], creating it if it's new, or otherwise changing only