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

Add configuration to disable relative date markers in timeline #7405

Merged
merged 6 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
flip timelineDisableRelativeDates -> timelineEnableRelativeDates to f…
…it convention

Signed-off-by: Kerry Archibald <kerrya@element.io>
  • Loading branch information
Kerry Archibald committed Dec 21, 2021
commit b12b6a597c10e7cf7e7c0955dfd983b7d5cad173
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