179 lines
7.5 KiB
TypeScript
179 lines
7.5 KiB
TypeScript
// Metro module 13543 (f13544).
|
|
import _asyncToGenerator from "../../../_bundle/_asyncToGenerator";
|
|
import { useMemo, useState, useCallback, useEffect } from "react";
|
|
import { View } from "react-native";
|
|
import "../../../stores/ChannelStore";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import EmbeddedActivitiesStore from "../EmbeddedActivitiesStore";
|
|
import { UserRowModes } from "../../main_tabs_v2/native/shared_components/user_list/UserRowConstants";
|
|
import "../../messages/MessageConstants";
|
|
import { jsx } from "react/jsx-runtime";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { getDestinationIdFromChannelId, getOrResolveChannelIdFromDestinationId } from "../../share/formatResults";
|
|
import { getActivityLaunchURL } from "../../applications/getApplicationInstallURL";
|
|
import { closeActivityShareLinkModal } from "../openActivityShareLinkModal.native";
|
|
import useGetOrFetchApplications from "../../applications/useGetOrFetchApplications";
|
|
import { isNotNullish } from "../../../utils/GlobalUtils";
|
|
import { resolveActivityShareMessageContent } from "../utils/activityShareLink";
|
|
import ToastActionCreators from "../../toast/native/ToastActionCreators";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { copy } from "../../../utils/ClipboardUtils.native";
|
|
import { presentLinkCopied } from "../../toast/native/ToastUtils";
|
|
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
|
|
import { isAndroid, isIOS } from "../../../utils/PlatformUtils";
|
|
import { Header } from "../../../_bundle/Module5150";
|
|
import { GenericHeaderTitle } from "../../main_tabs_v2/native/shared_components/HeaderShared";
|
|
import { getHeaderCloseButton } from "../../../design/components/Navigator/native/NavigatorHeader.native";
|
|
import { HeaderActionButton } from "../../../design/components/Navigator/native/HeaderActionButton.native";
|
|
import { LinkIcon } from "../../../design/components/Icon/native/redesign/generated/LinkIcon";
|
|
import ThemedGradient from "../../client_themes/native/ThemedGradient";
|
|
import SearchableDestinationList from "../../share/native/SearchableDestinationList";
|
|
import { ModalFloatingAction } from "../../../design/components/Modal/native/ModalFloatingAction.native";
|
|
function $mk116535($env) {
|
|
return function() {
|
|
let env31689 = {
|
|
$parent: $env
|
|
};
|
|
env31689[0] = (0, _asyncToGenerator)(function*(c32047_0) {
|
|
L11: {
|
|
const r30 = env31689.$parent.$parent;
|
|
const channel = r30[7].getChannel(c32047_0);
|
|
if (channel != null) {
|
|
const r16 = r30[1];
|
|
const r32 = r30[2];
|
|
yield r16(r32[19]).sendMessage(c32047_0, r16(r32[20]).parse(channel, env31689.$parent[1]), false, {
|
|
location: r30[11].ACTIVITY_SHARE
|
|
});
|
|
break L11;
|
|
}
|
|
return void 0;
|
|
}
|
|
});
|
|
return function() {
|
|
return env31689[0].apply(this, arguments);
|
|
};
|
|
};
|
|
}
|
|
let env9402 = {};
|
|
const useStyles = createStyles({
|
|
headerContainer: {
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
paddingVertical: Module712.space.PX_8,
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWER
|
|
},
|
|
header: {
|
|
borderBottomWidth: 0,
|
|
shadowColor: "transparent",
|
|
backgroundColor: "transparent"
|
|
},
|
|
container: {
|
|
flex: 1,
|
|
display: "flex",
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWER
|
|
}
|
|
});
|
|
export default function ActivityShareLinkModal(props) {
|
|
let setState, state, setState2, state2, setState3, stateFromStores2, state3, setState4, c20523_14, callback, height;
|
|
const { applicationId, customId, linkId, message, onShare } = props;
|
|
setState = void 0;
|
|
state = void 0;
|
|
setState2 = void 0;
|
|
state2 = void 0;
|
|
setState3 = void 0;
|
|
stateFromStores2 = void 0;
|
|
state3 = void 0;
|
|
setState4 = void 0;
|
|
c20523_14 = void 0;
|
|
callback = void 0;
|
|
height = void 0;
|
|
const styles = useStyles();
|
|
const stateFromStores = useStateFromStores([EmbeddedActivitiesStore], () => EmbeddedActivitiesStore.getConnectedActivityChannelId());
|
|
const memo = useMemo(() => stateFromStores != null ? getDestinationIdFromChannelId(stateFromStores) : void 0, [stateFromStores]);
|
|
let disabled;
|
|
[disabled, setState] = useState(false);
|
|
[state, setState2] = useState(false);
|
|
[state2, setState3] = useState([]);
|
|
const length = state2.length;
|
|
const callback2 = useCallback((a0) => {
|
|
setState3(a0);
|
|
}, []);
|
|
stateFromStores2 = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
|
|
[state3, setState4] = useState("");
|
|
useEffect(() => {
|
|
setState4(getActivityLaunchURL({
|
|
applicationId,
|
|
referrerId: stateFromStores2?.id,
|
|
customId,
|
|
linkId
|
|
}));
|
|
}, [applicationId, stateFromStores2, customId, linkId, setState4]);
|
|
const callback3 = useCallback(() => {
|
|
onShare(false, state);
|
|
closeActivityShareLinkModal();
|
|
}, [state, onShare]);
|
|
const [r78] = useGetOrFetchApplications([applicationId]);
|
|
c20523_14 = r78;
|
|
const callback4 = useCallback(async () => {
|
|
let c27500_0, c27500_1;
|
|
L13: {
|
|
let env30638;
|
|
c27500_1 = void 0;
|
|
const r9 = env30638 = {
|
|
$parent: env9402
|
|
};
|
|
c27500_0 = r9;
|
|
env30638[0] = void 0;
|
|
env30638[1] = void 0;
|
|
if (c20523_14 != null) {
|
|
const r48 = await Promise.all(state2.map(getOrResolveChannelIdFromDestinationId));
|
|
const r56 = c27500_0;
|
|
env30638[0] = r48.filter(isNotNullish);
|
|
env30638[1] = resolveActivityShareMessageContent(message, c20523_14, state3);
|
|
(0, setState)(true);
|
|
env30638[0].forEach($mk116535(r56)());
|
|
ToastActionCreators.open({
|
|
key: "ACTIVITY_SHARE_LINK_SUCCESS",
|
|
content: intl.formatToPlainString(t.jQULqL, {
|
|
applicationName: c20523_14.name
|
|
})
|
|
});
|
|
(0, onShare)(true, state);
|
|
closeActivityShareLinkModal();
|
|
break L13;
|
|
}
|
|
return void 0;
|
|
}
|
|
}, [r78, state, state3, message, onShare, state2]);
|
|
callback = useCallback(() => {
|
|
copy(state3);
|
|
setState2(true);
|
|
presentLinkCopied();
|
|
}, [state3]);
|
|
height = useWindowDimensions_native({
|
|
ignoreKeyboard: true
|
|
}).height;
|
|
const memo2 = useMemo(() => ({
|
|
height: isAndroid() ? height : "100%"
|
|
}), [height]);
|
|
return <View style={memo2}>
|
|
<View style={styles.headerContainer}>
|
|
<Header headerStyle={styles.header} title={intl.string(t.r9qKow)} headerTitle={(a0) => (0, jsx)(GenericHeaderTitle, {
|
|
title: a0.children,
|
|
subtitle: message,
|
|
variant: "redesign/heading-18/bold"
|
|
})} headerLeft={getHeaderCloseButton(callback3)} headerRight={function headerRight(a0) {
|
|
return <HeaderActionButton {...a0} onPress={callback} accessibilityLabel={intl.string(t.Xrt5Po)} IconComponent={LinkIcon} />;
|
|
}} headerStatusBarHeight={isIOS() ? 0 : void 0} headerTitleAlign="center" />
|
|
</View>
|
|
<View style={styles.container}>
|
|
<ThemedGradient absolute />
|
|
<SearchableDestinationList disableGradient disableStickySections initialSelectedDestinations={[]} insetEnd={0} onSelectedDestinationChange={callback2} originDestination={memo} rowMode={UserRowModes.TOGGLE} />
|
|
<ModalFloatingAction disabled={disabled} floatingBackgroundColor={styles.container.backgroundColor} isVisible={length > 0} loading={disabled} onPress={disabled ? void 0 : callback4} text={length === 1 ? intl.string(t.TXNS7S) : intl.formatToPlainString(t.jWtYUm, {
|
|
count: length
|
|
})} />
|
|
</View>
|
|
</View>;
|
|
};
|