Changeset View
Changeset View
Standalone View
Standalone View
native/profile/relationship-list-item-tooltip-modal.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { Alert, TouchableOpacity } from 'react-native'; | import { Alert, TouchableOpacity } from 'react-native'; | ||||
import { | import { | ||||
updateRelationshipsActionTypes, | updateRelationshipsActionTypes, | ||||
updateRelationships, | updateRelationships, | ||||
} from 'lib/actions/relationship-actions'; | } from 'lib/actions/relationship-actions'; | ||||
import { stringForUser } from 'lib/shared/user-utils'; | import { stringForUser } from 'lib/shared/user-utils'; | ||||
import type { RelativeUserInfo } from 'lib/types/user-types'; | import type { RelativeUserInfo } from 'lib/types/user-types'; | ||||
import type { DispatchFunctions, ActionFunc } from 'lib/utils/action-utils'; | import type { DispatchFunctions, BindServerCall } from 'lib/utils/action-utils'; | ||||
import PencilIcon from '../components/pencil-icon.react'; | import PencilIcon from '../components/pencil-icon.react'; | ||||
import type { AppNavigationProp } from '../navigation/app-navigator.react'; | import type { AppNavigationProp } from '../navigation/app-navigator.react'; | ||||
import { | import { | ||||
createTooltip, | createTooltip, | ||||
type TooltipParams, | type TooltipParams, | ||||
type BaseTooltipProps, | type BaseTooltipProps, | ||||
} from '../navigation/tooltip.react'; | } from '../navigation/tooltip.react'; | ||||
type Action = 'unfriend' | 'unblock'; | type Action = 'unfriend' | 'unblock'; | ||||
export type RelationshipListItemTooltipModalParams = TooltipParams<{ | export type RelationshipListItemTooltipModalParams = TooltipParams<{ | ||||
+relativeUserInfo: RelativeUserInfo, | +relativeUserInfo: RelativeUserInfo, | ||||
}>; | }>; | ||||
type OnRemoveUserProps = { | type OnRemoveUserProps = { | ||||
...RelationshipListItemTooltipModalParams, | ...RelationshipListItemTooltipModalParams, | ||||
+action: Action, | +action: Action, | ||||
}; | }; | ||||
function onRemoveUser( | function onRemoveUser( | ||||
props: OnRemoveUserProps, | props: OnRemoveUserProps, | ||||
dispatchFunctions: DispatchFunctions, | dispatchFunctions: DispatchFunctions, | ||||
bindServerCall: <F>(serverCall: ActionFunc<F>) => F, | bindServerCall: BindServerCall, | ||||
) { | ) { | ||||
const boundRemoveRelationships = bindServerCall(updateRelationships); | const boundRemoveRelationships = bindServerCall(updateRelationships); | ||||
const callRemoveRelationships = async () => { | const callRemoveRelationships = async () => { | ||||
try { | try { | ||||
return await boundRemoveRelationships({ | return await boundRemoveRelationships({ | ||||
action: props.action, | action: props.action, | ||||
userIDs: [props.relativeUserInfo.id], | userIDs: [props.relativeUserInfo.id], | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |