import { useCallback } from 'react'; import { FormattedMessage } from 'react-intl'; import type { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import { fetchHistory } from 'mastodon/actions/history'; import { openModal } from 'mastodon/actions/modal'; import { Dropdown } from 'mastodon/components/dropdown_menu'; import { FormattedDateWrapper } from 'mastodon/components/formatted_date'; import InlineAccount from 'mastodon/components/inline_account'; import { RelativeTimestamp } from 'mastodon/components/relative_timestamp'; import { useAppDispatch, useAppSelector } from 'mastodon/store'; type HistoryItem = ImmutableMap; export const EditedTimestamp: React.FC<{ statusId: string; timestamp: string; }> = ({ statusId, timestamp }) => { const dispatch = useAppDispatch(); const items = useAppSelector( (state) => ( state.history.getIn([statusId, 'items']) as | ImmutableList | undefined )?.toArray() as HistoryItem[], ); const loading = useAppSelector( (state) => state.history.getIn([statusId, 'loading']) as boolean, ); const handleOpen = useCallback(() => { dispatch(fetchHistory(statusId)); }, [dispatch, statusId]); const handleItemClick = useCallback( (_item: HistoryItem, index: number) => { dispatch( openModal({ modalType: 'COMPARE_HISTORY', modalProps: { index, statusId }, }), ); }, [dispatch, statusId], ); const renderHeader = useCallback((items: HistoryItem[]) => { return ( ); }, []); const renderItem = useCallback( ( item: HistoryItem, index: number, { onClick, onKeyUp, }: { onClick: React.MouseEventHandler; onKeyUp: React.KeyboardEventHandler; }, ) => { const formattedDate = ( ); const formattedName = ( ); const label = (item.get('original') as boolean) ? ( ) : ( ); return (
  • ); }, [], ); return ( items={items} loading={loading} renderItem={renderItem} scrollable renderHeader={renderHeader} onOpen={handleOpen} onItemClick={handleItemClick} > ); };