* Add message preview support to the new room list * Support showing message previews in the room list items * Add the secondary filters bar with the '...' menu, containing just the option for message previews for now * Change message preview toggle hook to update when setting is updated * Use new compund release * Unused i18n keys * Unused imports * Fix test & update snapshot * Fix more snapshots * Fix test Split into two tests that test setting & updating * Type import * Snapshots * Remove unnecessary Flex container and update screenshots as the room list has got shorter from the added bar * More snapshots & screenshots * More snapshots * Add test and remove active filter that's not done yet * Update snapshots & screenshots again * Other screenshot * Add more tests * Fix syntax * Fix tests * Use setter directly Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix CSS * Remopve filter button css for now * Update to remove forwardRef * Add comment on why lack of TypedEventEmitter * snapshots again * Screenshots again * Use original screenshots, maybe they'll work now * Add comment --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
/*
|
|
* Copyright 2025 New Vector Ltd.
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
* Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
import { useCallback } from "react";
|
|
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
|
import { SettingLevel } from "../../../settings/SettingLevel";
|
|
import { useSettingValue } from "../../../hooks/useSettings";
|
|
|
|
interface MessagePreviewToggleState {
|
|
shouldShowMessagePreview: boolean;
|
|
toggleMessagePreview: () => void;
|
|
}
|
|
|
|
/**
|
|
* This hook:
|
|
* - Provides a state that tracks whether message previews are turned on or off.
|
|
* - Provides a function to toggle message previews.
|
|
*/
|
|
export function useMessagePreviewToggle(): MessagePreviewToggleState {
|
|
const shouldShowMessagePreview = useSettingValue("RoomList.showMessagePreview");
|
|
|
|
const toggleMessagePreview = useCallback((): void => {
|
|
const toggled = !shouldShowMessagePreview;
|
|
SettingsStore.setValue("RoomList.showMessagePreview", null, SettingLevel.DEVICE, toggled);
|
|
}, [shouldShowMessagePreview]);
|
|
|
|
return { toggleMessagePreview, shouldShowMessagePreview };
|
|
}
|