Fix race condition in `AccountSettingsHandler` local echo (#9172)
Should fix https://github.com/vector-im/element-web/issues/23006pull/28217/head
parent
946aa7f979
commit
0697d1d6d4
|
@ -165,8 +165,8 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
|
||||
content[field] = value;
|
||||
|
||||
await this.client.setAccountData(eventType, content);
|
||||
|
||||
// Attach a deferred *before* setting the account data to ensure we catch any requests
|
||||
// which race between different lines.
|
||||
const deferred = defer<void>();
|
||||
const handler = (event: MatrixEvent) => {
|
||||
if (event.getType() !== eventType || event.getContent()[field] !== value) return;
|
||||
|
@ -175,6 +175,8 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
};
|
||||
this.client.on(ClientEvent.AccountData, handler);
|
||||
|
||||
await this.client.setAccountData(eventType, content);
|
||||
|
||||
await deferred.promise;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue