101 lines
3.1 KiB
TypeScript
101 lines
3.1 KiB
TypeScript
// Metro module 10203 (f10204).
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import { InstantInviteSources } from "../../../Constants";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import InstantInviteIcons from "./InstantInviteIcons";
|
|
import Module10204 from "../../../_bundle/Module10204";
|
|
import { showShareActionSheet } from "../../action_sheet/native/showShareActionSheet";
|
|
import getInviteURL from "../../instant_invite/getInviteURL";
|
|
import { copy } from "../../../utils/ClipboardUtils.native";
|
|
import { presentCopiedToClipboard } from "../../toast/native/ToastUtils";
|
|
import { handleCopy } from "../../instant_invite/native/InstantInviteUtils";
|
|
import InstantInviteActionCreators from "../../../actions/InstantInviteActionCreators";
|
|
import ToastActionCreators from "../../toast/native/ToastActionCreators";
|
|
export function useInviteActions({ invite, onInviteRevoked }) {
|
|
let c17761_2;
|
|
c17761_2 = void 0;
|
|
const channel = ChannelStore.getChannel(invite.channel.id);
|
|
const isPrivate = channel == null ? void 0 : channel.isPrivate();
|
|
const r28 = {
|
|
label: intl.string(t.RDE0Sc),
|
|
iconSource: InstantInviteIcons.share,
|
|
action: () => {
|
|
Module10204(() => {
|
|
const url = isPrivate ? void 0 : getInviteURL(invite.code);
|
|
let message = void 0;
|
|
if (isPrivate) {
|
|
const r27 = t["+zWvOQ"];
|
|
let username = UserStore.getCurrentUser()?.username;
|
|
if (username == null) {
|
|
username = "";
|
|
}
|
|
message = intl.formatToPlainString(r27, {
|
|
username,
|
|
link: getInviteURL(invite.code)
|
|
});
|
|
}
|
|
return showShareActionSheet({
|
|
url,
|
|
message
|
|
}, isPrivate ? InstantInviteSources.GROUP_DM : "Guild Instant Invite");
|
|
});
|
|
}
|
|
};
|
|
const r42 = {
|
|
label: intl.string(t.OpuAlK),
|
|
iconSource: InstantInviteIcons.copy,
|
|
action: () => {
|
|
if (isPrivate) {
|
|
handleCopy(invite.code, invite.channel, InstantInviteSources.GROUP_DM, false);
|
|
} else {
|
|
copy(getInviteURL(invite.code));
|
|
presentCopiedToClipboard();
|
|
}
|
|
}
|
|
};
|
|
const r59 = {
|
|
label: intl.string(t.v6Yazx),
|
|
iconSource: InstantInviteIcons.revoke,
|
|
variant: "destructive",
|
|
action: null
|
|
};
|
|
c17761_2 = async () => {
|
|
let c26634_3 = 0;
|
|
L12: {
|
|
try {
|
|
c26634_3 = 1;
|
|
await InstantInviteActionCreators.revokeInvite(invite);
|
|
if (onInviteRevoked != null) {
|
|
onInviteRevoked(invite);
|
|
}
|
|
c26634_3 = 0;
|
|
} catch ($e) {
|
|
let r7 = $e;
|
|
if (c26634_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c26634_3 = 0;
|
|
ToastActionCreators.open({
|
|
key: "ERROR_ANOTHER_TRY",
|
|
content: intl.string(t.CKsXk3)
|
|
});
|
|
break L12;
|
|
} catch ($e) {
|
|
r7 = $e;
|
|
if (c26634_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
};
|
|
r59.action = function() {
|
|
return c17761_2.apply(this, arguments);
|
|
};
|
|
return [r28, r42, r59];
|
|
}
|