126 lines
4.5 KiB
TypeScript
126 lines
4.5 KiB
TypeScript
// Metro module 10190 (f10191).
|
|
import * as Module19 from "react";
|
|
import { useState, useMemo, useEffect, useCallback } from "react";
|
|
import { View, FlatList, Platform } from "react-native";
|
|
import InviteRecord from "../../../../records/InviteRecord";
|
|
import "../../../../stores/ChannelSettingsStore";
|
|
import { Endpoints, ChannelSettingsSections } from "../../../../Constants";
|
|
import { jsx } from "react/jsx-runtime";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import useMountEffect from "../../../../hooks/useMountEffect";
|
|
import { HTTP } from "../../../../_bundle/sendRequest";
|
|
import Module12 from "../../../../_bundle/Module12";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import InstantInvite from "../../../guild_instant_invites/native/InstantInvite";
|
|
import { SceneLoadingIndicator } from "../../../../design/components/Navigator/native/SceneLoadingIndicator.native";
|
|
import { EmptyState } from "../../../../design/void/native";
|
|
import Module10209 from "../../../../_bundle/Module10209";
|
|
import Module10210 from "../../../../_bundle/Module10210";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { getHeaderCloseButton } from "../../../../design/components/Navigator/native/NavigatorHeader.native";
|
|
import { ImpressionNames } from "../../../../_bundle/Module503";
|
|
import { Navigator } from "../../../../design/components/Navigator/native/Navigator.native";
|
|
function $mk118830($env) {
|
|
return (a0) => new InviteRecord({
|
|
...a0,
|
|
maxUses: a0.max_uses,
|
|
maxAge: a0.max_age,
|
|
createdAt: a0.created_at
|
|
});
|
|
}
|
|
let useStyles;
|
|
let env6795 = {};
|
|
const GroupDMInviteManagement = function GroupDMInviteManagement(props) {
|
|
let setState3;
|
|
const channelId = props.channelId;
|
|
setState3 = void 0;
|
|
const styles = useStyles();
|
|
const [state, setState] = useState([]);
|
|
const [state2, setState2] = useState(true);
|
|
useMountEffect(() => {
|
|
let _fetchInvites2 = function _fetchInvites() {
|
|
const r9 = async () => {
|
|
let c31524_1;
|
|
let env32000;
|
|
c31524_1 = void 0;
|
|
const r23 = env32000 = {
|
|
$parent: env6795
|
|
};
|
|
let c31524_0 = r23;
|
|
env32000[0] = void 0;
|
|
env32000[0] = (await HTTP.get({
|
|
url: Endpoints.INSTANT_INVITES(channelId),
|
|
retries: 3,
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
})).body.map($mk118830(env6795));
|
|
(0, setState)(env32000[0]);
|
|
(0, setState2)(false);
|
|
};
|
|
_fetchInvites2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
(function fetchInvites() {
|
|
return _fetchInvites2.apply(this, arguments);
|
|
})().catch(() => {
|
|
setState2(false);
|
|
});
|
|
});
|
|
let windowSize;
|
|
[windowSize, setState3] = useState(21);
|
|
const memo = useMemo(() => Module12.sortBy(state, ({ inviter }) => {
|
|
const r2 = inviter == null;
|
|
let r6 = void 0;
|
|
if (!r2) {
|
|
const username = inviter.username;
|
|
r6 = username == null ? void 0 : username.toLowerCase();
|
|
}
|
|
if (r6 == null) {
|
|
r6 = "";
|
|
}
|
|
return r6;
|
|
}), [state]);
|
|
useEffect(() => {
|
|
setState3(21);
|
|
}, []);
|
|
const callback = useCallback((a0) => a0.code, []);
|
|
const callback2 = useCallback((a0) => <View style={{
|
|
marginHorizontal: Module712.space.PX_12
|
|
}}>
|
|
<InstantInvite invite={a0.item} onInviteRevoked={(c30204_0) => setState(state.filter((item) => item.code !== c30204_0.code))} />
|
|
</View>, [state]);
|
|
return state2 ? (0, jsx)(SceneLoadingIndicator, {}) : state.length === 0 ? <EmptyState lightSource={Module10209} darkSource={Module10210} title={intl.string(t["+nLJkZ"])} body={intl.string(t.F53CAc)} /> : (0, jsx)(FlatList, {
|
|
style: styles.list,
|
|
data: memo,
|
|
keyExtractor: callback,
|
|
renderItem: callback2,
|
|
initialNumToRender: 10,
|
|
windowSize
|
|
});
|
|
};
|
|
Platform;
|
|
useStyles = createStyles({
|
|
list: {
|
|
paddingTop: 8
|
|
}
|
|
});
|
|
const r44 = Module19.memo(function GroupDMInviteManagementScreen({ channelId: channelId2, onClose }) {
|
|
return (0, jsx)(Navigator, {
|
|
screens: useMemo(() => {
|
|
const channelId3 = channelId2;
|
|
const r11 = {};
|
|
r11[ChannelSettingsSections.INSTANT_INVITES_MANAGEMENT] = {
|
|
title: intl.string(t.OQ9MKu),
|
|
headerLeft: getHeaderCloseButton(onClose),
|
|
render: () => (0, jsx)(GroupDMInviteManagement, {
|
|
channelId: channelId3
|
|
}),
|
|
impressionName: ImpressionNames.GDM_SETTINGS_INVITES
|
|
};
|
|
return r11;
|
|
}, [channelId2, onClose]),
|
|
initialRouteName: ChannelSettingsSections.INSTANT_INVITES_MANAGEMENT
|
|
});
|
|
});
|
|
export default r44;
|