decord/source/modules/polls/native/PollVotesActionSheet.tsx
2026-07-25 08:10:48 +00:00

386 lines
16 KiB
TypeScript

// Module ID: 9897
// Function ID: 76675
// Name: PollEmoji
// Dependencies: [57, 5, 31, 27, 4123, 4992, 1348, 4350, 1850, 33, 4131, 689, 566, 1392, 5150, 1212, 4661, 4127, 6020, 5217, 7935, 5462, 9898, 9384, 6023, 4320, 3970, 5164, 1273, 9386, 8297, 3992, 4132, 6619, 4067, 3977, 9899, 9900, 5482, 4099, 5187, 2]
// Exports: default
// Module 9897 (PollEmoji)
import _slicedToArray from "_slicedToArray";
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import importAllResult from "module_3992";
import get_ActivityIndicator from "TableRowInner";
import closure_9 from "_isNativeReflectConstruct";
import closure_10 from "_isNativeReflectConstruct";
import closure_11 from "_isNativeReflectConstruct";
import closure_12 from "_isNativeReflectConstruct";
import closure_13 from "_isNativeReflectConstruct";
import jsxProd from "useModalDismissGuardRefreshControl";
import _createForOfIteratorHelperLoose from "_createForOfIteratorHelperLoose";
let closure_14;
let closure_15;
let closure_6;
let closure_7;
let closure_8;
const require = arg1;
function PollEmoji(emoji) {
emoji = emoji.emoji;
const tmp = callback3();
let obj = emoji(566);
const items = [closure_10];
const stateFromStores = obj.useStateFromStores(items, () => {
if (null != emoji.id) {
let animated = emoji.animated;
if (!animated) {
const customEmojiById = outer1_10.getCustomEmojiById(emoji.id);
animated = undefined;
if (null != customEmojiById) {
animated = customEmojiById.animated;
}
animated = null != animated && animated;
const tmp6 = null != animated && animated;
}
let obj = outer1_1(outer1_2[13]);
obj = { id: emoji.id, animated, size: 16 };
return obj.getEmojiURL(obj);
}
});
obj = { style: emoji.style, src: stateFromStores, name: emoji.name, textEmojiStyle: tmp.emojiText, fastImageStyle: tmp.emojiImage };
return callback(importDefault(5150), obj);
}
function PollVotesHeader(message) {
message = message.message;
const selectedAnswerId = message.selectedAnswerId;
const setSelectedAnswerId = message.setSelectedAnswerId;
let tmp = callback3();
const items = [message.reactions];
let tmp3 = null;
const memo = importAllResult.useMemo(() => message(setSelectedAnswerId[18]).getTotalVotes(message.reactions), items);
const ref = importAllResult.useRef(null);
let _isNativeReflectConstruct = importAllResult.useRef(null);
importAllResult = importAllResult.useRef(false);
const items1 = [selectedAnswerId];
const effect = importAllResult.useEffect(() => {
// CreateGeneratorClosureLongIndex (0x67)
const timerId = setTimeout(callback(tmp), 0);
}, items1);
if (null != message.poll) {
let obj = {};
obj = { style: tmp.headerText, variant: "redesign/heading-18/bold", color: "mobile-text-heading-primary", accessibilityRole: "header", children: message.poll.question.text };
const items2 = [callback(message(setSelectedAnswerId[17]).Text, obj), , ];
obj = { style: tmp.subheaderText, variant: "text-md/medium", color: "text-default" };
const intl = message(setSelectedAnswerId[15]).intl;
const obj1 = { count: memo };
obj.children = intl.format(message(setSelectedAnswerId[15]).t.XRkuof, obj1);
items2[1] = callback(message(setSelectedAnswerId[17]).Text, obj);
const obj2 = { gesture: tmp6 };
const obj3 = { ref, style: null, contentContainerStyle: null, horizontal: true, showsHorizontalScrollIndicator: false, accessibilityRole: "tablist" };
({ answerScroll: obj6.style, answerScrollContainer: obj6.contentContainerStyle } = tmp);
const intl2 = message(setSelectedAnswerId[15]).intl;
obj3.accessibilityLabel = intl2.string(message(setSelectedAnswerId[15]).t["qbir+4"]);
const answers = message.poll.answers;
obj3.children = answers.map((answer_id) => {
const tmp = selectedAnswerId === String(answer_id.answer_id);
const obj = {};
let tmp4;
if (tmp) {
tmp4 = _isNativeReflectConstruct;
}
obj.ref = tmp4;
obj.answer = answer_id;
obj.selected = tmp;
obj.reaction = message(setSelectedAnswerId[20]).reactionForId(message.reactions, String(answer_id.answer_id));
obj.setSelectedAnswerId = setSelectedAnswerId;
return outer1_14(outer1_17, obj, answer_id.answer_id);
});
obj2.children = callback(closure_8, obj3);
items2[2] = callback(message(setSelectedAnswerId[19]).GestureDetector, obj2);
obj.children = items2;
tmp3 = callback2(closure_7, obj);
}
return tmp3;
}
function VotersList(channelId) {
channelId = channelId.channelId;
const messageId = channelId.messageId;
const reaction = channelId.reaction;
let sharedValue;
analyticsLocations = messageId(analyticsLocations[21])().analyticsLocations;
const tmp2 = messageId(analyticsLocations[22])({ channelId, messageId, reaction });
const reactors = tmp2.reactors;
let obj = channelId(analyticsLocations[23]);
obj = { channelId, messageId, reactionSelected: reaction, reactors, reactorsHasMore: tmp2.hasMore, reactionType: channelId(analyticsLocations[24]).ReactionTypes.VOTE };
const reactorsOnScrollNative = obj.useReactorsOnScrollNative(obj);
const tmp = callback3();
const items = [closure_11];
const stateFromStores = channelId(analyticsLocations[12]).useStateFromStores(items, () => outer1_11.getChannel(channelId));
const items1 = [stateFromStores, reactors.length, channelId, messageId, analyticsLocations];
const callback = sharedValue.useCallback((item) => {
item = item.item;
const index = item.index;
let obj = messageId(analyticsLocations[25]);
let guild_id;
if (null != stateFromStores) {
guild_id = stateFromStores.guild_id;
}
let id;
if (null != stateFromStores) {
id = stateFromStores.id;
}
let nickname = obj.getNickname(guild_id, id, item);
if (null == nickname) {
let obj1 = messageId(analyticsLocations[26]);
nickname = obj1.getGlobalName(item);
}
const userTag = messageId(analyticsLocations[26]).getUserTag(item);
const user = outer1_13.getUser(item.id);
obj = { start: 0 === index, end: reactors.length - 1 === index };
obj = {};
let guild_id1;
if (null != stateFromStores) {
guild_id1 = stateFromStores.guild_id;
}
obj.guildId = guild_id1;
let tmp14 = item;
if (null != user) {
tmp14 = user;
}
obj.user = tmp14;
obj.size = channelId(analyticsLocations[28]).AvatarSizes.SMALL;
obj.icon = outer1_14(channelId(analyticsLocations[28]).Avatar, obj);
let tmp15 = nickname;
if (null == nickname) {
obj1 = { user: item };
tmp15 = outer1_14(messageId(analyticsLocations[29]), obj1);
}
obj.label = tmp15;
let tmp19 = null;
if (null != nickname) {
tmp19 = userTag;
}
obj.subLabel = tmp19;
obj.onPress = function onPress() {
return messageId(analyticsLocations[30])({ userId: item.id, localUser: item, sourceAnalyticsLocations: outer1_2, channelId: item, messageId: outer1_1 });
};
return outer1_14(channelId(analyticsLocations[27]).TableRow, obj);
}, items1);
const obj3 = channelId(analyticsLocations[12]);
let num = 1;
if (0 === reactors.length) {
num = 0;
}
sharedValue = channelId(analyticsLocations[31]).useSharedValue(num);
const items2 = [sharedValue, reactors.length];
const effect = sharedValue.useEffect(() => {
if (0 !== reactors.length) {
let obj = channelId(analyticsLocations[32]);
obj = { duration: 200 };
const result = sharedValue.set(obj.withTiming(1, obj));
} else {
const result1 = sharedValue.set(0);
}
}, items2);
const obj4 = channelId(analyticsLocations[31]);
class I {
constructor() {
obj = { flex: 1, opacity: null, marginBottom: 32 };
obj.opacity = channelId.get();
return obj;
}
}
I.__closure = { opacity: sharedValue };
I.__workletHash = 8593850252158;
I.__initData = closure_18;
const animatedStyle = channelId(analyticsLocations[31]).useAnimatedStyle(I);
obj = { style: animatedStyle, children: callback(channelId(analyticsLocations[33]).BottomSheetFlashList, { contentContainerStyle: tmp.list, data: reactors, renderItem: callback, onScroll: reactorsOnScrollNative }) };
return callback(messageId(analyticsLocations[31]).View, obj);
}
function NoResults() {
const tmp = callback3();
let obj = { style: tmp.noResultsContainer };
obj = { style: tmp.noResultsImage };
const tmp2 = importDefault(4067)();
const tmp3 = closure_15;
const tmp4 = closure_7;
const tmp5 = callback;
const tmp6 = closure_6;
if (obj3.isThemeDark(tmp2)) {
let tmp7Result = tmp7(9899);
} else {
tmp7Result = tmp7(9900);
}
obj.source = tmp7Result;
const items = [tmp5(tmp6, obj), , ];
obj = { style: tmp.noResultsTitle, variant: "heading-md/bold", color: "mobile-text-heading-primary" };
const intl = require(1212) /* getSystemLocale */.intl;
obj.children = intl.string(require(1212) /* getSystemLocale */.t.vhQK3o);
items[1] = callback(require(4127) /* Text */.Text, obj);
const obj1 = { style: tmp.noResultsSubtitle, variant: "text-sm/semibold", color: "text-default" };
const intl2 = require(1212) /* getSystemLocale */.intl;
obj1.children = intl2.string(require(1212) /* getSystemLocale */.t.bwytdh);
items[2] = callback(require(4127) /* Text */.Text, obj1);
obj.children = items;
return tmp3(tmp4, obj);
}
({ Image: closure_6, View: closure_7, ScrollView: closure_8 } = get_ActivityIndicator);
({ jsx: closure_14, jsxs: closure_15 } = jsxProd);
let obj = { headerText: { textAlign: "center", paddingHorizontal: 16 }, subheaderText: { textAlign: "center", marginTop: 2, paddingHorizontal: 16 }, answerScroll: { marginTop: 24 }, answerScrollContainer: { gap: 4, paddingHorizontal: 16 }, answerName: { marginTop: 16, marginHorizontal: 16, marginBottom: 8 }, list: { paddingHorizontal: 16 } };
obj = { padding: 8, flexDirection: "row", alignItems: "center", borderRadius: require("_createForOfIteratorHelperLoose").radii.xs, maxWidth: 200 };
obj.answerButton = obj;
_createForOfIteratorHelperLoose = { backgroundColor: require("_createForOfIteratorHelperLoose").colors.BORDER_SUBTLE };
obj.answerSelected = _createForOfIteratorHelperLoose;
obj.answerEmoji = { marginRight: 8 };
obj.answerText = { flexShrink: 1 };
obj.emojiText = { fontSize: 16 };
obj.emojiImage = { height: 16, width: 16, flexShrink: 0 };
obj.noResultsContainer = { flexDirection: "column", alignItems: "center", paddingHorizontal: 16 };
obj.noResultsImage = { marginTop: 32, width: 138 };
obj.noResultsTitle = { marginTop: 16, textAlign: "center" };
obj.noResultsSubtitle = { marginTop: 4, textAlign: "center" };
let closure_16 = _createForOfIteratorHelperLoose.createStyles(obj);
let closure_17 = importAllResult.forwardRef((answer, ref) => {
let reaction;
let selected;
let setSelectedAnswerId;
answer = answer.answer;
({ reaction, selected, setSelectedAnswerId } = answer);
const tmp = callback3();
let vote;
if (null != reaction) {
const count_details = reaction.count_details;
if (null != count_details) {
vote = count_details.vote;
}
}
let num = 0;
if (null != vote) {
num = vote;
}
const items = [setSelectedAnswerId, answer.answer_id];
let str = "text-default";
const callback = importAllResult.useCallback(() => {
setSelectedAnswerId(String(answer.answer_id));
}, items);
if (selected) {
str = "interactive-text-active";
}
const intl = answer(1212).intl;
let obj = { numVotes: num, option: answer.poll_media.text };
obj = { ref, onPress: callback };
const items1 = [tmp.answerButton, ];
let answerSelected;
if (selected) {
answerSelected = tmp.answerSelected;
}
items1[1] = answerSelected;
obj.style = items1;
obj.accessibilityRole = "tab";
obj.accessibilityState = { selected };
obj.accessibilityLabel = intl.formatToPlainString(answer(1212).t.wqBc7A, obj);
let tmp7 = null;
if (null != answer.poll_media.emoji) {
obj = { style: tmp.answerEmoji, emoji: answer.poll_media.emoji };
tmp7 = callback(PollEmoji, obj);
}
const items2 = [tmp7, , ];
let tmp10 = null;
if (null != answer.poll_media.text) {
const obj1 = { style: tmp.answerText, variant: "text-sm/semibold", color: str, lineClamp: 1, children: answer.poll_media.text };
tmp10 = callback(answer(4127).Text, obj1);
}
items2[1] = tmp10;
const obj2 = { variant: "text-sm/semibold", color: str, lineClamp: 1 };
const items3 = [" ", "(", num.toLocaleString(), ")"];
obj2.children = items3;
items2[2] = callback2(answer(4127).Text, obj2);
obj.children = items2;
return callback2(answer(4661).PressableHighlight, obj);
});
let closure_18 = { code: "function PollVotesActionSheetTsx1(){const{opacity}=this.__closure;return{flex:1,opacity:opacity.get(),marginBottom:32};}" };
let result = require("result").fileFinishedImporting("modules/polls/native/PollVotesActionSheet.tsx");
export default function PollVotesActionSheet(channelId) {
channelId = channelId.channelId;
const messageId = channelId.messageId;
let c4;
const tmp = callback3();
const tmp3 = stateFromStores(importAllResult.useState(channelId.initialAnswerId), 2);
const first = tmp3[0];
let obj = channelId(first[12]);
const items = [closure_12];
stateFromStores = obj.useStateFromStores(items, () => outer1_12.getMessage(channelId, messageId));
c4 = tmp6;
const items1 = [null != stateFromStores && null != stateFromStores.poll];
const effect = importAllResult.useEffect(() => {
if (!c4) {
messageId(first[39]).hideActionSheet("PollVotesActionSheet");
const obj = messageId(first[39]);
}
}, items1);
let reactions;
if (null != stateFromStores) {
reactions = stateFromStores.reactions;
}
const items2 = [reactions, first];
const memo = importAllResult.useMemo(() => {
let reactions;
if (null != stateFromStores) {
reactions = stateFromStores.reactions;
}
if (null != reactions) {
return channelId(first[20]).reactionForId(stateFromStores.reactions, first);
}
}, items2);
if (null != stateFromStores && null != stateFromStores.poll) {
let found;
if (null != stateFromStores) {
const poll = stateFromStores.poll;
if (null != poll) {
const answers = poll.answers;
found = answers.find((answer_id) => String(answer_id.answer_id) === first);
}
}
let vote;
if (null != memo) {
const count_details = memo.count_details;
if (null != count_details) {
vote = count_details.vote;
}
}
let num = 0;
if (null != vote) {
num = vote;
}
obj = { value: tmp2(messageId(first[38]).POLL_VOTES).analyticsLocations };
obj = { scrollable: true };
const obj1 = { message: stateFromStores, selectedAnswerId: first, setSelectedAnswerId: tmp3[1] };
obj.header = callback(PollVotesHeader, obj1);
const obj2 = { style: tmp.answerName, variant: "text-sm/semibold", color: "text-default" };
let text;
if (null != found) {
text = found.poll_media.text;
}
const items3 = [text, " - ", ];
const intl = channelId(first[15]).intl;
const obj3 = { count: num };
items3[2] = intl.format(channelId(first[15]).t["SG/Cyy"], obj3);
obj2.children = items3;
const items4 = [closure_15(channelId(first[17]).Text, obj2), ];
if (null != memo) {
if (num > 0) {
const obj4 = { channelId, messageId, reaction: memo };
let tmp25 = callback(VotersList, obj4);
}
items4[1] = tmp25;
obj.children = items4;
obj.children = tmp16(channelId(first[40]).BottomSheet, obj);
return tmp13(channelId(first[21]).AnalyticsLocationProvider, obj);
}
tmp25 = callback(NoResults, {});
tmp13 = callback;
tmp16 = closure_15;
const tmp19 = closure_15;
} else {
return null;
}
};