173 lines
7.0 KiB
TypeScript
173 lines
7.0 KiB
TypeScript
// Metro module 15853 (f15854).
|
|
import { useState, useCallback, useEffect } from "react";
|
|
import { View } from "react-native";
|
|
import { setSendState, useInstantInviteSendStates } from "../../../instant_invite/InstantInviteSendStateStore";
|
|
import InviteSuggestionsStore from "../../../../stores/InviteSuggestionsStore";
|
|
import { ActivityActionTypes } from "../../../../Constants";
|
|
import { InviteSendStates, InviteTargetTypes } from "../../../instant_invite/Constants";
|
|
import { NOOP_NULL } from "../../../../_bundle/Module505";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import UserPlaceholderRow from "../../../main_tabs_v2/native/shared_components/user_list/UserPlaceholderRow";
|
|
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../../app_analytics/useAnalyticsLocations";
|
|
import AnalyticsLocation from "../../../app_analytics/AnalyticsLocation";
|
|
import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators";
|
|
import showUserProfileActionSheet from "../../../user_profile/native/showUserProfileActionSheet";
|
|
import { RowTypes } from "../../../../utils/InstantInviteUtils";
|
|
import ActivitiesActionCreators from "../../../../actions/ActivitiesActionCreators";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { loadInviteSuggestions, searchInviteSuggestions } from "../../../../actions/InviteSuggestionsActionCreators";
|
|
import { BottomSheet } from "../../../../design/components/Sheet/native/BottomSheet.native";
|
|
import { BottomSheetTitleHeader } from "../../../../design/components/Sheet/native/BottomSheetTitleHeader.native";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { EmptyState } from "../../../../design/void/native";
|
|
import { AppCrash } from "../../../../design/components/Illustration/native/redesign/generated/AppCrash";
|
|
import { SearchField } from "../../../../design/components/TextField/native/SearchField.native";
|
|
import ActivityInviteSheetList from "./ActivityInviteSheetList";
|
|
let useStyles;
|
|
const Loading = function Loading() {
|
|
const styles = useStyles();
|
|
const r9 = [];
|
|
let key = 0;
|
|
while (true) {
|
|
r9.push(<UserPlaceholderRow key={key} row={key} />);
|
|
key = key + 1;
|
|
if (!(key < 10)) {
|
|
return <>
|
|
<View style={styles.placeholderHeader} />
|
|
<View style={styles.placeholderLabel} />
|
|
{r9}
|
|
</>;
|
|
}
|
|
}
|
|
};
|
|
useStyles = createStyles({
|
|
placeholderHeader: {
|
|
height: 16,
|
|
width: "80%",
|
|
margin: 16,
|
|
marginBottom: 8,
|
|
borderRadius: Module712.radii.sm,
|
|
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED
|
|
},
|
|
placeholderLabel: {
|
|
height: 16,
|
|
width: "40%",
|
|
margin: 16,
|
|
borderRadius: Module712.radii.sm,
|
|
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED
|
|
},
|
|
emptyState: {
|
|
backgroundColor: "transparent"
|
|
},
|
|
searchAndShareContainer: {
|
|
borderTopWidth: 1,
|
|
borderColor: Module712.colors.BORDER_SUBTLE,
|
|
marginTop: Module712.space.PX_8,
|
|
paddingVertical: Module712.space.PX_8,
|
|
paddingHorizontal: Module712.space.PX_12,
|
|
flexDirection: "column",
|
|
gap: Module712.space.PX_12
|
|
}
|
|
});
|
|
export default function ActivityInviteSheet(props) {
|
|
let setState2;
|
|
const activity = props.activity;
|
|
setState2 = void 0;
|
|
const styles = useStyles();
|
|
const analyticsLocations = useAnalyticsLocations(AnalyticsLocation.ACTIVITY_INVITE_SHEET).analyticsLocations;
|
|
const [title, setState] = useState(null);
|
|
const instantInviteSendStates = useInstantInviteSendStates((a0) => a0);
|
|
const callback3 = useCallback((a0) => {
|
|
const id3 = activity.party?.id;
|
|
const id2 = a0.item.id;
|
|
const r10 = id3 != null;
|
|
let r11 = null;
|
|
if (r10) {
|
|
const r13 = instantInviteSendStates[id3];
|
|
r11 = r13 == null ? void 0 : r13[id2];
|
|
}
|
|
return r11;
|
|
}, [activity, instantInviteSendStates]);
|
|
const callback = useCallback((a0) => {
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
showUserProfileActionSheet({
|
|
userId: a0,
|
|
sourceAnalyticsLocations: analyticsLocations
|
|
});
|
|
}, [analyticsLocations]);
|
|
const callback2 = useCallback((a0) => {
|
|
let c28167_0, id;
|
|
L13: {
|
|
c28167_0 = a0;
|
|
if (activity != null) {
|
|
id = activity.party?.id;
|
|
if (id != null) {
|
|
const markInviteSent = function markInviteSent() {
|
|
if (id != null) {
|
|
setSendState(id, c28167_0.item.id, InviteSendStates.SENT);
|
|
}
|
|
};
|
|
setSendState(id, a0.item.id, InviteSendStates.SENDING);
|
|
if (a0.type === RowTypes.CHANNEL) {
|
|
const id3 = a0.item.id;
|
|
try {
|
|
ActivitiesActionCreators.sendActivityInvite({
|
|
channelId: id3,
|
|
type: ActivityActionTypes.JOIN,
|
|
activity,
|
|
location: AnalyticsLocation.ACTIVITY_INVITE_SHEET
|
|
}).then(markInviteSent).catch((error) => {
|
|
setState(String(error));
|
|
});
|
|
} catch ($e) {
|
|
setState(String($e));
|
|
}
|
|
} else {
|
|
if (a0.type !== RowTypes.DM && a0.type !== RowTypes.FRIEND) {
|
|
break L13;
|
|
}
|
|
const id2 = a0.item.id;
|
|
try {
|
|
ActivitiesActionCreators.sendActivityInviteUser({
|
|
userId: id2,
|
|
type: ActivityActionTypes.JOIN,
|
|
activity,
|
|
location: AnalyticsLocation.ACTIVITY_INVITE_SHEET
|
|
}).then(markInviteSent).catch((error) => setState(String(error)));
|
|
} catch ($e) {
|
|
setState(String($e));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, [activity]);
|
|
const stateFromStores = useStateFromStores([InviteSuggestionsStore], () => InviteSuggestionsStore.getInviteSuggestionRows());
|
|
let state;
|
|
[state, setState2] = useState(false);
|
|
useEffect(() => {
|
|
setState2(true);
|
|
loadInviteSuggestions({
|
|
omitUserIds: new Set(),
|
|
inviteTargetType: InviteTargetTypes.EMBEDDED_APPLICATION
|
|
}).catch(NOOP_NULL).finally(() => {
|
|
setState2(false);
|
|
});
|
|
}, []);
|
|
const r69 = stateFromStores.length === 0 && state;
|
|
const r71 = stateFromStores.length === 0 && !state;
|
|
return <AnalyticsLocationProvider value={analyticsLocations}>
|
|
<BottomSheet showGradient={title != null || !r69 || !r71} scrollable startExpanded header={<BottomSheetTitleHeader title={intl.string(t["OzOM/q"])} />}>
|
|
{title != null ? <EmptyState style={styles.emptyState} Illustration={AppCrash} title={title} /> : r69 ? <Loading /> : <>
|
|
<View>
|
|
<View style={styles.searchAndShareContainer}>
|
|
<SearchField size="md" isRound onChange={searchInviteSuggestions} placeholder={intl.string(t.iI1gMg)} />
|
|
</View>
|
|
</View>
|
|
{r71 ? <EmptyState style={styles.emptyState} title={intl.string(t.ojoWgX)} /> : <ActivityInviteSheetList data={stateFromStores} error={title} getSendState={callback3} onInviteSent={callback2} onPressAvatar={callback} />}
|
|
</>}
|
|
</BottomSheet>
|
|
</AnalyticsLocationProvider>;
|
|
};
|