Allow feature-gated 10-minute video uploads (#11388)
This commit is contained in:
@@ -70,6 +70,7 @@ import {
|
||||
MAX_GRAPHEME_LENGTH,
|
||||
SUPPORTED_MIME_TYPES,
|
||||
type SupportedMimeTypes,
|
||||
VIDEO_10_MINUTE_MAX_DURATION_MS,
|
||||
VIDEO_MAX_DURATION_MS,
|
||||
} from '#/lib/constants'
|
||||
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||
@@ -267,6 +268,12 @@ export const ComposePost = ({
|
||||
const {currentAccount} = useSession()
|
||||
const t = useTheme()
|
||||
const ax = useAnalytics()
|
||||
const allow10MinuteVideos = ax.features.enabled(
|
||||
ax.features.VideoAllow10MinuteEnable,
|
||||
)
|
||||
const videoMaxDurationMs = allow10MinuteVideos
|
||||
? VIDEO_10_MINUTE_MAX_DURATION_MS
|
||||
: VIDEO_MAX_DURATION_MS
|
||||
const agent = useAgent()
|
||||
const queryClient = useQueryClient()
|
||||
const currentDid = currentAccount!.did
|
||||
@@ -434,7 +441,7 @@ export const ComposePost = ({
|
||||
* Fail early on duration so we don't spend time compressing a video the
|
||||
* server would reject anyway.
|
||||
*/
|
||||
if (asset.duration != null && asset.duration > VIDEO_MAX_DURATION_MS) {
|
||||
if (asset.duration != null && asset.duration > videoMaxDurationMs) {
|
||||
composerDispatch({
|
||||
type: 'update_post',
|
||||
postId: postId,
|
||||
@@ -442,7 +449,9 @@ export const ComposePost = ({
|
||||
type: 'embed_update_video',
|
||||
videoAction: {
|
||||
type: 'to_error',
|
||||
error: l`Videos must be less than 3 minutes long.`,
|
||||
error: allow10MinuteVideos
|
||||
? l`Videos must be 10 minutes or less.`
|
||||
: l`Videos must be less than 3 minutes long.`,
|
||||
signal: abortController.signal,
|
||||
},
|
||||
},
|
||||
@@ -469,7 +478,16 @@ export const ComposePost = ({
|
||||
telemetry,
|
||||
)
|
||||
},
|
||||
[l, i18n, agent, currentDid, composerDispatch, ax.metric],
|
||||
[
|
||||
l,
|
||||
i18n,
|
||||
agent,
|
||||
currentDid,
|
||||
composerDispatch,
|
||||
ax.metric,
|
||||
videoMaxDurationMs,
|
||||
allow10MinuteVideos,
|
||||
],
|
||||
)
|
||||
|
||||
const onInitVideo = useNonReactiveCallback(() => {
|
||||
@@ -566,7 +584,7 @@ export const ComposePost = ({
|
||||
},
|
||||
})
|
||||
|
||||
if (asset.duration != null && asset.duration > VIDEO_MAX_DURATION_MS) {
|
||||
if (asset.duration != null && asset.duration > videoMaxDurationMs) {
|
||||
composerDispatch({
|
||||
type: 'update_post',
|
||||
postId,
|
||||
@@ -574,7 +592,9 @@ export const ComposePost = ({
|
||||
type: 'embed_update_video',
|
||||
videoAction: {
|
||||
type: 'to_error',
|
||||
error: l`Videos must be less than 3 minutes long.`,
|
||||
error: allow10MinuteVideos
|
||||
? l`Videos must be 10 minutes or less.`
|
||||
: l`Videos must be less than 3 minutes long.`,
|
||||
signal: abortController.signal,
|
||||
},
|
||||
},
|
||||
@@ -646,7 +666,16 @@ export const ComposePost = ({
|
||||
})
|
||||
}
|
||||
},
|
||||
[l, i18n, agent, currentDid, composerDispatch, ax.metric],
|
||||
[
|
||||
l,
|
||||
i18n,
|
||||
agent,
|
||||
currentDid,
|
||||
composerDispatch,
|
||||
ax.metric,
|
||||
videoMaxDurationMs,
|
||||
allow10MinuteVideos,
|
||||
],
|
||||
)
|
||||
|
||||
const handleSelectDraft = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user