Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
flip timelineDisableRelativeDates -> timelineEnableRelativeDates to f…
Browse files Browse the repository at this point in the history
…it convention

Signed-off-by: Kerry Archibald <kerrya@element.io>
  • Loading branch information
Kerry Archibald committed Dec 17, 2021
1 parent 8c314d3 commit 7c463ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/views/messages/DateSeparator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class DateSeparator extends React.Component<IProps> {

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);
Expand Down
4 changes: 2 additions & 2 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
2 changes: 1 addition & 1 deletion src/settings/UIFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions test/components/views/messages/DateSeparator-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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)));
Expand Down

0 comments on commit 7c463ba

Please sign in to comment.