{"version":3,"sources":["webpack:///./app/javascript/mastodon/features/notifications/request.jsx"],"names":["messages","defineMessages","title","id","defaultMessage","accept","dismiss","selectChild","ref","index","alignTop","container","current","node","element","querySelector","scrollTop","offsetTop","scrollIntoView","clientHeight","offsetHeight","focus","NotificationRequest","_ref","multiColumn","params","columnRef","useRef","intl","useIntl","dispatch","useDispatch","notificationRequest","useSelector","state","_state$notificationRe","notificationRequests","item","accountId","account_id","account","getIn","notifications","items","isLoading","hasMore","next","removed","handleHeaderClick","useCallback","_columnRef$current","handleLoadMore","expandNotificationsForRequest","handleDismiss","dismissNotificationRequest","handleAccept","acceptNotificationRequest","handleMoveUp","elementIndex","findIndex","get","handleMoveDown","useEffect","fetchNotificationRequest","fetchNotificationsForRequest","columnTitle","formatMessage","name","explainer","limited","isLocal","acct","indexOf","_jsx","className","FormattedMessage","_jsxs","Column","bindToDocument","label","children","ColumnHeader","icon","iconComponent","InventoryIcon","onClick","showBackButton","extraButton","_Fragment","IconButton","DeleteIcon","DoneIcon","SensitiveMediaContextProvider","hideMediaByDefault","ScrollableList","prepend","scrollKey","trackScroll","showLoading","size","onLoadMore","map","NotificationContainer","notification","onMoveUp","onMoveDown","Helmet","content"],"mappings":"mTA2BA,MAAMA,EAAWC,YAAe,CAC9BC,MAAO,CAAEC,GAAG,2CAA6CC,eAAe,6BACxEC,OAAQ,CAAEF,GAAG,+BAAiCC,eAAe,UAC7DE,QAAS,CAAEH,GAAG,gCAAkCC,eAAe,aAG3DG,EAAcA,CAACC,EAAKC,EAAOC,KAC/B,MAAMC,EAAYH,EAAII,QAAQC,KACxBC,EAAUH,EAAUI,cAAc,uBAAuBN,EAAQ,iBAEnEK,IACEJ,GAAYC,EAAUK,UAAYF,EAAQG,UAC5CH,EAAQI,gBAAe,IACbR,GAAYC,EAAUK,UAAYL,EAAUQ,aAAeL,EAAQG,UAAYH,EAAQM,cACjGN,EAAQI,gBAAe,GAGzBJ,EAAQO,QACV,EAGWC,EAAsBC,IAAsC,IAArC,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EACdsD,gBAAiBtD,EACjBoB,UAAWA,EACXsD,YAAatD,GAAoC,IAAvBF,EAAcyD,KACxCtD,QAASA,EACTuD,WAAYjD,QAAe,EAE1BT,EAAc2D,KAAIhE,GACjBA,GAAQoC,YAAC6B,IAAqB,CAE5BC,aAAclE,EACdC,UAAWD,EAAKuB,IAAI,WACpB4C,SAAU/C,EACVgD,WAAY5C,GAJPxB,EAAKuB,IAAI,WAUtBa,YAACiC,IAAM,UACLjC,YAAA,kBAAQR,GACRQ,YAAA,QAAMN,KAAK,SAASwC,QAAQ,eAEvB,EAWErF,W","file":"js/features/notifications/request-b99df357e098d63f54f6.chunk.js","sourcesContent":["import PropTypes from 'prop-types';\nimport { useRef, useCallback, useEffect } from 'react';\n\nimport { defineMessages, useIntl, FormattedMessage } from 'react-intl';\n\nimport { Helmet } from 'react-helmet';\n\nimport { useSelector, useDispatch } from 'react-redux';\n\nimport DeleteIcon from '@/material-icons/400-24px/delete.svg?react';\nimport DoneIcon from '@/material-icons/400-24px/done.svg?react';\nimport InventoryIcon from '@/material-icons/400-24px/inventory_2.svg?react';\nimport {\n fetchNotificationRequest,\n fetchNotificationsForRequest,\n expandNotificationsForRequest,\n acceptNotificationRequest,\n dismissNotificationRequest,\n} from 'mastodon/actions/notification_requests';\nimport Column from 'mastodon/components/column';\nimport ColumnHeader from 'mastodon/components/column_header';\nimport { IconButton } from 'mastodon/components/icon_button';\nimport ScrollableList from 'mastodon/components/scrollable_list';\nimport { SensitiveMediaContextProvider } from 'mastodon/features/ui/util/sensitive_media_context';\n\nimport NotificationContainer from './containers/notification_container';\n\nconst messages = defineMessages({\n title: { id: 'notification_requests.notifications_from', defaultMessage: 'Notifications from {name}' },\n accept: { id: 'notification_requests.accept', defaultMessage: 'Accept' },\n dismiss: { id: 'notification_requests.dismiss', defaultMessage: 'Dismiss' },\n});\n\nconst selectChild = (ref, index, alignTop) => {\n const container = ref.current.node;\n const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);\n\n if (element) {\n if (alignTop && container.scrollTop > element.offsetTop) {\n element.scrollIntoView(true);\n } else if (!alignTop && container.scrollTop + container.clientHeight < element.offsetTop + element.offsetHeight) {\n element.scrollIntoView(false);\n }\n\n element.focus();\n }\n};\n\nexport const NotificationRequest = ({ multiColumn, params: { id } }) => {\n const columnRef = useRef();\n const intl = useIntl();\n const dispatch = useDispatch();\n const notificationRequest = useSelector(state => state.notificationRequests.current.item?.id === id ? state.notificationRequests.current.item : null);\n const accountId = notificationRequest?.account_id;\n const account = useSelector(state => state.getIn(['accounts', accountId]));\n const notifications = useSelector(state => state.notificationRequests.current.notifications.items);\n const isLoading = useSelector(state => state.notificationRequests.current.notifications.isLoading);\n const hasMore = useSelector(state => !!state.notificationRequests.current.notifications.next);\n const removed = useSelector(state => state.notificationRequests.current.removed);\n\n const handleHeaderClick = useCallback(() => {\n columnRef.current?.scrollTop();\n }, [columnRef]);\n\n const handleLoadMore = useCallback(() => {\n dispatch(expandNotificationsForRequest({ accountId }));\n }, [dispatch, accountId]);\n\n const handleDismiss = useCallback(() => {\n dispatch(dismissNotificationRequest({ id }));\n }, [dispatch, id]);\n\n const handleAccept = useCallback(() => {\n dispatch(acceptNotificationRequest({ id }));\n }, [dispatch, id]);\n\n const handleMoveUp = useCallback(id => {\n const elementIndex = notifications.findIndex(item => item !== null && item.get('id') === id) - 1;\n selectChild(columnRef, elementIndex, true);\n }, [columnRef, notifications]);\n\n const handleMoveDown = useCallback(id => {\n const elementIndex = notifications.findIndex(item => item !== null && item.get('id') === id) + 1;\n selectChild(columnRef, elementIndex, false);\n }, [columnRef, notifications]);\n\n useEffect(() => {\n dispatch(fetchNotificationRequest({ id }));\n }, [dispatch, id]);\n\n useEffect(() => {\n if (accountId) {\n dispatch(fetchNotificationsForRequest({ accountId }));\n }\n }, [dispatch, accountId]);\n\n const columnTitle = intl.formatMessage(messages.title, { name: account?.get('display_name') || account?.get('username') });\n\n let explainer = null;\n\n if (account?.limited) {\n const isLocal = account.acct.indexOf('@') === -1;\n explainer = (\n <div className='dismissable-banner'>\n <div className='dismissable-banner__message'>\n {isLocal ? (\n <FormattedMessage id='notification_requests.explainer_for_limited_account' defaultMessage='Notifications from this account have been filtered because the account has been limited by a moderator.' />\n ) : (\n <FormattedMessage id='notification_requests.explainer_for_limited_remote_account' defaultMessage='Notifications from this account have been filtered because the account or its server has been limited by a moderator.' />\n )}\n </div>\n </div>\n );\n }\n\n return (\n <Column bindToDocument={!multiColumn} ref={columnRef} label={columnTitle}>\n <ColumnHeader\n icon='archive'\n iconComponent={InventoryIcon}\n title={columnTitle}\n onClick={handleHeaderClick}\n multiColumn={multiColumn}\n showBackButton\n extraButton={!removed && (\n <>\n <IconButton className='column-header__button' iconComponent={DeleteIcon} onClick={handleDismiss} title={intl.formatMessage(messages.dismiss)} />\n <IconButton className='column-header__button' iconComponent={DoneIcon} onClick={handleAccept} title={intl.formatMessage(messages.accept)} />\n </>\n )}\n />\n\n <SensitiveMediaContextProvider hideMediaByDefault>\n <ScrollableList\n prepend={explainer}\n scrollKey={`notification_requests/${id}`}\n trackScroll={!multiColumn}\n bindToDocument={!multiColumn}\n isLoading={isLoading}\n showLoading={isLoading && notifications.size === 0}\n hasMore={hasMore}\n onLoadMore={handleLoadMore}\n >\n {notifications.map(item => (\n item && <NotificationContainer\n key={item.get('id')}\n notification={item}\n accountId={item.get('account')}\n onMoveUp={handleMoveUp}\n onMoveDown={handleMoveDown}\n />\n ))}\n </ScrollableList>\n </SensitiveMediaContextProvider>\n\n <Helmet>\n <title>{columnTitle}</title>\n <meta name='robots' content='noindex' />\n </Helmet>\n </Column>\n );\n};\n\nNotificationRequest.propTypes = {\n multiColumn: PropTypes.bool,\n params: PropTypes.shape({\n id: PropTypes.string.isRequired,\n }),\n};\n\nexport default NotificationRequest;\n"],"sourceRoot":""}