Add timestamp field to video report dialog (#11339)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
type $Typed,
|
||||
BSKY_LABELER_DID,
|
||||
type ChatBskyConvoDefs,
|
||||
type ComAtprotoModerationCreateReport,
|
||||
} from '@atproto/api'
|
||||
@@ -9,7 +10,7 @@ import {useMutation} from '@tanstack/react-query'
|
||||
|
||||
import {logger} from '#/logger'
|
||||
import {useAgent} from '#/state/session'
|
||||
import {NEW_TO_OLD_REASONS_MAP} from './const'
|
||||
import {NEW_TO_OLD_REASONS_MAP, REPORT_MOD_TOOL_NAME} from './const'
|
||||
import {type ReportState} from './state'
|
||||
import {type ParsedReportSubject} from './types'
|
||||
|
||||
@@ -21,9 +22,15 @@ export function useSubmitReportMutation() {
|
||||
async mutationFn({
|
||||
subject,
|
||||
state,
|
||||
videoTimestampSeconds,
|
||||
}: {
|
||||
subject: ParsedReportSubject
|
||||
state: ReportState
|
||||
/**
|
||||
* How far the viewer watched when the dialog opened, if the subject is a
|
||||
* post with a video.
|
||||
*/
|
||||
videoTimestampSeconds?: number
|
||||
}) {
|
||||
if (!state.selectedOption) {
|
||||
throw new Error(_(msg`Please select a reason for this report`))
|
||||
@@ -115,6 +122,21 @@ export function useSubmitReportMutation() {
|
||||
}
|
||||
}
|
||||
|
||||
const modToolMeta =
|
||||
state.includeVideoTimestamp &&
|
||||
videoTimestampSeconds != null &&
|
||||
subject.type === 'post' &&
|
||||
labeler.creator.did === BSKY_LABELER_DID
|
||||
? {videoTimestampSeconds}
|
||||
: undefined
|
||||
|
||||
if (modToolMeta) {
|
||||
report.modTool = {
|
||||
name: REPORT_MOD_TOOL_NAME,
|
||||
meta: modToolMeta,
|
||||
}
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
logger.info('Submitting report (dry run)', {
|
||||
labeler: {
|
||||
|
||||
Reference in New Issue
Block a user