Files
discord-decomp/modules/user_profile/native/ProfileGIFSelectActionSheet.tsx
T
2026-11-01 12:12:55 +02:00

128 lines
4.5 KiB
TypeScript

// Metro module 13710 (f13711).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import { useRef } from "react";
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import DiscordMd5 from "../../discord_md5/DiscordMd5";
import { createPendingImage, generateAvatarDescription } from "../../recent_avatars/RecentAvatarUtils";
import { setTryItOutAvatar, setTryItOutBanner } from "../UserProfileActionCreators";
import { setPendingChanges } from "../UserProfileSettingsActionCreators";
import { announcePendingAvatarChange } from "../../profile_customization/ProfileCustomizationUtils";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
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 { NitroWheelIcon } from "../../../design/components/Icon/native/redesign/generated/NitroWheelIcon";
import GIFPicker from "../../gif_picker/native/GIFPicker";
function $mk118405($env) {
return (c32052_0) => {
const fileReader = new FileReader();
fileReader.onload = (a0) => {
const result = a0.target?.result;
c32052_0(typeof result === "string" ? result : "");
};
fileReader.readAsDataURL($env[0]);
};
}
const useStyles = createStyles({
titleWrapper: {
flex: 0
},
titleContainer: {
justifyContent: "flex-start"
},
gifPicker: {
flex: 1,
marginTop: Module712.space.PX_4,
marginLeft: Module712.space.PX_8,
marginRight: Module712.space.PX_8
}
});
let c9525_10 = {
AVATAR: 0,
0: "AVATAR",
BANNER: 1,
1: "BANNER"
};
let c9525_11 = {
PROFILE_EDIT: 0,
0: "PROFILE_EDIT",
PROFILE_TRY_IT_OUT: 1,
1: "PROFILE_TRY_IT_OUT"
};
export default function ProfileGIFSelectActionSheet(props) {
const { profileAssetType, selectionContext, guildId } = props;
let _onPressGIF2 = function _onPressGIF() {
const r9 = async (c30664_0) => {
let c30664_3;
let env31698;
c30664_3 = void 0;
const r9 = env31698 = {};
let c30664_2 = r9;
env31698[0] = void 0;
env31698[1] = void 0;
env31698[2] = void 0;
env31698[3] = void 0;
env31698[4] = void 0;
env31698[5] = void 0;
env31698[6] = void 0;
env31698[7] = void 0;
const gifSrc2 = c30664_0.gifSrc;
let gifSrc = gifSrc2;
if (gifSrc2 == null) {
gifSrc = c30664_0.src;
}
env31698[1] = await fetch(gifSrc);
const r62 = await env31698[1].blob();
env31698[2] = r62;
const r72 = Promise;
env31698[0] = env31698[2];
env31698[3] = await r72.all([new Promise($mk118405(c30664_2)), DiscordMd5.fromBlob(env31698[2]).catch(() => null)]);
env31698[4] = (0, _slicedToArray)(env31698[3], 2);
env31698[5] = env31698[4][0];
env31698[6] = env31698[4][1];
if (c9525_10.AVATAR === profileAssetType) {
env31698[7] = createPendingImage({
imageUri: env31698[5],
description: generateAvatarDescription(),
originalMd5: env31698[6]
});
if (selectionContext === c9525_11.PROFILE_TRY_IT_OUT) {
setTryItOutAvatar(env31698[7]);
} else {
setPendingChanges({
guildId,
avatar: env31698[7]
});
announcePendingAvatarChange("set");
}
} else if (c9525_10.BANNER === profileAssetType) {
if (selectionContext === c9525_11.PROFILE_TRY_IT_OUT) {
setTryItOutBanner(env31698[5]);
} else {
setPendingChanges({
banner: env31698[5],
bannerOriginalMd5: env31698[6]
});
}
}
ActionSheetActionCreators.hideActionSheet();
};
_onPressGIF2 = r9;
return r9.apply(this, arguments);
};
const styles = useStyles();
const ref = useRef(null);
return <BottomSheet ref={ref} scrollable startExpanded>
<BottomSheetTitleHeader title={intl.string(t["xsC+/y"])} trailing={<NitroWheelIcon />} titleWrapperStyle={styles.titleWrapper} titleContainerStyle={styles.titleContainer} />
<View style={styles.gifPicker}>
<GIFPicker bottomSheetRef={ref} onPressGIF={function onPressGIF(event) {
return _onPressGIF2.apply(this, arguments);
}} />
</View>
</BottomSheet>;
};
export { c9525_10 as ProfileAssetType };
export { c9525_11 as GIFSelectionContext };