mirror of
https://github.com/outline/outline.git
synced 2026-12-03 10:00:13 +03:00
fix: Use store models in history sidebar
This commit is contained in:
1 parent
b2da166dd6
commit
83da38afd5
2 files changed
+9
-9
No files matched your search
@@ -19,7 +19,6 @@ import EventBoundary from "@shared/components/EventBoundary";
|
||||
import { s, hover } from "@shared/styles";
|
||||
import { RevisionHelper } from "@shared/utils/RevisionHelper";
|
||||
import Document from "~/models/Document";
|
||||
import User from "~/models/User";
|
||||
import { Avatar, AvatarSize } from "~/components/Avatar";
|
||||
import Item, { Actions } from "~/components/List/Item";
|
||||
import Time from "~/components/Time";
|
||||
@@ -49,7 +48,7 @@ export type DocumentEvent = {
|
||||
userId: string;
|
||||
};
|
||||
|
||||
export type Event = { id: string; actor: User; createdAt: string } & (
|
||||
export type Event = { id: string; actorId: string; createdAt: string } & (
|
||||
| RevisionEvent
|
||||
| DocumentEvent
|
||||
);
|
||||
@@ -62,12 +61,13 @@ type Props = {
|
||||
const EventListItem = ({ event, document, ...rest }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const { revisions, users } = useStores();
|
||||
const user = "userId" in event ? users.get(event.userId) : null;
|
||||
const actor = "actorId" in event ? users.get(event.actorId) : undefined;
|
||||
const user = "userId" in event ? users.get(event.userId) : undefined;
|
||||
const location = useLocation();
|
||||
const sidebarContext = useLocationSidebarContext();
|
||||
const revisionLoadedRef = React.useRef(false);
|
||||
const opts = {
|
||||
userName: event.actor.name,
|
||||
userName: actor?.name,
|
||||
};
|
||||
const isRevision = event.name === "revisions.create";
|
||||
const isDerivedFromDocument =
|
||||
@@ -98,7 +98,7 @@ const EventListItem = ({ event, document, ...rest }: Props) => {
|
||||
icon = <EditIcon size={16} />;
|
||||
meta = event.latest ? (
|
||||
<>
|
||||
{t("Current version")} · {event.actor.name}
|
||||
{t("Current version")} · {actor?.name}
|
||||
</>
|
||||
) : (
|
||||
t("{{userName}} edited", opts)
|
||||
@@ -198,7 +198,7 @@ const EventListItem = ({ event, document, ...rest }: Props) => {
|
||||
onClick={handleTimeClick}
|
||||
/>
|
||||
}
|
||||
image={<Avatar model={event.actor} size={AvatarSize.Large} />}
|
||||
image={<Avatar model={actor} size={AvatarSize.Large} />}
|
||||
subtitle={meta}
|
||||
actions={
|
||||
isRevision && isActive && !event.latest ? (
|
||||
|
||||
@@ -47,7 +47,7 @@ function History() {
|
||||
return {
|
||||
id: data.id,
|
||||
name: "revisions.create",
|
||||
actor: data.createdBy,
|
||||
actorId: data.createdBy.id,
|
||||
createdAt: data.createdAt,
|
||||
latest: false,
|
||||
} satisfies Event;
|
||||
@@ -56,7 +56,7 @@ function History() {
|
||||
return {
|
||||
id: data.id,
|
||||
name: data.name as DocumentEvent["name"],
|
||||
actor: data.actor,
|
||||
actorId: data.actorId,
|
||||
userId: data.userId,
|
||||
createdAt: data.createdAt,
|
||||
} satisfies Event;
|
||||
@@ -148,7 +148,7 @@ function History() {
|
||||
id: RevisionHelper.latestId(document.id),
|
||||
name: "revisions.create",
|
||||
createdAt: document.updatedAt,
|
||||
actor: document.updatedBy!,
|
||||
actorId: document.updatedBy?.id ?? "",
|
||||
latest: true,
|
||||
});
|
||||
} else if (latestRevisionEvent) {
|
||||
|
||||
Reference in new issue
Block a user