Fix so that we still use notificationsMuted / unread even if a room isn't in view.

This commit is contained in:
Half-Shot
2025-01-17 12:14:46 +00:00
parent b589757c34
commit bcf9854a4c

View File

@@ -1944,20 +1944,18 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
let context: AppTitleContext = { let context: AppTitleContext = {
brand: SdkConfig.get().brand, brand: SdkConfig.get().brand,
syncError: extraContext?.syncState === SyncState.Error, syncError: extraContext?.syncState === SyncState.Error,
notificationsMuted: extraContext && extraContext.userNotificationLevel < NotificationLevel.Activity,
unreadNotificationCount: extraContext?.unreadNotificationCount,
}; };
if (extraContext) { if (this.state.currentRoomId) {
if (this.state.currentRoomId) { const client = MatrixClientPeg.get();
const client = MatrixClientPeg.get(); const room = client?.getRoom(this.state.currentRoomId);
const room = client?.getRoom(this.state.currentRoomId); context = {
context = { ...context,
...context, roomId: this.state.currentRoomId,
roomId: this.state.currentRoomId, roomName: room?.name,
roomName: room?.name, };
notificationsMuted: extraContext.userNotificationLevel < NotificationLevel.Activity,
unreadNotificationCount: extraContext.unreadNotificationCount,
};
}
} }
const moduleTitle = ModuleRunner.instance.extensions.branding?.getAppTitle(context); const moduleTitle = ModuleRunner.instance.extensions.branding?.getAppTitle(context);
@@ -1968,13 +1966,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
return; return;
} }
// Use application default.
let subtitle = ""; let subtitle = "";
if (context?.syncError) { if (context?.syncError) {
subtitle += `[${_t("common|offline")}] `; subtitle += `[${_t("common|offline")}] `;
} }
if ('unreadNotificationCount' in context && context.unreadNotificationCount > 0) { if (context.unreadNotificationCount !== undefined && context.unreadNotificationCount > 0) {
subtitle += `[${context.unreadNotificationCount}]`; subtitle += `[${context.unreadNotificationCount}]`;
} else if ('notificationsMuted' in context && !context.notificationsMuted) { } else if (context.notificationsMuted !== undefined && !context.notificationsMuted) {
subtitle += `*`; subtitle += `*`;
} }