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

Iterate io.element.late_event decoration #11760

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions res/css/views/messages/_MessageTimestamp.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ limitations under the License.
white-space: nowrap;
user-select: none;
}

.mx_MessageTimestamp_lateIcon {
position: absolute;
right: 100%;
top: 50%;
transform: translateY(-50%);
color: inherit;
}
3 changes: 3 additions & 0 deletions res/img/sensor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/components/views/messages/MessageTimestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from "react";
import React, { ReactNode } from "react";
import { Tooltip } from "@vector-im/compound-web";

import { formatFullDate, formatTime, formatFullTime, formatRelativeTime } from "../../../DateUtils";
import { _t } from "../../../languageHandler";
import { Icon as LateIcon } from "../../../../res/img/sensor.svg";

interface IProps {
ts: number;
Expand Down Expand Up @@ -49,17 +50,20 @@ export default class MessageTimestamp extends React.Component<IProps> {

let label = formatFullDate(date, this.props.showTwelveHour);
let caption: string | undefined;
let icon: ReactNode | undefined;
if (this.props.receivedTs !== undefined) {
label = _t("timeline|message_timestamp_sent_at", { dateTime: label });
const receivedDate = new Date(this.props.receivedTs);
caption = _t("timeline|message_timestamp_received_at", {
dateTime: formatFullDate(receivedDate, this.props.showTwelveHour),
});
icon = <LateIcon className="mx_MessageTimestamp_lateIcon" width="16" height="16" />;
}

return (
<Tooltip label={label} caption={caption}>
<span className="mx_MessageTimestamp" aria-hidden={true} aria-live="off">
{icon}
{timestamp}
</span>
</Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3418,7 +3418,7 @@
"label": "Message Actions",
"view_in_room": "View in room"
},
"message_timestamp_received_at": "Recovered at: %(dateTime)s",
"message_timestamp_received_at": "Received at: %(dateTime)s",
"message_timestamp_sent_at": "Sent at: %(dateTime)s",
"mjolnir": {
"changed_rule_glob": "%(senderName)s updated a ban rule that was matching %(oldGlob)s to matching %(newGlob)s for %(reason)s",
Expand Down
2 changes: 1 addition & 1 deletion test/components/views/messages/MessageTimestamp-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("MessageTimestamp", () => {
);
await userEvent.hover(container.querySelector(".mx_MessageTimestamp")!);
expect((await screen.findByRole("tooltip")).textContent).toMatchInlineSnapshot(
`"Sent at: Fri, Dec 17, 2021, 08:09:00Recovered at: Sat, Dec 18, 2021, 08:09:00"`,
`"Sent at: Fri, Dec 17, 2021, 08:09:00Received at: Sat, Dec 18, 2021, 08:09:00"`,
);
});
});
Loading