Stabilise user profile timezones (#30815)

* Fix imports

* lint

* update test

* log

* Update comment
This commit is contained in:
Will Hunt
2025-10-13 11:41:57 +00:00
committed by GitHub
parent 2698ad422e
commit 6838969792
5 changed files with 71 additions and 38 deletions
+7 -2
View File
@@ -17,6 +17,8 @@ import {
type SyncStateData,
SyncState,
EventType,
ProfileKeyTimezone,
ProfileKeyMSC4175Timezone,
} from "matrix-js-sdk/src/matrix";
import { type MatrixCall } from "matrix-js-sdk/src/webrtc/call";
import classNames from "classnames";
@@ -197,10 +199,12 @@ class LoggedInView extends React.Component<IProps, IState> {
}
private onTimezoneUpdate = async (): Promise<void> => {
// TODO: In a future app release, remove support for legacy key.
if (!SettingsStore.getValue("userTimezonePublish")) {
// Ensure it's deleted
try {
await this._matrixClient.deleteExtendedProfileProperty("us.cloke.msc4175.tz");
await this._matrixClient.deleteExtendedProfileProperty(ProfileKeyMSC4175Timezone);
await this._matrixClient.deleteExtendedProfileProperty(ProfileKeyTimezone);
} catch (ex) {
console.warn("Failed to delete timezone from user profile", ex);
}
@@ -215,7 +219,8 @@ class LoggedInView extends React.Component<IProps, IState> {
return;
}
try {
await this._matrixClient.setExtendedProfileProperty("us.cloke.msc4175.tz", currentTimezone);
await this._matrixClient.setExtendedProfileProperty(ProfileKeyTimezone, currentTimezone);
await this._matrixClient.setExtendedProfileProperty(ProfileKeyMSC4175Timezone, currentTimezone);
} catch (ex) {
console.warn("Failed to update user profile with current timezone", ex);
}