From 7c463bafe3dab6d939c2ad42e450e3c0b6339eb8 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Fri, 17 Dec 2021 16:54:13 +0100 Subject: [PATCH] flip timelineDisableRelativeDates -> timelineEnableRelativeDates to fit convention Signed-off-by: Kerry Archibald --- src/components/views/messages/DateSeparator.tsx | 2 +- src/settings/Settings.tsx | 4 ++-- src/settings/UIFeature.ts | 2 +- test/components/views/messages/DateSeparator-test.tsx | 10 +++++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/views/messages/DateSeparator.tsx b/src/components/views/messages/DateSeparator.tsx index d6800d985ee6..1e3da01d7b50 100644 --- a/src/components/views/messages/DateSeparator.tsx +++ b/src/components/views/messages/DateSeparator.tsx @@ -50,7 +50,7 @@ export default class DateSeparator extends React.Component { private getLabel() { const date = new Date(this.props.ts); - const disableRelativeTimestamps = SettingsStore.getValue(UIFeature.TimelineDisableRelativeDates); + const disableRelativeTimestamps = !SettingsStore.getValue(UIFeature.TimelineEnableRelativeDates); // During the time the archive is being viewed, a specific day might not make sense, so we return the full date if (this.props.forExport || disableRelativeTimestamps) return formatFullDateNoTime(date); diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index c4d4335bf913..a96ad66e044f 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -965,8 +965,8 @@ export const SETTINGS: {[setting: string]: ISetting} = { supportedLevels: LEVELS_UI_FEATURE, default: true, }, - [UIFeature.TimelineDisableRelativeDates]: { + [UIFeature.TimelineEnableRelativeDates]: { supportedLevels: LEVELS_UI_FEATURE, - default: false, + default: true, }, }; diff --git a/src/settings/UIFeature.ts b/src/settings/UIFeature.ts index 9c81dbe871c6..225f785614f7 100644 --- a/src/settings/UIFeature.ts +++ b/src/settings/UIFeature.ts @@ -32,7 +32,7 @@ export enum UIFeature { Communities = "UIFeature.communities", AdvancedSettings = "UIFeature.advancedSettings", RoomHistorySettings = "UIFeature.roomHistorySettings", - TimelineDisableRelativeDates = "UIFeature.timelineDisableRelativeDates" + TimelineEnableRelativeDates = "UIFeature.timelineEnableRelativeDates" } export enum UIComponent { diff --git a/test/components/views/messages/DateSeparator-test.tsx b/test/components/views/messages/DateSeparator-test.tsx index 13bcc7766606..8ec6054cb782 100644 --- a/test/components/views/messages/DateSeparator-test.tsx +++ b/test/components/views/messages/DateSeparator-test.tsx @@ -54,10 +54,14 @@ describe("DateSeparator", () => { ], ]; + beforeEach(() => { + (SettingsStore.getValue as jest.Mock).mockReturnValue(true); + }); + it('renders the date separator correctly', () => { const component = getComponent(); expect(component).toMatchSnapshot(); - expect(SettingsStore.getValue).toHaveBeenCalledWith(UIFeature.TimelineDisableRelativeDates); + expect(SettingsStore.getValue).toHaveBeenCalledWith(UIFeature.TimelineEnableRelativeDates); }); it.each(testCases)('formats date correctly when current time is %s', (_d, ts, result) => { @@ -70,9 +74,9 @@ describe("DateSeparator", () => { }); }); - describe('when Settings.TimelineDisableRelativeDates is truthy', () => { + describe('when Settings.TimelineEnableRelativeDates is falsy', () => { beforeEach(() => { - (SettingsStore.getValue as jest.Mock).mockReturnValue(true); + (SettingsStore.getValue as jest.Mock).mockReturnValue(false); }); it.each(testCases)('formats date in full when current time is %s', (_d, ts) => { expect(getComponent({ ts, forExport: false }).text()).toEqual(formatFullDateNoTime(new Date(ts)));