decord/source/modules/polls/PollsActionCreators.tsx
github-actions 20a21ad13f chore: update source for alpha 346.5
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4791.js (118.4 MB)
2026-09-11 19:12:58 +00:00

875 lines
31 KiB
TypeScript

// Module ID: 11807
// Function ID: 11808
// Name: PollsActionCreators
// Dependencies: [5, 4246, 7667, 502, 1957, 4947, 5464, 4827, 4946, 11521, 1074, 38, 4950, 1114, 5571, 11808, 11810, 4786, 12, 504, 573, 7835, 11819, 4458, 11813, 7529, 9400, 4507, 2]
// Module 11807 (PollsActionCreators)
import AppAnalyticsUtilsDefault from "AppAnalyticsUtils" /* 4786 */;
import AlertActionCreatorsDefault from "AlertActionCreators" /* 4950 */;
import GuildActionCreatorsDefault from "GuildActionCreators" /* 5571 */;
import PollInteractionUtilsAll from "PollInteractionUtils" /* 11808 */;
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
import LurkingStore from "LurkingStore" /* 4246 */;
import ReferencedMessageStore from "ReferencedMessageStore" /* 7667 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import GuildVerificationStore from "GuildVerificationStore" /* 5464 */;
import MessageStore from "MessageStore" /* 4827 */;
import UploadAttachmentStore from "UploadAttachmentStore" /* 4946 */;
const require = fn;
function getPollVoteEventProperties(arg0, arg1) {
closure_0 = arg0;
const items = [...arg1];
importDefault = 0;
importAll = 0;
for (const item10012 of items) {
let tmp = (function _loop(item10012) {
closure_0 = item10012;
let poll_media;
if (closure_0 != null) {
const found = closure_0.find((answer_id) => answer_id.answer_id === parseInt(closure_0));
if (found != null) {
poll_media = found.poll_media;
}
}
let text;
if (poll_media != null) {
text = poll_media.text;
}
if (null != text) {
closure_1 = closure_1 + 1;
}
let emoji;
if (poll_media != null) {
emoji = poll_media.emoji;
}
if (null != emoji) {
closure_2 = closure_2 + 1;
}
})(item10012);
continue;
}
return { analyticsSelectedAnswerIds: items, selectedTextAnswersCount: importDefault, selectedEmojiAnswersCount: importAll };
}
function showLurkingAlert(guildId) {
guildId = guildId.guildId;
({ title, body } = guildId);
const obj2 = { title, body, confirmText: null, cancelText: null, onConfirm: null };
const intl = guildId(1114).intl;
obj2.confirmText = intl.string(guildId(1114).t["9VLmlZ"]);
const intl2 = guildId(1114).intl;
obj2.cancelText = intl2.string(guildId(1114).t["2m+Sqk"]);
obj2.onConfirm = function onConfirm() {
GuildActionCreatorsDefault.joinGuild(guild_id, { source: constants2.POLL_ALERT });
};
AlertActionCreatorsDefault.show(obj2);
}
function handleShowVotesForAnswer(messageId) {
({ channelId, answerId } = messageId);
const channel = ChannelStore.getChannel(channelId);
if (null != channel) {
if (LurkingStore.isLurking(channel.guild_id)) {
const intl = guild_id(1114).intl;
const intl2 = guild_id(1114).intl;
guild_id = channel.guild_id;
const stringResult = intl.string(guild_id(1114).t["7LpysO"]);
const stringResult1 = intl2.string(guild_id(1114).t["5sHHoy"]);
const obj2 = { title: stringResult, body: stringResult1, confirmText: null, cancelText: null, onConfirm: null };
const intl3 = guild_id(1114).intl;
obj2.confirmText = intl3.string(guild_id(1114).t["9VLmlZ"]);
const intl4 = guild_id(1114).intl;
obj2.cancelText = intl4.string(guild_id(1114).t["2m+Sqk"]);
obj2.onConfirm = function onConfirm() {
GuildActionCreatorsDefault.joinGuild(guild_id, { source: constants2.POLL_ALERT });
};
AlertActionCreatorsDefault.show(obj2);
} else {
const message = MessageStore.getMessage(channelId, messageId.messageId);
if (null != message) {
if (null != message.poll) {
if (0 !== message.poll.answers.length) {
if (answerId == null) {
const _String = String;
answerId = String(message.poll.answers[0].answer_id);
}
const obj4 = { message, initialAnswerId: answerId };
PollInteractionUtilsAll.showVotesForAnswer(obj4);
}
}
}
}
}
}
function handleUpdateVoteEditingState(channelId) {
channelId = channelId.channelId;
const isEditing = channelId.isEditing;
closure_1_14(channelId, channelId.messageId, (showResults) => {
const obj = { channelId, selectedAnswerIds: new Set(), submitting: false, editing: isEditing, showResults: null };
let flag;
if (showResults != null) {
flag = showResults.showResults;
}
if (flag == null) {
flag = false;
}
obj.showResults = flag;
return obj;
});
}
function getCurrentAnswerIds(channelId) {
const message = MessageStore.getMessage(channelId.channelId, channelId.messageId);
if (null == message) {
let items = [];
} else {
const reactions = message.reactions;
items = reactions.flatMap((me_vote) => {
if (true === me_vote.me_vote) {
let name = me_vote.emoji.name;
} else {
name = [];
}
return name;
});
}
return items;
}
function optimisticallySetAnswers() {
const self = this;
const apply = closure_23.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
}
let closure_23 = async function _optimisticallySetAnswers(arg0, value) {
if (c5 === 2) {
c5 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
let obj2 = { value, done: true };
return obj2;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c5 = 2;
if (0 === c4) {
if (arg0 === 1) {
c5 = 3;
throw value;
} else if (arg0 === 2) {
c5 = 3;
let obj3 = { value, done: true };
return obj3;
} else {
dependencyMap = tmp5;
closure_2 = tmp2;
closure_130_0 = undefined;
closure_130_1 = undefined;
closure_130_2 = undefined;
({ channelId: closure_130_0, messageId: closure_130_1, answerIds: closure_130_2 } = channelId);
closure_130_3 = undefined;
closure_130_4 = undefined;
closure_130_5 = undefined;
let id;
closure_130_7 = undefined;
closure_130_8 = undefined;
c4 = 1;
c5 = 1;
return { value: "PX_16", done: null };
}
} else {
if (1 === tmp5) {
if (arg0 === 1) {
c5 = 3;
throw value;
} else if (arg0 === 2) {
c5 = 3;
const obj4 = { value, done: true };
return obj4;
} else {
const obj5 = { channelId: closure_130_0, messageId: closure_130_1 };
closure_130_3 = closure_131_21(obj5);
closure_130_4 = closure_131_1(closure_131_3[18]).difference(closure_130_3, closure_130_2);
const obj7 = closure_131_1(closure_131_3[18]);
closure_130_5 = closure_131_1(closure_131_3[18]).difference(closure_130_2, closure_130_3);
id = closure_131_7.getId();
let messageId = 0;
const items = [];
messageId = HermesBuiltin.arraySpread(closure_130_4.map((id) => ({ type: "MESSAGE_REACTION_REMOVE", id })), messageId);
messageId = HermesBuiltin.arraySpread(closure_130_5.map((id) => ({ type: "MESSAGE_REACTION_ADD", id })), messageId);
closure_130_7 = items;
const Emitter = closure_131_1(closure_131_3[19]).Emitter;
closure_130_8 = Emitter.batched(() => {
let dispatchResult;
for (const item10006 of closure_1_7) {
let id = item10006.id;
let obj = messageId(573);
let obj2 = { type: item10006.type, channelId: null, messageId: null, emoji: null, userId: null, optimistic: true, reactionType: null };
obj2.channelId = channelId;
obj2.messageId = messageId;
let obj3 = { id, name: id };
obj2.emoji = obj3;
obj2.userId = userId;
obj2.reactionType = channelId(7835).ReactionTypes.VOTE;
dispatchResult = obj.dispatch(obj2);
continue;
}
return dispatchResult;
});
if (null != closure_130_8) {
c4 = 2;
c5 = 1;
const obj6 = { value: closure_130_8, done: false };
return obj6;
}
const obj8 = closure_131_1(closure_131_3[18]);
}
} else if (arg0 === 1) {
c5 = 3;
throw value;
} else if (arg0 === 2) {
c5 = 3;
let obj = { value, done: true };
return obj;
}
c5 = 3;
return { value: "HermesInternal", done: null };
}
} catch (tmp8) {
c5 = tmp;
throw tmp8;
}
}
};
function handlePollSubmitVote() {
const self = this;
const apply = closure_25.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
}
let closure_25 = async function _handlePollSubmitVote(arg0, value) {
closure_5 = tmp3;
({ channelId: closure_132_0, messageId: closure_132_1 } = closure_0);
await "PX_16";
if (1 === tmp7) {
if (arg0 === 1) {
c9 = 3;
throw value;
} else if (arg0 === 2) {
c9 = 3;
return { value, done: true };
} else {
const channel = closure_133_8.getChannel(closure_132_0);
if (null != channel) {
if (closure_133_5.isLurking(channel.guild_id)) {
const obj6 = { guildId: channel.guild_id, title: null, body: null };
const intl7 = closure_133_0(closure_133_3[13]).intl;
obj6.title = intl7.string(closure_133_0(closure_133_3[13]).t.Qic1FD);
const intl8 = closure_133_0(closure_133_3[13]).intl;
obj6.body = intl8.string(closure_133_0(closure_133_3[13]).t["5sHHoy"]);
closure_133_18(obj6);
} else if (closure_133_10.canChatInGuild(channel.guild_id)) {
closure_132_3 = closure_133_13(closure_132_0, closure_132_1);
closure_133_1(closure_133_3[11])(null != closure_132_3, "Must not be able to vote without existing state!");
closure_132_4 = closure_133_21({ channelId: closure_132_0, messageId: closure_132_1 });
c7 = 1;
closure_3 = 0;
const selectedAnswerIds = closure_132_3.selectedAnswerIds;
const items = [];
closure_3 = HermesBuiltin.arraySpread(selectedAnswerIds.values(), closure_3);
closure_132_5 = items;
closure_133_14(closure_132_0, closure_132_1, (arg0) => {
body(closure_1_3[11])(null != arg0, "Must not be able to vote without existing state!");
const obj = {};
const merged = Object.assign(arg0);
obj.submitting = true;
obj.editing = false;
return obj;
});
c8 = 3;
c9 = 1;
return { value: closure_133_22({ channelId: closure_132_0, messageId: closure_132_1, answerIds: closure_132_5 }), done: false };
} else {
const obj12 = { title: null, body: null };
const intl5 = closure_133_0(closure_133_3[13]).intl;
obj12.title = intl5.string(closure_133_0(closure_133_3[13]).t.p245wu);
const intl6 = closure_133_0(closure_133_3[13]).intl;
obj12.body = intl6.string(closure_133_0(closure_133_3[13]).t["U/uodt"]);
closure_133_1(closure_133_3[12]).show(obj12);
closure_133_1(closure_133_3[12]);
}
}
c9 = 3;
}
} else if (2 === tmp7) {
c7 = 0;
closure_132_6 = closure_6;
const obj13 = { title: null, body: null };
const intl3 = closure_133_0(closure_133_3[13]).intl;
obj13.title = intl3.string(closure_133_0(closure_133_3[13]).t.iufib1);
const getAnyErrorMessage = closure_132_6.getAnyErrorMessage;
let anyErrorMessage;
if (getAnyErrorMessage != null) {
anyErrorMessage = getAnyErrorMessage();
}
let message = anyErrorMessage;
if (anyErrorMessage == null) {
message = closure_132_6.message;
}
let body = message;
if (message == null) {
const intl4 = closure_133_0(closure_133_3[13]).intl;
body = intl4.string(closure_133_0(closure_133_3[13]).t.eAn6z2);
}
obj13.body = body;
closure_133_1(closure_133_3[12]).show(obj13);
c8 = 5;
c9 = 1;
return { value: closure_133_22({ channelId: closure_132_0, messageId: closure_132_1, answerIds: closure_132_4 }), done: false };
} else if (3 === tmp7) {
if (arg0 === 1) {
c9 = 3;
throw value;
} else if (arg0 === 2) {
c7 = 0;
c9 = 3;
return { value, done: true };
} else {
c8 = 4;
c9 = 1;
return { value: closure_133_2(closure_133_3[22]).submitPollVote({ channelId: closure_132_0, messageId: closure_132_1, answerIds: closure_132_5 }), done: false };
}
} else if (4 === tmp7) {
if (arg0 === 1) {
c9 = 3;
throw value;
} else if (arg0 === 2) {
c7 = 0;
c9 = 3;
return { value, done: true };
} else {
closure_133_14(closure_132_0, closure_132_1, () => {
});
const AccessibilityAnnouncer = closure_133_0(closure_133_3[23]).AccessibilityAnnouncer;
if (0 === closure_132_5.length) {
const intl2 = closure_133_0(closure_133_3[13]).intl;
let stringResult = intl2.string(closure_133_0(closure_133_3[13]).t["xcvy+3"]);
} else {
const intl = closure_133_0(closure_133_3[13]).intl;
stringResult = intl.string(closure_133_0(closure_133_3[13]).t.o20GSo);
}
AccessibilityAnnouncer.announce(stringResult);
c7 = 0;
}
} else if (arg0 === 1) {
c9 = 3;
throw value;
} else if (arg0 !== 2) {
closure_133_14(closure_132_0, closure_132_1, (arg0) => {
if (null != arg0) {
const obj = {};
const merged = Object.assign(arg0);
obj.submitting = false;
obj.editing = false;
return obj;
}
});
}
return value;
};
let closure_26 = async function _handleClearPollVote() {
({ channelId: closure_129_0, messageId: closure_129_1 } = channelId);
await "PX_16";
const channel = closure_130_8.getChannel(closure_129_0);
if (null != channel) {
if (closure_130_5.isLurking(channel.guild_id)) {
const obj5 = { guildId: channel.guild_id, title: null, body: null };
const intl = closure_130_0(closure_130_3[13]).intl;
obj5.title = intl.string(closure_130_0(closure_130_3[13]).t.B9QnBp);
const intl2 = closure_130_0(closure_130_3[13]).intl;
obj5.body = intl2.string(closure_130_0(closure_130_3[13]).t.BVZCTn);
closure_130_18(obj5);
} else {
closure_130_14(closure_129_0, closure_129_1, (showResults) => {
const obj = { channelId, selectedAnswerIds: new Set(), submitting: false, editing: false, showResults: null };
let flag;
if (showResults != null) {
flag = showResults.showResults;
}
if (flag == null) {
flag = false;
}
obj.showResults = flag;
return obj;
});
c3 = 2;
c4 = 1;
return { value: closure_130_24({ channelId: closure_129_0, messageId: closure_129_1 }), done: false };
}
}
await "HermesInternal";
return arg1;
};
let closure_27 = async function _handlePollActionTapped(arg0, value) {
if (c4 === 2) {
c4 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
let obj2 = { value, done: true };
return obj2;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c4 = 2;
if (0 === c3) {
if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj3 = { value, done: true };
return obj3;
} else {
closure_2 = tmp5;
closure_1 = tmp2;
closure_129_0 = undefined;
closure_129_1 = undefined;
closure_129_2 = undefined;
({ channelId: closure_129_0, messageId: closure_129_1, type: closure_129_2 } = closure_0);
c3 = 1;
c4 = 1;
return { value: "PX_16", done: null };
}
} else {
if (1 === tmp5) {
if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj4 = { value, done: true };
return obj4;
} else if ("submit" === closure_129_2) {
const obj5 = { channelId: closure_129_0, messageId: closure_129_1 };
c3 = 2;
c4 = 1;
const obj6 = { value: closure_130_24(obj5), done: false };
return obj6;
} else if ("remove" === tmp39) {
const obj7 = { channelId: closure_129_0, messageId: closure_129_1 };
c3 = 3;
c4 = 1;
const obj8 = {
value: (function handleClearPollVote() {
const self = this;
const apply = closure_1_26.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
})(obj7),
done: false
};
return obj8;
} else if ("cancel" === tmp39) {
const obj9 = { channelId: closure_129_0, messageId: closure_129_1, isEditing: false };
closure_130_20(obj9);
} else {
if ("showVotes" === tmp39) {
const obj10 = { channelId: closure_129_0, messageId: closure_129_1 };
(function handleShowVotes(channelId) {
channelId = channelId.channelId;
const messageId = channelId.messageId;
closure_14(channelId, messageId, (showResults) => {
message = message.getMessage(channelId, messageId);
let num = 0;
if (null != message) {
const reactions = message.reactions;
num = reactions.reduce((acc, count_details) => {
count_details = count_details.count_details;
let num;
if (count_details != null) {
num = count_details.vote;
}
if (num == null) {
num = 0;
}
return acc + num;
}, 0);
}
closure_2_1(dependencyMap[17]).trackWithMetadata(constants.POLL_SHOW_RESULTS_CLICKED, { channel_id: channelId, message_id: messageId, show_results: null == showResults || !showResults.showResults, votes_count: num });
const obj2 = { channelId, selectedAnswerIds: null, submitting: null, editing: null, showResults: null };
const obj = closure_2_1(dependencyMap[17]);
obj2.selectedAnswerIds = new Set();
let flag;
if (showResults != null) {
flag = showResults.submitting;
}
if (flag == null) {
flag = false;
}
obj2.submitting = flag;
let flag2;
if (showResults != null) {
flag2 = showResults.submitting;
}
if (flag2 == null) {
flag2 = false;
}
obj2.editing = flag2;
obj2.showResults = null == showResults || !showResults.showResults;
return obj2;
});
})(obj10);
} else if ("showVoterDetails" !== tmp39) {
const _HermesInternal = HermesInternal;
closure_130_1(closure_130_3[11])(false, "Unknown poll action type: " + closure_129_2);
const tmp9 = closure_130_1(closure_130_3[11]);
}
const obj11 = { channelId: closure_129_0, messageId: closure_129_1 };
closure_130_19(obj11);
}
} else if (2 === tmp5) {
if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj12 = { value, done: true };
return obj12;
}
} else if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
let obj = { value, done: true };
return obj;
}
c4 = 3;
}
} catch (tmp33) {
c4 = tmp;
throw tmp33;
}
}
};
let closure_28 = async function _createPoll(arg0, arg1) {
closure_2 = tmp3;
({ channel: closure_129_0, question: closure_129_1, answers: closure_129_2, allowMultiSelect: closure_129_3, duration: closure_129_4, layout: closure_129_5, onClose: closure_129_6, scheduledTimestamp: closure_129_7 } = guildId);
await "PX_16";
const uploads = closure_130_12.getUploads(closure_129_0.id, closure_130_9.Poll);
closure_129_9 = closure_129_2.map((text) => {
guildId = text;
let findIndexResult;
if (closure_1_8 != null) {
findIndexResult = closure_1_8.findIndex((id) => id.id === text.localCreationAnswerId);
}
let tmp2;
if (-1 !== findIndexResult) {
const _HermesInternal = HermesInternal;
const items = ["" + findIndexResult];
tmp2 = items;
}
const obj2 = { attachment_ids: tmp2 };
if (closure_1_5 === guildId(11813).PollLayoutTypes.DEFAULT) {
let trimmed;
if (text.text != null) {
trimmed = str2.trim();
}
obj2.text = trimmed;
}
const image = text.image;
let emoji;
if (image != null) {
emoji = image.emoji;
}
if (null != emoji) {
if (null != emoji.id) {
const obj3 = { id: emoji.id, name: "" };
obj2.emoji = obj3;
} else if (null != emoji.optionallyDiverseSequence) {
const obj4 = { name: emoji.optionallyDiverseSequence };
obj2.emoji = obj4;
}
}
return { poll_media: obj2 };
});
closure_129_10 = { question: { text: closure_129_1.trim() }, answers: closure_129_9, allow_multiselect: closure_129_3, duration: closure_129_4, layout_type: closure_129_5 };
await closure_130_1(closure_130_3[25]).sendPollMessage(closure_129_0.id, closure_129_10, {
attachmentsToUpload: uploads,
scheduledTimestamp: closure_129_7,
onAttachmentUploadError(file, code, reason) {
const obj = guildId(9400);
const result = obj.handleUploadMessageAttachmentsErrors({ file, guildId: guildId.getGuildId(), analyticsLocations: [], code, reason });
}
});
if (2 === tmp7) {
c4 = 0;
closure_129_11 = dependencyMap;
if (closure_129_11 instanceof closure_130_0(closure_130_3[27]).APIError) {
let aPIError = closure_129_11;
} else {
aPIError = new closure_130_0(closure_130_3[27]).APIError(closure_129_11);
}
if ("poll" === aPIError.getAnyErrorMessage()) {
if (null != closure_129_11.text) {
const obj9 = {};
const merged = Object.assign(closure_129_11);
const _JSON = JSON;
obj9.body = JSON.parse(closure_129_11.text);
throw obj9;
}
}
if (null == closure_129_7) {
throw closure_129_11;
} else {
c6 = 3;
}
} else if (arg0 === 1) {
c6 = 3;
throw arg1;
} else if (arg0 !== 2) {
if (closure_129_6 != null) {
tmp9(closure_129_7);
}
c4 = 0;
}
return arg1;
};
let closure_29 = async function _endPollEarly(arg0, value) {
if (c4 === 2) {
c4 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp4 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
const obj3 = { value, done: true };
return obj3;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c4 = 2;
if (0 === c3) {
if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj4 = { value, done: true };
return obj4;
} else {
closure_2 = tmp5;
closure_1 = tmp2;
closure_129_0 = undefined;
closure_129_1 = undefined;
({ channelId: closure_129_0, messageId: closure_129_1 } = closure_0);
c3 = 1;
c4 = 1;
return { value: "PX_16", done: null };
}
} else if (1 === tmp5) {
if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj5 = { value, done: true };
return obj5;
} else {
const obj6 = { title: null, body: null };
const intl = closure_130_0(closure_130_3[13]).intl;
obj6.title = intl.string(closure_130_0(closure_130_3[13]).t["+rfkTK"]);
const intl2 = closure_130_0(closure_130_3[13]).intl;
obj6.body = intl2.string(closure_130_0(closure_130_3[13]).t.H2I1gL);
c3 = 2;
c4 = 1;
const obj7 = { value: closure_130_1(closure_130_3[12]).confirm(obj6), done: false };
return obj7;
}
} else {
if (2 === tmp5) {
if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj8 = { value, done: true };
return obj8;
} else if (value) {
const obj9 = { channelId: closure_129_0, messageId: closure_129_1 };
c3 = 3;
c4 = 1;
const obj11 = { value: closure_130_2(closure_130_3[22]).endPollEarly(obj9), done: false };
return obj11;
}
} else if (arg0 === 1) {
c4 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 3;
const obj = { value, done: true };
return obj;
}
c4 = 3;
return { value: "HermesInternal", done: null };
}
} catch (tmp13) {
c4 = tmp;
throw tmp13;
}
}
};
const DraftType = fn(4947).DraftType;
const PollsInteractionStore = fn(11521);
({ getPollState: map1, updatePollState: closure_14 } = PollsInteractionStore);
const Constants = fn(1074);
({ AnalyticEvents: closure_15, JoinGuildSources: closure_16 } = Constants);
const size = fn(2);
let result = size.fileFinishedImporting("modules/polls/PollsActionCreators.tsx");
export default {
handlePollAnswerTapped(answerId) {
answerId = answerId.answerId;
let merged = Object.assign(answerId, Object.assign({ answerId: 0 }));
let channelId2;
let messageId2;
let message;
let allow_multiselect;
({ channelId, messageId } = merged);
const message1 = MessageStore.getMessage(channelId, messageId);
if (null != message1) {
let obj2 = { message: message1, channelId, messageId };
let obj = obj2;
} else {
const message2 = ReferencedMessageStore.getMessage(channelId, messageId);
if (null != message2.message) {
obj = { channelId, messageId, message: message2.message };
} else {
channelId2(message[11])(null != message1, "Tapped on a non-existent poll message");
const _Error = Error;
const error = new Error();
throw error;
}
}
channelId2 = obj.channelId;
messageId2 = obj.messageId;
message = obj.message;
let basicPollChatData = answerId(message[16]).computeBasicPollChatData(message);
if (basicPollChatData == null) {
basicPollChatData = {};
}
if (true !== basicPollChatData.tapShouldOpenVotersModal) {
let poll = message.poll;
allow_multiselect = undefined;
if (poll != null) {
allow_multiselect = poll.allow_multiselect;
}
closure_14(channelId2, messageId2, (arg0) => {
if (null == arg0) {
const _Set = Set;
const items = [answerId];
const set = new Set(items);
const poll2 = message.poll;
let answers;
if (poll2 != null) {
answers = poll2.answers;
}
({ analyticsSelectedAnswerIds: analyticsSelectedAnswerIds2, selectedTextAnswersCount: selectedTextAnswersCount2, selectedEmojiAnswersCount: selectedEmojiAnswersCount2 } = getPollVoteEventProperties(answers, set));
const tmp24Result = getPollVoteEventProperties(answers, set);
const obj2 = { channel_id: channelId2, message_id: messageId2, selected_answer_ids: analyticsSelectedAnswerIds2, selected_text_answers_count: selectedTextAnswersCount2, selected_emoji_answers_count: selectedEmojiAnswersCount2 };
AppAnalyticsUtilsDefault.trackWithMetadata(constants.POLL_VOTE_SELECTED, obj2);
const obj4 = { channelId: channelId2, selectedAnswerIds: set, submitting: false, editing: false, showResults: false };
return obj4;
} else {
const obj5 = {};
const merged = Object.assign(arg0);
const _Set2 = Set;
const set1 = new Set(obj5.selectedAnswerIds);
obj5.selectedAnswerIds = set1;
if (set1.has(answerId)) {
set1.delete(tmp42);
} else {
if (!allow_multiselect) {
for (const item10007 of tmp41) {
let deleteResult1 = set1.delete(item10007);
continue;
}
}
set1.add(answerId);
}
const poll = message.poll;
let answers1;
if (poll != null) {
answers1 = poll.answers;
}
({ analyticsSelectedAnswerIds, selectedTextAnswersCount, selectedEmojiAnswersCount } = getPollVoteEventProperties(answers1, set1));
tmp42 = answerId;
const tmp8Result = getPollVoteEventProperties(answers1, set1);
const obj6 = { channel_id: channelId2, message_id: messageId2, selected_answer_ids: analyticsSelectedAnswerIds, selected_text_answers_count: selectedTextAnswersCount, selected_emoji_answers_count: selectedEmojiAnswersCount };
AppAnalyticsUtilsDefault.trackWithMetadata(constants.POLL_VOTE_SELECTED, obj6);
return obj5;
}
});
} else {
let obj4 = { channelId: channelId2, messageId: messageId2, answerId };
handleShowVotesForAnswer(obj4);
}
},
handlePollSubmitVote,
handleUpdateVoteEditingState,
handlePollActionTapped() {
const self = this;
const apply = closure_27.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
},
createPoll() {
const self = this;
const apply = closure_28.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
},
endPollEarly() {
const self = this;
const apply = closure_29.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
}
};
export { handleShowVotesForAnswer };