This commit is contained in:
Tom Moor
2023-10-17 21:28:11 -04:00
parent caafdb2fe7
commit 297536bfe5
2 changed files with 13 additions and 6 deletions

View File

@@ -1,14 +1,15 @@
import { compact } from "lodash"; import compact from "lodash/compact";
import sortBy from "lodash/sortBy"; import sortBy from "lodash/sortBy";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import * as React from "react"; import * as React from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { dateToRelative } from "@shared/utils/date"; import { dateLocale, dateToRelative } from "@shared/utils/date";
import Document from "~/models/Document"; import Document from "~/models/Document";
import User from "~/models/User"; import User from "~/models/User";
import Avatar from "~/components/Avatar"; import Avatar from "~/components/Avatar";
import ListItem from "~/components/List/Item"; import ListItem from "~/components/List/Item";
import PaginatedList from "~/components/PaginatedList"; import PaginatedList from "~/components/PaginatedList";
import useCurrentUser from "~/hooks/useCurrentUser";
import useStores from "~/hooks/useStores"; import useStores from "~/hooks/useStores";
type Props = { type Props = {
@@ -19,6 +20,9 @@ type Props = {
function DocumentViews({ document, isOpen }: Props) { function DocumentViews({ document, isOpen }: Props) {
const { t } = useTranslation(); const { t } = useTranslation();
const { views, presence } = useStores(); const { views, presence } = useStores();
const user = useCurrentUser();
const locale = dateLocale(user.language);
const documentPresence = presence.get(document.id); const documentPresence = presence.get(document.id);
const documentPresenceArray = documentPresence const documentPresenceArray = documentPresence
? Array.from(documentPresence.values()) ? Array.from(documentPresence.values())
@@ -53,9 +57,13 @@ function DocumentViews({ document, isOpen }: Props) {
? isEditing ? isEditing
? t("Currently editing") ? t("Currently editing")
: t("Currently viewing") : t("Currently viewing")
: t("Viewed {{ timeAgo }} ago", { : t("Viewed {{ timeAgo }}", {
timeAgo: dateToRelative( timeAgo: dateToRelative(
view ? Date.parse(view.lastViewedAt) : new Date() view ? Date.parse(view.lastViewedAt) : new Date(),
{
addSuffix: true,
locale,
}
), ),
}); });
return ( return (

View File

@@ -168,7 +168,7 @@
"Creating a template from <em>{{titleWithDefault}}</em> is a non-destructive action we'll make a copy of the document and turn it into a template that can be used as a starting point for new documents.": "Creating a template from <em>{{titleWithDefault}}</em> is a non-destructive action we'll make a copy of the document and turn it into a template that can be used as a starting point for new documents.", "Creating a template from <em>{{titleWithDefault}}</em> is a non-destructive action we'll make a copy of the document and turn it into a template that can be used as a starting point for new documents.": "Creating a template from <em>{{titleWithDefault}}</em> is a non-destructive action we'll make a copy of the document and turn it into a template that can be used as a starting point for new documents.",
"Currently editing": "Currently editing", "Currently editing": "Currently editing",
"Currently viewing": "Currently viewing", "Currently viewing": "Currently viewing",
"Viewed {{ timeAgo }} ago": "Viewed {{ timeAgo }} ago", "Viewed {{ timeAgo }}": "Viewed {{ timeAgo }}",
"Copy of {{ documentName }}": "Copy of {{ documentName }}", "Copy of {{ documentName }}": "Copy of {{ documentName }}",
"Title": "Title", "Title": "Title",
"Include nested documents": "Include nested documents", "Include nested documents": "Include nested documents",
@@ -948,7 +948,6 @@
"Online now": "Online now", "Online now": "Online now",
"Online {{ timeAgo }}": "Online {{ timeAgo }}", "Online {{ timeAgo }}": "Online {{ timeAgo }}",
"Viewed just now": "Viewed just now", "Viewed just now": "Viewed just now",
"Viewed {{ timeAgo }}": "Viewed {{ timeAgo }}",
"You updated {{ timeAgo }}": "You updated {{ timeAgo }}", "You updated {{ timeAgo }}": "You updated {{ timeAgo }}",
"{{ user }} updated {{ timeAgo }}": "{{ user }} updated {{ timeAgo }}", "{{ user }} updated {{ timeAgo }}": "{{ user }} updated {{ timeAgo }}",
"You created {{ timeAgo }}": "You created {{ timeAgo }}", "You created {{ timeAgo }}": "You created {{ timeAgo }}",