{
render(): React.Node {
let deleted = null;
if (this.props.entryInfo.deleted) {
let restore = null;
if (this.props.loggedIn) {
restore = (
(
restore
)
);
}
deleted = (
deleted
{restore}
);
}
const textClasses = classNames({
[css.entry]: true,
[css.darkEntry]: colorIsDark(this.props.threadInfo.color),
});
const textStyle = { backgroundColor: '#' + this.props.threadInfo.color };
const creator = this.props.creator?.username ? (
{this.props.creator.username}
) : (
'anonymous'
);
return (
{this.props.entryInfo.text}
{'created by '}
{creator}
{this.props.threadInfo.uiName}
{deleted}
revision history >
);
}
onRestore = (event: SyntheticEvent) => {
event.preventDefault();
const entryID = this.props.entryInfo.id;
invariant(entryID, 'entryInfo.id (serverID) should be set');
this.props.dispatchActionPromise(
restoreEntryActionTypes,
this.restoreEntryAction(),
{ customKeyName: `${restoreEntryActionTypes.started}:${entryID}` },
);
};
onClick = (event: SyntheticEvent) => {
event.preventDefault();
const entryID = this.props.entryInfo.id;
invariant(entryID, 'entryInfo.id (serverID) should be set');
this.props.onClick(entryID);
};
async restoreEntryAction(): Promise {
const entryID = this.props.entryInfo.id;
invariant(entryID, 'entry should have ID');
const result = await this.props.restoreEntry({
entryID,
calendarQuery: this.props.calendarQuery(),
});
this.props.animateAndLoadEntry(entryID);
return { ...result, threadID: this.props.threadInfo.id };
}
}
const ConnectedHistoryEntry: React.ComponentType =
React.memo(function ConnectedHistoryEntry(props) {
const entryID = props.entryInfo.id;
invariant(entryID, 'entryInfo.id (serverID) should be set');
const unresolvedThreadInfo = useSelector(
state => threadInfoSelector(state)[props.entryInfo.threadID],
);
const threadInfo = useResolvedThreadInfo(unresolvedThreadInfo);
const loggedIn = useSelector(
state =>
!!(state.currentUserInfo && !state.currentUserInfo.anonymous && true),
);
const restoreLoadingStatus = useSelector(
createLoadingStatusSelector(
restoreEntryActionTypes,
`${restoreEntryActionTypes.started}:${entryID}`,
),
);
const calenderQuery = useSelector(nonThreadCalendarQuery);
const callRestoreEntry = useRestoreEntry();
const dispatchActionPromise = useDispatchActionPromise();
const { creator } = props.entryInfo;
const [creatorWithENSName] = useENSNames([creator]);
return (
);
});
export default ConnectedHistoryEntry;