49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
// Metro module 12229 (f12230).
|
|
import { useState, useEffect } from "react";
|
|
import GuildMemberStore from "../../../stores/GuildMemberStore";
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import InviteSuggestionsStore from "../../../stores/InviteSuggestionsStore";
|
|
import { InviteTargetTypes } from "../Constants";
|
|
import { AnalyticEvents } from "../../../Constants";
|
|
import { NOOP_NULL } from "../../../_bundle/Module505";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { loadInviteSuggestions } from "../../../actions/InviteSuggestionsActionCreators";
|
|
export default (a0, a1, a2, a3) => {
|
|
const channel = a0;
|
|
const location2 = a1;
|
|
const inviteTargetType = a2;
|
|
const application_id = a3;
|
|
const stateFromStores = useStateFromStores([InviteSuggestionsStore], () => InviteSuggestionsStore.getInviteSuggestionRows());
|
|
const [state, setState] = useState(true);
|
|
useEffect(() => {
|
|
if (!state) {
|
|
const initialCounts = InviteSuggestionsStore.getInitialCounts();
|
|
AnalyticsUtils.track(AnalyticEvents.INVITE_SUGGESTION_OPENED, {
|
|
location: location2,
|
|
num_suggestions: stateFromStores.length,
|
|
guild_id: channel.guild_id,
|
|
num_friends: initialCounts.numFriends,
|
|
num_dms: initialCounts.numDms,
|
|
num_group_dms: initialCounts.numGroupDms,
|
|
application_id
|
|
});
|
|
}
|
|
}, [stateFromStores, a0, state, a3, a1]);
|
|
useEffect(() => {
|
|
setState(true);
|
|
loadInviteSuggestions({
|
|
omitUserIds: new Set(inviteTargetType === InviteTargetTypes.EMBEDDED_APPLICATION ? [] : GuildMemberStore.getMemberIds(channel.guild_id)),
|
|
guild: GuildStore.getGuild(channel.guild_id),
|
|
channel,
|
|
inviteTargetType
|
|
}).catch(NOOP_NULL).finally(() => {
|
|
setState(false);
|
|
});
|
|
}, [a0, a2]);
|
|
return {
|
|
rows: stateFromStores,
|
|
isFetchingRows: state
|
|
};
|
|
};
|