250 lines
8.6 KiB
TypeScript
250 lines
8.6 KiB
TypeScript
// Metro module 9056 (f9057).
|
|
import RelationshipStore from "../../stores/RelationshipStore";
|
|
import { AbortCodes } from "../../Constants";
|
|
import GameRelationshipActionCreators from "../game_relationships/GameRelationshipActionCreators";
|
|
import RelationshipActionCreators from "../../actions/RelationshipActionCreators";
|
|
import * as _RegionalFeatureConfigUtils from "../regional_feature_config/RegionalFeatureConfigUtils";
|
|
import { SettingsDefaultFeature } from "../../_bundle/Module3875";
|
|
import * as _FriendRequestAlertsV2 from "../user_settings/content_and_social/FriendRequestAlertsV2";
|
|
import { openAcceptFriendRequestConfirmModal } from "./strangers/AcceptFriendRequestModalActionCreators.native";
|
|
import Dispatcher from "../../Dispatcher";
|
|
import { HermesBuiltin } from "../../_hermes/prelude";
|
|
function $mk81810($env) {
|
|
return () => {
|
|
const r2 = {};
|
|
const r13 = $env[0];
|
|
HermesBuiltin.copyDataProperties(r2, r13);
|
|
r2.confirmStrangerRequest = true;
|
|
const { userId: userId2, applicationId: applicationId2, location: location3, confirmStrangerRequest = false } = r2;
|
|
const r15 = $env.$parent;
|
|
if (applicationId2 != null) {
|
|
(0, r15[1])(r15[2][2]).acceptGameFriendRequest({
|
|
userId: userId2,
|
|
applicationId: applicationId2
|
|
});
|
|
} else {
|
|
(0, r15[1])(r15[2][3]).acceptFriendRequest({
|
|
userId: userId2,
|
|
confirmStrangerRequest,
|
|
context: {
|
|
location: location3
|
|
}
|
|
});
|
|
}
|
|
const onConfirm3 = r13.onConfirm;
|
|
if (onConfirm3 != null) {
|
|
onConfirm3.call(r13);
|
|
}
|
|
};
|
|
}
|
|
function $mk81811($env) {
|
|
return () => {
|
|
const r2 = $env[0];
|
|
const onCancel3 = r2.onCancel;
|
|
if (onCancel3 != null) {
|
|
onCancel3.call(r2);
|
|
}
|
|
};
|
|
}
|
|
let env5925 = {};
|
|
const r18 = {
|
|
removeFriend: function removeFriend({ userId: userId2, applicationId: applicationId2, location: location3 }) {
|
|
if (applicationId2 != null) {
|
|
GameRelationshipActionCreators.removeGameFriend({
|
|
userId: userId2,
|
|
applicationId: applicationId2
|
|
});
|
|
} else {
|
|
RelationshipActionCreators.removeFriend(userId2, {
|
|
location: location3
|
|
});
|
|
}
|
|
},
|
|
cancelFriendRequest: function cancelFriendRequest({ userId: userId2, applicationId: applicationId2, location: location3 }) {
|
|
return applicationId2 != null ? GameRelationshipActionCreators.cancelGameFriendRequest({
|
|
userId: userId2,
|
|
applicationId: applicationId2
|
|
}) : RelationshipActionCreators.cancelFriendRequest(userId2, {
|
|
location: location3
|
|
});
|
|
},
|
|
acceptFriendRequest: function acceptFriendRequest({ userId: userId2, applicationId: applicationId2, location: location3, confirmStrangerRequest = false }) {
|
|
return applicationId2 != null ? GameRelationshipActionCreators.acceptGameFriendRequest({
|
|
userId: userId2,
|
|
applicationId: applicationId2
|
|
}) : RelationshipActionCreators.acceptFriendRequest({
|
|
userId: userId2,
|
|
confirmStrangerRequest,
|
|
context: {
|
|
location: location3
|
|
}
|
|
});
|
|
},
|
|
maybeConfirmFriendRequestAccept: function maybeConfirmFriendRequestAccept(a0) {
|
|
let userId, applicationId, location2, onConfirm2, onCancel2, onFinally2;
|
|
L13: {
|
|
userId = a0.userId;
|
|
applicationId = a0.applicationId;
|
|
location2 = a0.location;
|
|
onConfirm2 = a0.onConfirm;
|
|
onCancel2 = a0.onCancel;
|
|
onFinally2 = a0.onFinally;
|
|
const isSettingTeenByDefault = _RegionalFeatureConfigUtils.isSettingTeenByDefault(SettingsDefaultFeature.FRIEND_REQUEST_STRANGER_CONFIRMATION);
|
|
const isFriendRequestAlertsV2Enabled = _FriendRequestAlertsV2.isFriendRequestAlertsV2Enabled("maybeConfirmFriendRequestAccept");
|
|
const isStranger = RelationshipStore.isStranger(userId);
|
|
if (applicationId == null) {
|
|
if (!isSettingTeenByDefault && !isFriendRequestAlertsV2Enabled) {
|
|
break L13;
|
|
}
|
|
if (isStranger !== false) {
|
|
if (isStranger) {
|
|
openAcceptFriendRequestConfirmModal({
|
|
onConfirm: () => {
|
|
if (applicationId != null) {
|
|
GameRelationshipActionCreators.acceptGameFriendRequest({
|
|
userId,
|
|
applicationId
|
|
});
|
|
} else {
|
|
RelationshipActionCreators.acceptFriendRequest({
|
|
userId,
|
|
confirmStrangerRequest: true,
|
|
context: {
|
|
location: location2
|
|
}
|
|
});
|
|
}
|
|
if (onConfirm2 != null) {
|
|
onConfirm2();
|
|
}
|
|
},
|
|
onCancel: () => {
|
|
if (onCancel2 != null) {
|
|
onCancel2();
|
|
}
|
|
},
|
|
onFinally: () => {
|
|
if (onFinally2 != null) {
|
|
onFinally2();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
const r33 = {
|
|
userId,
|
|
applicationId,
|
|
location: location2
|
|
};
|
|
const { userId: userId2, applicationId: applicationId2, location: location3, confirmStrangerRequest = false } = r33;
|
|
(applicationId2 != null ? GameRelationshipActionCreators.acceptGameFriendRequest({
|
|
userId: userId2,
|
|
applicationId: applicationId2
|
|
}) : RelationshipActionCreators.acceptFriendRequest({
|
|
userId: userId2,
|
|
confirmStrangerRequest,
|
|
context: {
|
|
location: location3
|
|
}
|
|
})).then((result) => {
|
|
let r22;
|
|
let env26352;
|
|
const r6 = env5925;
|
|
const r11 = {
|
|
userId,
|
|
applicationId,
|
|
location: location2,
|
|
onConfirm: onConfirm2,
|
|
onCancel: onCancel2
|
|
};
|
|
const r8 = env26352 = {
|
|
$parent: r6
|
|
};
|
|
env26352[0] = r11;
|
|
if ((result == null ? void 0 : result.body?.code) === AbortCodes.RELATIONSHIP_INVALID_NO_CONFIRMATION) {
|
|
Dispatcher.dispatch({
|
|
type: "UPDATE_STRANGER_STATUS",
|
|
userId: r11.userId,
|
|
isStranger: true
|
|
});
|
|
openAcceptFriendRequestConfirmModal({
|
|
onConfirm: $mk81810(r8),
|
|
onCancel: $mk81811(r8)
|
|
});
|
|
r22 = true;
|
|
} else {
|
|
const ok = result?.ok;
|
|
r22 = false;
|
|
if (ok) {
|
|
Dispatcher.dispatch({
|
|
type: "UPDATE_STRANGER_STATUS",
|
|
userId: r11.userId,
|
|
isStranger: false
|
|
});
|
|
r22 = false;
|
|
}
|
|
}
|
|
if (!r22 && onConfirm2 != null) {
|
|
onConfirm2();
|
|
}
|
|
}).catch((error) => {
|
|
let env26353;
|
|
const r4 = env5925;
|
|
const r9 = {
|
|
userId,
|
|
applicationId,
|
|
location: location2,
|
|
onConfirm: onConfirm2,
|
|
onCancel: onCancel2
|
|
};
|
|
const r14 = env26353 = {
|
|
$parent: r4
|
|
};
|
|
env26353[0] = r9;
|
|
if ((error == null ? void 0 : error.body?.code) === AbortCodes.RELATIONSHIP_INVALID_NO_CONFIRMATION) {
|
|
Dispatcher.dispatch({
|
|
type: "UPDATE_STRANGER_STATUS",
|
|
userId: r9.userId,
|
|
isStranger: true
|
|
});
|
|
openAcceptFriendRequestConfirmModal({
|
|
onConfirm: $mk81810(r14),
|
|
onCancel: $mk81811(r14)
|
|
});
|
|
} else if (error?.ok) {
|
|
Dispatcher.dispatch({
|
|
type: "UPDATE_STRANGER_STATUS",
|
|
userId: r9.userId,
|
|
isStranger: false
|
|
});
|
|
}
|
|
}).finally(() => {
|
|
if (onFinally2 != null) {
|
|
onFinally2();
|
|
}
|
|
});
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
}
|
|
return (applicationId != null ? GameRelationshipActionCreators.acceptGameFriendRequest({
|
|
userId,
|
|
applicationId
|
|
}) : RelationshipActionCreators.acceptFriendRequest({
|
|
userId,
|
|
confirmStrangerRequest: true,
|
|
context: {
|
|
location: location2
|
|
}
|
|
})).then(() => {
|
|
if (onConfirm2 != null) {
|
|
onConfirm2();
|
|
}
|
|
if (onFinally2 != null) {
|
|
onFinally2();
|
|
}
|
|
});
|
|
}
|
|
};
|
|
export default r18;
|