Changeset View
Changeset View
Standalone View
Standalone View
web/modals/threads/gallery/thread-settings-media-gallery.react.js
// @flow | // @flow | ||||
import invariant from 'invariant'; | |||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { fetchThreadMedia } from 'lib/actions/thread-actions.js'; | import { fetchThreadMedia } from 'lib/actions/thread-actions.js'; | ||||
import { useModalContext } from 'lib/components/modal-provider.react.js'; | import { useModalContext } from 'lib/components/modal-provider.react.js'; | ||||
import type { Media } from 'lib/types/media-types.js'; | import type { Media } from 'lib/types/media-types.js'; | ||||
import type { ThreadInfo } from 'lib/types/thread-types.js'; | import type { ThreadInfo } from 'lib/types/thread-types.js'; | ||||
import { useServerCall } from 'lib/utils/action-utils.js'; | import { useServerCall } from 'lib/utils/action-utils.js'; | ||||
Show All 32 Lines | const fetchData = async () => { | ||||
}); | }); | ||||
setMediaInfos(result.media); | setMediaInfos(result.media); | ||||
}; | }; | ||||
fetchData(); | fetchData(); | ||||
}, [callFetchThreadMedia, threadID, limit]); | }, [callFetchThreadMedia, threadID, limit]); | ||||
const onClick = React.useCallback( | const onClick = React.useCallback( | ||||
(media: Media) => { | (media: Media) => { | ||||
invariant( | |||||
media.type === 'photo' || media.type === 'video', | |||||
'<MultimediaModal> supports only unencrypted images and videos', | |||||
); | |||||
pushModal(<MultimediaModal type={media.type} uri={media.uri} />); | pushModal(<MultimediaModal type={media.type} uri={media.uri} />); | ||||
}, | }, | ||||
[pushModal], | [pushModal], | ||||
); | ); | ||||
const filteredMediaInfos = React.useMemo(() => { | const filteredMediaInfos = React.useMemo(() => { | ||||
if (tab === 'Images') { | if (tab === 'Images') { | ||||
return mediaInfos.filter(mediaInfo => mediaInfo.type === 'photo'); | return mediaInfos.filter(mediaInfo => mediaInfo.type === 'photo'); | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |