{
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');
void 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;
diff --git a/web/navigation-sidebar/community-list-item.react.js b/web/navigation-sidebar/community-list-item.react.js
index 21a1dfa7c..b59a31b8f 100644
--- a/web/navigation-sidebar/community-list-item.react.js
+++ b/web/navigation-sidebar/community-list-item.react.js
@@ -1,58 +1,57 @@
// @flow
import * as React from 'react';
import { unreadCountSelectorForCommunity } from 'lib/selectors/thread-selectors.js';
import type { MinimallyEncodedResolvedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import type { LegacyResolvedThreadInfo } from 'lib/types/thread-types.js';
import css from './community-list-item.css';
import { navigationSidebarLabelTooltipMargin } from './navigation-sidebar-constants.js';
import ThreadAvatar from '../avatars/thread-avatar.react.js';
import UnreadBadge from '../components/unread-badge.react.js';
import { useSelector } from '../redux/redux-utils.js';
import { useLabelTooltip } from '../tooltips/tooltip-action-utils.js';
import { tooltipPositions } from '../tooltips/tooltip-utils.js';
type Props = {
- +threadInfo: LegacyResolvedThreadInfo | MinimallyEncodedResolvedThreadInfo,
+ +threadInfo: MinimallyEncodedResolvedThreadInfo,
};
function CommunityListItem(props: Props): React.Node {
const { threadInfo } = props;
const { id: threadID } = threadInfo;
const communityUnreadCountSelector =
unreadCountSelectorForCommunity(threadID);
const unreadCountValue = useSelector(communityUnreadCountSelector);
const unreadBadge = React.useMemo(() => {
if (unreadCountValue === 0) {
return null;
}
return (
);
}, [unreadCountValue]);
const { onMouseEnter, onMouseLeave } = useLabelTooltip({
tooltipLabel: threadInfo.uiName,
position: tooltipPositions.RIGHT,
tooltipMargin: navigationSidebarLabelTooltipMargin,
});
return (
{unreadBadge}
);
}
export default CommunityListItem;