This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
// Metro module 11379 (f11380).
import { POLL_ATTACHMENT_FOLDER } from "./PollsConstants";
export function getFileNameFromGifUrl(a0, a1) {
let r5 = decodeURIComponent(a1).split("/").pop();
if (r5 == null) {
r5 = "temp.gif";
}
return `${a0}-${r5}`;
}
export function getFilePathForGif(a0) {
return POLL_ATTACHMENT_FOLDER + "/" + a0;
}
export async function downloadPollGif(c27049_0) {
let env30399;
const r22 = env30399 = {};
let c27049_2 = r22;
env30399[0] = void 0;
env30399[0] = await fetch(c27049_0);
const convertBlobToBase642 = function convertBlobToBase64(c31623_0) {
let c31623_1 = new FileReader();
return new Promise((c32027_0, reject) => {
c31623_1.onload = () => {
c32027_0(c31623_1.result.split(",").pop());
};
c31623_1.onerror = reject;
c31623_1.readAsDataURL(c31623_0);
});
};
return convertBlobToBase642(await env30399[0].blob());
}
@@ -0,0 +1,9 @@
// Metro module 9958 (f9959).
import ActionSheetActionCreators from "../action_sheet/native/ActionSheetActionCreators";
export function showVotesForAnswer({ message, initialAnswerId }) {
ActionSheetActionCreators.openLazy(import("./native/PollVotesActionSheet"), "PollVotesActionSheet", {
channelId: message.channel_id,
messageId: message.id,
initialAnswerId
});
}
+7
View File
@@ -0,0 +1,7 @@
// Metro module 11380 (f11381).
const r8 = {
PREPARING: "PREPARING",
READY_TO_UPLOAD: "READY_TO_UPLOAD",
ERROR: "ERROR"
};
export { r8 as PollMediaUploadAttachmentStatus };
@@ -0,0 +1,133 @@
// Metro module 11378 (f11379).
import { DraftType } from "../../stores/DraftStore";
import { POLL_ATTACHMENT_FOLDER } from "./PollsConstants";
import { getFileNameFromGifUrl, downloadPollGif, getFilePathForGif } from "./PollAttachmentUtils";
import { writeFile, removeFile, clearFolder } from "../../utils/FileManagerUtils.android";
import { getImageDimensionsIfMissing } from "../../utils/native/UploadUtils";
import { UploadOrigin, UploadPlatform } from "../../lib/uploader/Upload";
import UploadAttachmentActionCreators from "../../actions/UploadAttachmentActionCreators";
export async function handlePollGifAttachmentAdd(c27046_0, c27046_1, c27046_2) {
let r176;
let c27046_6 = 0;
let c30398_0, c30398_1, c30398_2, c30398_3, c30398_4, c30398_5, c30398_6, c30398_7;
L23: {
L22: {
try {
c30398_0 = c27046_0;
c30398_1 = c27046_1;
c30398_2 = void 0;
c30398_3 = void 0;
c30398_4 = void 0;
c30398_5 = void 0;
c30398_6 = void 0;
c30398_7 = void 0;
c30398_2 = getFileNameFromGifUrl(c27046_1, c27046_2);
c27046_6 = 1;
c30398_3 = await downloadPollGif(c27046_2);
if (c30398_3 == null) {
c27046_6 = 0;
break L23;
}
c30398_4 = getFilePathForGif(c30398_2);
c30398_5 = await writeFile("cache", c30398_4, c30398_3, "base64");
if (c30398_5 == null) {
c27046_6 = 0;
break L22;
}
c30398_6 = await getImageDimensionsIfMissing(c30398_5);
c30398_7 = {
id: c30398_1,
origin: UploadOrigin.IMAGE_PICKER,
uri: c30398_5,
originalUri: c30398_5,
filename: c30398_2,
mimeType: "image/gif",
width: c30398_6?.width,
height: c30398_6?.height,
platform: UploadPlatform.REACT_NATIVE
};
UploadAttachmentActionCreators.addFile({
file: c30398_7,
channelId: c30398_0,
draftType: DraftType.Poll
});
r176 = c30398_5;
c27046_6 = 0;
} catch ($e) {
let r8 = $e;
if (c27046_6 !== 0) {
while (true) {
try {
c27046_6 = 0;
} catch ($e) {
r8 = $e;
if (c27046_6 === 0) {
break;
}
continue;
}
return void 0;
}
}
throw r8;
}
return r176;
}
return void 0;
}
}
export function handlePollMediaAttachmentAdd() {}
export async function removePollUploadAttachment(c27047_0, c27047_1, c27047_2) {
let c27047_6 = 0;
L10: {
try {
c27047_6 = 1;
UploadAttachmentActionCreators.remove(c27047_0, c27047_1, DraftType.Poll);
await removeFile("cache", getFilePathForGif(c27047_2));
c27047_6 = 0;
} catch ($e) {
let r8 = $e;
if (c27047_6 !== 0) {
while (true) {
try {
c27047_6 = 0;
break L10;
} catch ($e) {
r8 = $e;
if (c27047_6 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
export async function removeAllPollUploadAttachments(c27048_0) {
let c27048_4 = 0;
L10: {
try {
c27048_4 = 1;
UploadAttachmentActionCreators.clearAll(c27048_0, DraftType.Poll);
await clearFolder("cache", POLL_ATTACHMENT_FOLDER);
c27048_4 = 0;
} catch ($e) {
let r8 = $e;
if (c27048_4 !== 0) {
while (true) {
try {
c27048_4 = 0;
break L10;
} catch ($e) {
r8 = $e;
if (c27048_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
+749
View File
@@ -0,0 +1,749 @@
// Metro module 9957 (f9958).
import LurkingStore from "../lurker_mode/LurkingStore";
import ReferencedMessageStore from "../replies/ReferencedMessageStore";
import AuthenticationStore from "../../stores/AuthenticationStore";
import ChannelStore from "../../stores/ChannelStore";
import { DraftType } from "../../stores/DraftStore";
import GuildVerificationStore from "../../stores/GuildVerificationStore";
import MessageStore from "../../stores/MessageStore";
import UploadAttachmentStore from "../../stores/UploadAttachmentStore";
import { updatePollState, getPollState } from "./PollsInteractionStore";
import { AnalyticEvents } from "../../Constants";
import Module38 from "../../_bundle/Module38";
import AlertActionCreators from "../../actions/AlertActionCreators";
import { intl, t } from "../../intl/index.native";
import { showVotesForAnswer } from "./PollInteractionUtils.native";
import { computeBasicPollChatData } from "./chat/formatPollMessageChatData";
import AppAnalyticsUtils from "../app_analytics/AppAnalyticsUtils";
import Module12 from "../../_bundle/Module12";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
import { ReactionTypes } from "../messages/MessageReactionsTypes";
import * as _PollsHttpApi from "./PollsHttpApi";
import { submitPollVote } from "./PollsHttpApi";
import { AccessibilityAnnouncer } from "../../design/shared";
import { PollLayoutTypes } from "../../_bundle/Module8002";
import MessageActionCreators from "../../actions/MessageActionCreators";
import { handleUploadMessageAttachmentsErrors } from "../media_uploads/handleUploadAttachmentErrors.native";
import { APIError } from "../../errors/index";
import { HermesBuiltin } from "../../_hermes/prelude";
function $mk83611($env) {
return () => {
const r5 = $env.$parent;
(0, r5[1])(r5[3][14]).joinGuild($env[0], {
source: r5[16].POLL_ALERT
});
};
}
function $mk115581($env) {
return () => {
let r22;
const r5 = $env;
let r0 = void 0;
let r2 = r5[7][Symbol.iterator]();
const next = r2.next;
while (true) {
const r25 = r2 === void 0 ? void 0 : (r22 = next.call(r2)).done ? r2 = void 0 : r22.value;
if (r2 === void 0) {
return r0;
}
try {
const id = r25.id;
r0 = Dispatcher.dispatch({
type: r25.type,
channelId: r5[0],
messageId: r5[1],
emoji: {
id,
name: id
},
userId: r5[6],
optimistic: true,
reactionType: ReactionTypes.VOTE
});
} catch (r39) {
if (r2 !== void 0 && typeof r2.return === "function") {
try {
r2.return();
} catch {}
}
throw r39;
}
}
};
}
function $mk115582($env) {
return (a0) => {
Module38(a0 != null, "Must not be able to vote without existing state!");
return {
...a0,
submitting: true,
editing: false
};
};
}
function $mk115585($env) {
return (a0) => {
const r2 = {
channelId: $env[0],
selectedAnswerIds: new Set(),
submitting: false,
editing: false,
showResults: null
};
let showResults = a0?.showResults;
if (showResults == null) {
showResults = false;
}
r2.showResults = showResults;
return r2;
};
}
function $mk115586($env) {
return function handleClearPollVote() {
return $env[26].apply(this, arguments);
};
}
function $mk115587($env) {
return function handleShowVotes(a0) {
let env31516 = {
$parent: $env
};
const channelId3 = a0.channelId;
env31516[0] = channelId3;
const messageId2 = a0.messageId;
env31516[1] = messageId2;
(0, updatePollState)(channelId3, messageId2, (a0) => {
const show_results = a0 == null || !a0.showResults;
const r16 = env31516.$parent;
const r9 = r16[11];
const channel_id = env31516[0];
const message_id = env31516[1];
const message2 = r9.getMessage(channel_id, message_id);
const votes_count = message2 != null ? message2.reactions.reduce((acc, reaction) => {
let r4 = reaction.count_details?.vote;
if (r4 == null) {
r4 = 0;
}
return acc + r4;
}, 0) : 0;
(0, r16[1])(r16[3][17]).trackWithMetadata(r16[15].POLL_SHOW_RESULTS_CLICKED, {
channel_id,
message_id,
show_results,
votes_count
});
const r31 = {
channelId: channel_id,
selectedAnswerIds: new Set(),
submitting: null,
editing: null,
showResults: null
};
let submitting = a0?.submitting;
if (submitting == null) {
submitting = false;
}
r31.submitting = submitting;
let editing = a0?.submitting;
if (editing == null) {
editing = false;
}
r31.editing = editing;
r31.showResults = show_results;
return r31;
});
};
}
function $mk115588($env) {
return (a0) => {
const r6 = $env;
const r8 = r6[7];
const r9 = r8 == null ? void 0 : r8.findIndex((item) => item.id === a0.localCreationAnswerId);
const poll_media = {
attachment_ids: r9 !== -1 ? [`${r9}`] : void 0
};
const r19 = r6[5];
if (r19 === PollLayoutTypes.DEFAULT) {
const text = a0.text;
poll_media.text = text == null ? void 0 : text.trim();
}
const emoji = a0.image?.emoji;
if (emoji != null) {
if (emoji.id != null) {
poll_media.emoji = {
id: emoji.id,
name: ""
};
} else if (emoji.optionallyDiverseSequence != null) {
poll_media.emoji = {
name: emoji.optionallyDiverseSequence
};
}
}
return {
poll_media
};
};
}
function $mk115589($env) {
return (a0, a1, a2) => {
handleUploadMessageAttachmentsErrors({
file: a0,
guildId: $env[0].getGuildId(),
analyticsLocations: [],
code: a1,
reason: a2
});
};
}
let showLurkingAlert, handleShowVotesForAnswer, handleUpdateVoteEditingState, getCurrentAnswerIds, optimisticallySetAnswers, handlePollSubmitVote;
let env6619 = {};
const getPollVoteEventProperties = function getPollVoteEventProperties(c17577_0, a1) {
const analyticsSelectedAnswerIds = [...a1];
let selectedTextAnswersCount = 0;
let selectedEmojiAnswersCount = 0;
const _loop = function _loop(c26574_0) {
const r9 = c17577_0 == null ? void 0 : c17577_0.find((item) => item.answer_id === parseInt(c26574_0))?.poll_media;
if (r9?.text != null) {
selectedTextAnswersCount = selectedTextAnswersCount + 1;
}
if (r9?.emoji != null) {
selectedEmojiAnswersCount = selectedEmojiAnswersCount + 1;
}
};
for (const item of analyticsSelectedAnswerIds) {
_loop(item);
}
return {
analyticsSelectedAnswerIds,
selectedTextAnswersCount,
selectedEmojiAnswersCount
};
};
showLurkingAlert = function showLurkingAlert(a0) {
let env17578;
const r4 = env17578 = {
$parent: env6619
};
env17578[0] = a0.guildId;
AlertActionCreators.show({
title: a0.title,
body: a0.body,
confirmText: intl.string(t["9VLmlZ"]),
cancelText: intl.string(t["2m+Sqk"]),
onConfirm: $mk83611(r4)
});
};
handleShowVotesForAnswer = function handleShowVotesForAnswer(a0) {
const { channelId: channelId3, messageId: messageId2 } = a0;
let answerId2 = a0.answerId;
const channel = ChannelStore.getChannel(channelId3);
if (channel != null) {
if (LurkingStore.isLurking(channel.guild_id)) {
let env17579;
const guild_id = channel.guild_id;
const title = intl.string(t["7LpysO"]);
const body = intl.string(t["5sHHoy"]);
const r59 = env17579 = {
$parent: env6619
};
env17579[0] = guild_id;
AlertActionCreators.show({
title,
body,
confirmText: intl.string(t["9VLmlZ"]),
cancelText: intl.string(t["2m+Sqk"]),
onConfirm: $mk83611(r59)
});
} else {
const message2 = MessageStore.getMessage(channelId3, messageId2);
if (message2 != null && message2.poll != null && message2.poll.answers.length !== 0) {
if (answerId2 == null) {
answerId2 = String(message2.poll.answers[0].answer_id);
}
showVotesForAnswer({
message: message2,
initialAnswerId: answerId2
});
}
}
}
};
handleUpdateVoteEditingState = function handleUpdateVoteEditingState({ channelId, messageId: messageId2, isEditing }) {
(0, updatePollState)(channelId, messageId2, (a0) => {
const r2 = {
channelId,
selectedAnswerIds: new Set(),
submitting: false,
editing: isEditing,
showResults: null
};
let showResults = a0?.showResults;
if (showResults == null) {
showResults = false;
}
r2.showResults = showResults;
return r2;
});
};
getCurrentAnswerIds = function getCurrentAnswerIds(a0) {
const message2 = MessageStore.getMessage(a0.channelId, a0.messageId);
return message2 == null ? [] : message2.reactions.flatMap((reaction) => reaction.me_vote === true ? reaction.emoji.name : []);
};
optimisticallySetAnswers = async function optimisticallySetAnswers(c26575_0) {
let c26575_1, c26575_2, c26575_3;
L13: {
let env30165;
const r31 = env6619;
c26575_3 = r31;
const r10 = env30165 = {
$parent: r31
};
c26575_2 = r10;
env30165[0] = void 0;
env30165[1] = void 0;
env30165[2] = void 0;
env30165[0] = c26575_0.channelId;
env30165[1] = c26575_0.messageId;
env30165[2] = c26575_0.answerIds;
env30165[3] = void 0;
env30165[4] = void 0;
env30165[5] = void 0;
env30165[6] = void 0;
env30165[7] = void 0;
env30165[8] = void 0;
await void 0;
const r48 = c26575_2;
env30165[3] = (0, getCurrentAnswerIds)({
channelId: env30165[0],
messageId: env30165[1]
});
env30165[4] = Module12.difference(env30165[3], env30165[2]);
env30165[5] = Module12.difference(env30165[2], env30165[3]);
env30165[6] = AuthenticationStore.getId();
c26575_1 = 0;
const r20 = env30165[4].map((item) => ({
type: "MESSAGE_REACTION_REMOVE",
id: item
}));
const r71 = [];
c26575_1 = HermesBuiltin.arraySpread(r71, r20, c26575_1);
c26575_1 = HermesBuiltin.arraySpread(r71, env30165[5].map((item) => ({
type: "MESSAGE_REACTION_ADD",
id: item
})), c26575_1);
env30165[7] = r71;
env30165[8] = Module589.Emitter.batched($mk115581(r48));
if (env30165[8] != null) {
await env30165[8];
break L13;
}
return void 0;
}
};
handlePollSubmitVote = async function handlePollSubmitVote(c26576_0) {
let anyErrorMessage, anyErrorMessage2, c26576_3, c26576_4, c26576_5, c26576_6;
let c26576_7 = 0;
const r15 = env6619;
L22: {
try {
let env30166;
c26576_5 = r15;
const r43 = env30166 = {
$parent: r15
};
c26576_4 = r43;
env30166[0] = void 0;
env30166[1] = void 0;
env30166[0] = c26576_0.channelId;
env30166[1] = c26576_0.messageId;
env30166[2] = void 0;
env30166[3] = void 0;
env30166[4] = void 0;
env30166[5] = void 0;
await void 0;
env30166[2] = ChannelStore.getChannel(env30166[0]);
if (env30166[2] != null) {
if (LurkingStore.isLurking(env30166[2].guild_id)) {
(0, showLurkingAlert)({
guildId: env30166[2].guild_id,
title: intl.string(t.Qic1FD),
body: intl.string(t["5sHHoy"])
});
} else if (GuildVerificationStore.canChatInGuild(env30166[2].guild_id)) {
env30166[3] = (0, getPollState)(env30166[0], env30166[1]);
Module38(env30166[3] != null, "Must not be able to vote without existing state!");
env30166[4] = (0, getCurrentAnswerIds)({
channelId: env30166[0],
messageId: env30166[1]
});
c26576_7 = 1;
c26576_3 = 0;
const r28 = env30166[3].selectedAnswerIds.values();
const r136 = [];
c26576_3 = HermesBuiltin.arraySpread(r136, r28, c26576_3);
env30166[5] = r136;
updatePollState(env30166[0], env30166[1], $mk115582(env6619));
await (0, optimisticallySetAnswers)({
channelId: env30166[0],
messageId: env30166[1],
answerIds: env30166[5]
});
await submitPollVote({
channelId: env30166[0],
messageId: env30166[1],
answerIds: env30166[5]
});
(0, updatePollState)(env30166[0], env30166[1], () => {});
AccessibilityAnnouncer.announce(env30166[5].length === 0 ? intl.string(t["xcvy+3"]) : intl.string(t.o20GSo));
c26576_7 = 0;
} else {
AlertActionCreators.show({
title: intl.string(t.p245wu),
body: intl.string(t["U/uodt"])
});
}
}
} catch ($e) {
const r41 = $e;
let r8 = r41;
c26576_6 = r41;
if (c26576_7 !== 0) {
while (true) {
try {
const r281 = c26576_6;
c26576_7 = 0;
env30166[6] = r281;
const r301 = {
title: intl.string(t.iufib1),
body: null
};
const r302 = env30166[6];
const getAnyErrorMessage = r302.getAnyErrorMessage;
const r305 = getAnyErrorMessage == null ? void 0 : getAnyErrorMessage.call(r302);
anyErrorMessage2 = r305;
if (r305 == null) {
anyErrorMessage2 = env30166[6].message;
}
anyErrorMessage = anyErrorMessage2;
if (anyErrorMessage == null) {
anyErrorMessage = intl.string(t.eAn6z2);
}
r301.body = anyErrorMessage;
AlertActionCreators.show(r301);
await (0, optimisticallySetAnswers)({
channelId: env30166[0],
messageId: env30166[1],
answerIds: env30166[4]
});
(0, updatePollState)(env30166[0], env30166[1], (a0) => {
if (a0 != null) {
return {
...a0,
submitting: false,
editing: false
};
}
});
break L22;
} catch (r277) {
r8 = r277;
c26576_6 = r277;
if (c26576_7 === 0) {
break;
}
}
}
}
throw r8;
}
}
};
env6619[26] = function _handleClearPollVote() {
const r8 = async (c26577_0) => {
let c26577_1, c26577_2;
L15: {
let env30167;
c26577_2 = env6619;
const r29 = env30167 = {};
c26577_1 = r29;
env30167[0] = void 0;
env30167[1] = void 0;
env30167[0] = c26577_0.channelId;
env30167[1] = c26577_0.messageId;
env30167[2] = void 0;
await void 0;
env30167[2] = ChannelStore.getChannel(env30167[0]);
if (env30167[2] == null) {
break L15;
}
const isLurking = LurkingStore.isLurking(env30167[2].guild_id);
const r60 = c26577_1;
if (isLurking) {
showLurkingAlert({
guildId: env30167[2].guild_id,
title: intl.string(t.B9QnBp),
body: intl.string(t.BVZCTn)
});
break L15;
}
(0, updatePollState)(env30167[0], env30167[1], $mk115585(r60));
return await (0, handlePollSubmitVote)({
channelId: env30167[0],
messageId: env30167[1]
});
}
};
env6619[26] = r8;
return r8.apply(this, arguments);
};
const r54 = {
handlePollAnswerTapped: function handlePollAnswerTapped({ answerId, ...rest }) {
let r33;
let allow_multiselect;
allow_multiselect = void 0;
const { channelId: channelId3, messageId: messageId2 } = rest;
const message2 = MessageStore.getMessage(channelId3, messageId2);
if (message2 != null) {
r33 = {
message: message2,
channelId: channelId3,
messageId: messageId2
};
} else {
const message3 = ReferencedMessageStore.getMessage(channelId3, messageId2);
if (message3.message == null) {
Module38(message2 != null, "Tapped on a non-existent poll message");
throw new Error();
}
r33 = {
channelId: channelId3,
messageId: messageId2,
message: message3.message
};
}
const { channelId: channelId2, messageId, message } = r33;
let r43 = computeBasicPollChatData(message);
if (r43 == null) {
r43 = {};
}
if (r43.tapShouldOpenVotersModal !== true) {
allow_multiselect = message.poll?.allow_multiselect;
(0, updatePollState)(channelId2, messageId, (a0) => {
if (a0 == null) {
const set2 = new Set([answerId]);
const answers = message.poll?.answers;
const selectedAnswerIds = set2;
const r82 = getPollVoteEventProperties(answers, selectedAnswerIds);
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.POLL_VOTE_SELECTED, {
channel_id: channelId2,
message_id: messageId,
selected_answer_ids: r82.analyticsSelectedAnswerIds,
selected_text_answers_count: r82.selectedTextAnswersCount,
selected_emoji_answers_count: r82.selectedEmojiAnswersCount
});
return {
channelId: channelId2,
selectedAnswerIds,
submitting: false,
editing: false,
showResults: false
};
}
const r0 = {
...a0
};
const set = new Set(r0.selectedAnswerIds);
r0.selectedAnswerIds = set;
if (set.has(answerId)) {
set.delete(answerId);
} else {
if (!allow_multiselect) {
for (const item of set) {
set.delete(item);
}
}
set.add(answerId);
}
const pollVoteEventProperties = getPollVoteEventProperties(message.poll?.answers, set);
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.POLL_VOTE_SELECTED, {
channel_id: channelId2,
message_id: messageId,
selected_answer_ids: pollVoteEventProperties.analyticsSelectedAnswerIds,
selected_text_answers_count: pollVoteEventProperties.selectedTextAnswersCount,
selected_emoji_answers_count: pollVoteEventProperties.selectedEmojiAnswersCount
});
return r0;
});
} else {
handleShowVotesForAnswer({
channelId: channelId2,
messageId,
answerId
});
}
},
handlePollSubmitVote,
handleUpdateVoteEditingState,
handlePollActionTapped: async function handlePollActionTapped(c26578_0) {
let c26578_1, c26578_2;
L24: {
L22: {
let env30168;
const r29 = env6619;
c26578_2 = r29;
const r10 = env30168 = {
$parent: r29
};
c26578_1 = r10;
env30168[0] = void 0;
env30168[1] = void 0;
env30168[2] = void 0;
env30168[0] = c26578_0.channelId;
env30168[1] = c26578_0.messageId;
env30168[2] = c26578_0.type;
await void 0;
const r48 = env30168[2];
if (r48 === "submit") {
await (0, handlePollSubmitVote)({
channelId: env30168[0],
messageId: env30168[1]
});
break L24;
}
if (r48 === "remove") {
const r60 = {
channelId: env30168[0],
messageId: env30168[1]
};
await $mk115586(env6619)(r60);
break L22;
}
if (r48 === "cancel") {
(0, handleUpdateVoteEditingState)({
channelId: env30168[0],
messageId: env30168[1],
isEditing: false
});
} else if (r48 === "showVotes") {
const r77 = {
channelId: env30168[0],
messageId: env30168[1]
};
$mk115587(env6619)(r77);
} else if (r48 === "showVoterDetails") {
(0, handleShowVotesForAnswer)({
channelId: env30168[0],
messageId: env30168[1]
});
} else {
Module38(false, `Unknown poll action type: ${env30168[2]}`);
}
return void 0;
}
return void 0;
}
},
createPoll: async function createPoll(c26579_0) {
let c26579_1, c26579_2, c26579_3;
let c26579_4 = 0;
const r14 = env6619;
try {
let env30169;
c26579_2 = r14;
const r36 = env30169 = {
$parent: r14
};
c26579_1 = r36;
env30169[0] = void 0;
env30169[1] = void 0;
env30169[2] = void 0;
env30169[3] = void 0;
env30169[4] = void 0;
env30169[5] = void 0;
env30169[6] = void 0;
env30169[0] = c26579_0.channel;
env30169[1] = c26579_0.question;
env30169[2] = c26579_0.answers;
env30169[3] = c26579_0.allowMultiSelect;
env30169[4] = c26579_0.duration;
env30169[5] = c26579_0.layout;
env30169[6] = c26579_0.onClose;
env30169[7] = void 0;
env30169[8] = void 0;
env30169[9] = void 0;
await void 0;
const r61 = c26579_1;
env30169[7] = UploadAttachmentStore.getUploads(env30169[0].id, DraftType.Poll);
env30169[8] = env30169[2].map($mk115588(r61));
env30169[9] = {
question: {
text: env30169[1].trim()
},
answers: env30169[8],
allow_multiselect: env30169[3],
duration: env30169[4],
layout_type: env30169[5]
};
const r21 = c26579_1;
c26579_4 = 1;
await MessageActionCreators.sendPollMessage(env30169[0].id, env30169[9], {
attachmentsToUpload: env30169[7],
onAttachmentUploadError: $mk115589(r21)
});
const r112 = env30169[6];
if (r112 != null) {
r112();
}
c26579_4 = 0;
} catch ($e) {
const r34 = $e;
let r8 = r34;
c26579_3 = r34;
if (c26579_4 !== 0) {
while (true) {
try {
const r122 = c26579_3;
c26579_4 = 0;
env30169[10] = r122;
throw (env30169[10] instanceof APIError ? env30169[10] : new APIError(env30169[10])).getAnyErrorMessage() === "poll" && env30169[10].text != null ? {
...env30169[10],
body: JSON.parse(env30169[10].text)
} : env30169[10];
} catch (r118) {
r8 = r118;
c26579_3 = r118;
if (c26579_4 === 0) {
break;
}
}
}
}
throw r8;
}
},
endPollEarly: async function endPollEarly(c26580_0) {
let c30170_0, c30170_1;
L15: {
c30170_0 = void 0;
c30170_1 = void 0;
c30170_0 = c26580_0.channelId;
c30170_1 = c26580_0.messageId;
await void 0;
if (await AlertActionCreators.confirm({
title: intl.string(t["+rfkTK"]),
body: intl.string(t.H2I1gL)
})) {
await _PollsHttpApi.endPollEarly({
channelId: c30170_0,
messageId: c30170_1
});
break L15;
}
return void 0;
}
}
};
export default r54;
export { handleShowVotesForAnswer };
+31
View File
@@ -0,0 +1,31 @@
// Metro module 6140 (f6141).
import { ExpressionPickerViewType } from "../expression_picker/ExpressionPickerConstants";
const r19 = {
ONE_HOUR: 1,
1: "ONE_HOUR",
FOUR_HOURS: 4,
4: "FOUR_HOURS",
EIGHT_HOURS: 8,
8: "EIGHT_HOURS",
ONE_DAY: 24,
24: "ONE_DAY",
THREE_DAYS: 72,
72: "THREE_DAYS",
SEVEN_DAYS: 168,
168: "SEVEN_DAYS",
FOURTEEN_DAYS: 336,
336: "FOURTEEN_DAYS"
};
const set = new Set([ExpressionPickerViewType.GIF, ExpressionPickerViewType.EMOJI]);
export const POLL_ATTACHMENT_FOLDER = "polls";
export const POLL_CREATION_MODAL_KEY = "POLL_CREATION_MODAL_KEY";
export const POLL_CREATION_IMAGE_INPUT_ACTION_SHEET_KEY = "PollsImageInputActionSheet";
export const POLL_CREATION_DURATION_ACTION_SHEET_KEY = "PollsDurationActionSheet";
export const MIN_NUMBER_OF_ANSWERS_PER_POLL = 1;
export const MAX_NUMBER_OF_ANSWERS_PER_POLL = 10;
export const MAX_POLL_QUESTION_LENGTH = 300;
export const MAX_POLL_ANSWER_LENGTH = 55;
export const VOTES_TOOLTIP_MAX_USERS = 3;
export const POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS = 50;
export { r19 as PollDurations };
export { set as POLLS_SUPPORTED_EXPRESSION_PICKER_VIEW_TYPES };
+87
View File
@@ -0,0 +1,87 @@
// Metro module 9963 (f9964).
import { Endpoints } from "../../Constants";
import { HTTP } from "../../_bundle/sendRequest";
import { APIError } from "../../errors/index";
export async function submitPollVote(c26582_0) {
let c26582_3;
let c26582_4 = 0;
let c30172_0, c30172_1, c30172_2, c30172_3;
try {
c30172_0 = void 0;
c30172_1 = void 0;
c30172_2 = void 0;
c30172_0 = c26582_0.channelId;
c30172_1 = c26582_0.messageId;
c30172_2 = c26582_0.answerIds;
await void 0;
c26582_4 = 1;
await HTTP.put({
url: Endpoints.POLL_ANSWERS(c30172_0, c30172_1),
body: {
answer_ids: c30172_2
},
rejectWithError: false
});
c26582_4 = 0;
} catch ($e) {
const r31 = $e;
let r8 = r31;
c26582_3 = r31;
if (c26582_4 !== 0) {
while (true) {
try {
const r86 = c26582_3;
c26582_4 = 0;
c30172_3 = r86;
throw new APIError(c30172_3);
} catch (r82) {
r8 = r82;
c26582_3 = r82;
if (c26582_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
export async function endPollEarly(c26583_0) {
let c26583_3;
let c26583_4 = 0;
let c30173_0, c30173_1, c30173_2;
try {
c30173_0 = void 0;
c30173_1 = void 0;
c30173_0 = c26583_0.channelId;
c30173_1 = c26583_0.messageId;
await void 0;
c26583_4 = 1;
await HTTP.post({
url: Endpoints.POLL_EXPIRE(c30173_0, c30173_1),
rejectWithError: false
});
c26583_4 = 0;
} catch ($e) {
const r30 = $e;
let r8 = r30;
c26583_3 = r30;
if (c26583_4 !== 0) {
while (true) {
try {
const r83 = c26583_3;
c26583_4 = 0;
c30173_2 = r83;
throw new APIError(c30173_2);
} catch (r79) {
r8 = r79;
c26583_3 = r79;
if (c26583_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
+116
View File
@@ -0,0 +1,116 @@
// Metro module 7998 (f7999).
import { createWithEqualityFn } from "../../_bundle/identity_700";
import { batchUpdates } from "../../_bundle/Module705";
import shallowEqual from "../../_bundle/shallowEqual";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
let c5061_3 = {};
const withEqualityFn = createWithEqualityFn((c16157_0) => ({
pollsByChannelId: {},
pollsByMessageId: {},
updatePollState: (c26072_0, c26072_1, c26072_2) => {
batchUpdates(() => {
c16157_0((a0) => {
const pollsByChannelId = a0.pollsByChannelId;
const r7 = pollsByChannelId[c26072_0];
const r14 = c26072_2(r7 == null ? void 0 : r7[c26072_1]);
const pollsByChannelId2 = {
...a0.pollsByChannelId
};
const r17 = {
...a0.pollsByChannelId[c26072_0]
};
r17[c26072_1] = r14;
pollsByChannelId2[c26072_0] = r17;
const pollsByMessageId = {
...a0.pollsByMessageId
};
pollsByMessageId[c26072_1] = r14;
return {
pollsByChannelId: pollsByChannelId2,
pollsByMessageId
};
});
});
}
}));
export function useMessagePollInteractions(c16158_0) {
return withEqualityFn((c26073_0) => {
const r4 = {};
let c26073_1 = r4;
c16158_0.forEach((item) => {
const r5 = c26073_0.pollsByMessageId[item];
if (r5 != null) {
c26073_1[item] = r5;
}
});
return r4;
}, shallowEqual);
}
export function useChannelPollInteractions(c16159_0) {
return withEqualityFn((a0) => {
let r5 = a0.pollsByChannelId[c16159_0];
if (r5 == null) {
r5 = c5061_3;
}
return r5;
}, shallowEqual);
}
export function clearChannelPollState(c16160_0) {
batchUpdates(() => {
withEqualityFn.setState(({ pollsByChannelId, pollsByMessageId }) => {
let r8 = pollsByChannelId[c16160_0];
if (r8 == null) {
r8 = c5061_3;
}
const r18 = SnowflakeUtils.keys(r8);
const pollsByMessageId2 = {
...pollsByMessageId
};
let c29871_0 = pollsByMessageId2;
r18.forEach((item) => {
delete c29871_0[item];
});
const pollsByChannelId2 = {
...pollsByChannelId
};
delete pollsByChannelId2[c16160_0];
return {
pollsByChannelId: pollsByChannelId2,
pollsByMessageId: pollsByMessageId2
};
});
});
}
export function clearPollState(c16161_0, c16161_1) {
batchUpdates(() => {
withEqualityFn.setState(({ pollsByChannelId, pollsByMessageId }) => {
let r9 = pollsByChannelId[c16161_0];
if (r9 == null) {
r9 = {};
}
const r4 = {
...r9
};
delete r4[c16161_1];
const pollsByMessageId2 = {
...pollsByMessageId
};
delete pollsByMessageId2[c16161_1];
const pollsByChannelId2 = {
...pollsByChannelId
};
pollsByChannelId2[c16161_0] = r4;
return {
pollsByChannelId: pollsByChannelId2,
pollsByMessageId: pollsByMessageId2
};
});
});
}
export function updatePollState(a0, a1, a2) {
withEqualityFn.getState().updatePollState(a0, a1, a2);
}
export function getPollState(a0, a1) {
const r3 = withEqualityFn.getState().pollsByChannelId[a0];
return r3 == null ? void 0 : r3[a1];
}
+235
View File
@@ -0,0 +1,235 @@
// Metro module 6072 (f6073).
import ChannelStore from "../../stores/ChannelStore";
import MessageReactionsStore from "../../stores/MessageReactionsStore";
import MessageStore from "../../stores/MessageStore";
import PermissionStore from "../../stores/PermissionStore";
import RelationshipStore from "../../stores/RelationshipStore";
import { POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS, VOTES_TOOLTIP_MAX_USERS } from "./PollsConstants";
import { ChannelTypesSets, Permissions } from "../../Constants";
import { v4 } from "../../_bundle/Module514";
import { useStateFromStores } from "../../_bundle/Module589";
import { FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID } from "../channel/FakePlaceholderPrivateChannel";
import Durations from "../../utils/Durations";
import { truncateText } from "../../_bundle/Module1857";
import { getMessageAuthor } from "../messages/useMessageAuthor";
import { intl, t } from "../../intl/index.native";
import { ReactionTypes } from "../messages/MessageReactionsTypes";
import Module12 from "../../_bundle/Module12";
import NicknameUtils from "../../utils/NicknameUtils";
function $mk77708() {
return (a0) => a0.rawName === "poll_question_text";
}
let formatVoterTooltipText;
const getSampleOfVoterUsernamesForAnswer = function getSampleOfVoterUsernamesForAnswer(message, a1) {
const channelId = message.getChannelId();
const reactions = MessageReactionsStore.getReactions(channelId, message.id, {
id: a1,
name: "",
animated: false
}, VOTES_TOOLTIP_MAX_USERS, ReactionTypes.VOTE);
const channel = ChannelStore.getChannel(channelId);
const guildId = channel == null ? null : channel.isPrivate() ? null : channel.getGuildId();
const r37 = Array;
let r40 = reactions == null ? void 0 : reactions.values();
if (r40 == null) {
r40 = [];
}
return Module12(r37.from(r40)).reject((a0) => RelationshipStore.isBlockedOrIgnored(a0.id)).take(VOTES_TOOLTIP_MAX_USERS).map((item) => NicknameUtils.getName(guildId, channel?.id, item)).value();
};
formatVoterTooltipText = function formatVoterTooltipText(sampleOfVoterUsernamesForAnswer, a1) {
const r9 = Math.max(0, a1 - sampleOfVoterUsernamesForAnswer.length);
return sampleOfVoterUsernamesForAnswer.length === 1 ? r9 > 0 ? intl.formatToPlainString(t["SV/iZn"], {
a: sampleOfVoterUsernamesForAnswer[0],
n: r9
}) : sampleOfVoterUsernamesForAnswer[0] : sampleOfVoterUsernamesForAnswer.length === 2 ? r9 > 0 ? intl.formatToPlainString(t.YBnZK0, {
a: sampleOfVoterUsernamesForAnswer[0],
b: sampleOfVoterUsernamesForAnswer[1],
n: r9
}) : intl.formatToPlainString(t["O5+f5c"], {
a: sampleOfVoterUsernamesForAnswer[0],
b: sampleOfVoterUsernamesForAnswer[1]
}) : sampleOfVoterUsernamesForAnswer.length === 3 ? r9 > 0 ? intl.formatToPlainString(t["ThXp+N"], {
a: sampleOfVoterUsernamesForAnswer[0],
b: sampleOfVoterUsernamesForAnswer[1],
c: sampleOfVoterUsernamesForAnswer[2],
n: r9
}) : intl.formatToPlainString(t["0UzBM3"], {
a: sampleOfVoterUsernamesForAnswer[0],
b: sampleOfVoterUsernamesForAnswer[1],
c: sampleOfVoterUsernamesForAnswer[2]
}) : intl.formatToPlainString(t.yVX6kE, {
n: r9
});
};
export function generateEmptyPollAnswer() {
return {
text: void 0,
image: void 0,
localCreationAnswerId: v4()
};
}
export function generateLocalCreationAnswerId() {
return v4();
}
export function filterOutUUID(a0) {
return a0.replace(/\b[a-f\d]{8}-(?:[a-f\d]{4}-){3}[a-f\d]{12}-\b/i, "");
}
export function hasNonVoteReactions(a0) {
for (const reaction of a0.reactions) {
if (reaction.me_vote != null) {
continue;
}
return true;
}
return false;
}
export function useCanPostPollsInChannel(c15459_0) {
return useStateFromStores([PermissionStore], () => c15459_0 != null && c15459_0.id !== FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID && (!!ChannelTypesSets.POLLS.has(c15459_0.type) && (!!c15459_0.isPrivate() || PermissionStore.can(Permissions.SEND_MESSAGES, c15459_0) && PermissionStore.can(Permissions.SEND_POLLS, c15459_0))));
}
export function isPollCreationEmpty(a0, a1) {
return a0.length === 0 && a1.find(({ text }) => {
const r6 = text == null ? void 0 : text.trim();
return r6 != null && r6.length > 0;
}) == null;
}
export function isAnswerFilled({ text }) {
const r6 = text == null ? void 0 : text.trim();
return r6 != null && r6.length > 0;
}
export function isIncompleteAnswer(a0) {
const text = a0.text;
const r4 = text == null ? void 0 : text.trim();
return a0.image != null && (r4 == null || r4.length === 0);
}
export function createPollExpiryTimestamp(a0) {
return new Date(Date.now() + a0 * Durations.Millis.HOUR).toISOString();
}
export function createPollServerDataFromCreateRequest(a0) {
if (a0 != null) {
const r2 = a0 == null;
let answers2 = void 0;
if (!r2) {
const answers = a0.answers;
answers2 = answers == null ? void 0 : answers.map((answer, index) => {
const emoji = answer.poll_media?.emoji;
const r12 = emoji != null;
let emoji2 = void 0;
if (r12) {
let name = emoji.name;
if (name == null) {
name = "";
}
emoji2 = {
id: emoji.id,
name
};
}
return {
...answer,
answer_id: index + 1,
poll_media: {
...answer.poll_media,
emoji: emoji2
}
};
});
}
const r18 = a0?.duration != null;
let expiry = "0";
if (r18) {
const duration = a0.duration;
expiry = new Date(Date.now() + duration * Durations.Millis.HOUR).toISOString();
}
return {
...a0,
expiry,
answers: answers2
};
}
}
export function getPollReplyPreview({ poll }) {
let r5 = poll == null ? void 0 : poll.question?.text;
if (r5 == null) {
r5 = "";
}
return r5;
}
export function getPollResultsReplyPreview(a0) {
const messageAuthor = getMessageAuthor(a0);
const r14 = a0.embeds[0];
const r2 = r14 == null;
let r9 = void 0;
if (!r2) {
const fields = r14.fields;
r9 = fields == null ? void 0 : fields.find($mk77708())?.rawValue;
}
if (r9 == null) {
r9 = "";
}
return intl.format(t.Vn97Ka, {
username: messageAuthor.nick,
title: POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS != null ? truncateText(r9, POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS) : r9
});
}
export function getPollResultsReplyPreviewMobile(a0) {
if ("author" in a0) {
const messageAuthor = getMessageAuthor(a0);
const r17 = a0.embeds[0];
const r2 = r17 == null;
let r9 = void 0;
if (!r2) {
const fields = r17.fields;
r9 = fields == null ? void 0 : fields.find($mk77708())?.rawValue;
}
if (r9 == null) {
r9 = "";
}
return intl.formatToParts(t.Vn97Ka, {
username: messageAuthor.nick,
title: POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS != null ? truncateText(r9, POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS) : r9
});
}
return null;
}
export function getTotalVotes(a0) {
return a0.reduce((acc, item) => {
let r4 = item.count_details?.vote;
if (r4 == null) {
r4 = 0;
}
return acc + r4;
}, 0);
}
export { getSampleOfVoterUsernamesForAnswer };
export { formatVoterTooltipText };
export function getPollAnswerVotesTooltipText(a0, a1, a2) {
const message = MessageStore.getMessage(a1, a0);
if (message == null) {
return "";
}
const reaction = message.getReaction({
id: a2,
name: "",
animated: false
});
let r14 = reaction == null ? void 0 : reaction.count_details?.vote;
if (r14 == null) {
r14 = 0;
}
const sampleOfVoterUsernamesForAnswer = getSampleOfVoterUsernamesForAnswer(message, a2);
return sampleOfVoterUsernamesForAnswer.length !== 0 ? formatVoterTooltipText(sampleOfVoterUsernamesForAnswer, r14) : "";
}
export function formatPollResultNotificationCenterText(a0) {
const { questionText, victorAnswerText, victorAnswerVotes, victorAnswerId, totalVotes } = a0;
const r13 = a0.totalVotes > 0 ? Math.round(victorAnswerVotes / totalVotes * 100) : 0;
return totalVotes === 0 ? intl.formatToPlainString(t["8anM0l"], {
questionText
}) : victorAnswerId != null ? intl.formatToPlainString(t["8yEgvE"], {
questionText,
victorAnswerText,
percentage: `${r13}%`
}) : intl.formatToPlainString(t.XVk6Zv, {
questionText,
percentage: `${r13}%`
});
}
@@ -0,0 +1,30 @@
// Metro module 8003 (f8004).
const r13 = {
NONE: 0,
0: "NONE",
LOW: 1,
1: "LOW",
HIGH: 2,
2: "HIGH"
};
const r17 = {
NONE: 0,
0: "NONE",
HOLLOW: 1,
1: "HOLLOW",
FILLED: 2,
2: "FILLED",
CHECKMARK: 3,
3: "CHECKMARK"
};
const r22 = {
LIST: 1,
1: "LIST",
CHECKBOXES: 2,
2: "CHECKBOXES",
RADIO_BUTTONS: 3,
3: "RADIO_BUTTONS"
};
export { r13 as NativeShadowType };
export { r17 as PollRadioStyle };
export { r22 as PollChatAnswerInteractionType };
@@ -0,0 +1,29 @@
// Metro module 8000 (f8001).
import Module12 from "../../../_bundle/Module12";
import { pollStyleSets } from "./native/PollStyles";
import { createNativeStyleProperties } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { getAssetUriForEmbed } from "../../messages/native/renderer/EmbedUtils";
import Module5237 from "../../../_bundle/Module5237";
import Module5557 from "../../../_bundle/Module5557";
import { ensureAvatarSource } from "../../../utils/native/AvatarUtils";
let c5063_3 = Module12.mapValues(pollStyleSets, (c16162_0) => {
const nativeStyleProperties = createNativeStyleProperties((a0) => Module12.pickBy(c16162_0(Module712, a0), (a0) => typeof a0 !== "number" ? typeof a0 !== "boolean" : typeof a0 !== "number"));
return (a0, a1) => {
const r16 = Module12.pickBy(c16162_0(Module712, a1), (a0) => typeof a0 !== "number" ? typeof a0 === "boolean" : typeof a0 === "number");
return {
...nativeStyleProperties(a0, a1),
...r16
};
};
});
export function buildPlatformPollResources(c16163_0, c16163_1) {
return {
styles: Module12.mapValues(c5063_3, (a0) => a0(c16163_0, c16163_1)),
selectedIcon: getAssetUriForEmbed(Module5237),
checkmarkIcon: getAssetUriForEmbed(Module5557)
};
}
export function getAvatarUrl(a0, a1) {
return ensureAvatarSource(a0.getAvatarSource(a1, false)).uri;
}
@@ -0,0 +1,7 @@
// Metro module 8004 (f8005).
import { buildPlatformPollResources } from "./buildPlatformPollResources.native";
import { memoize } from "../../../_bundle/Module12";
const r16 = memoize(function buildPollResources(a0) {
return buildPlatformPollResources(a0.theme, a0.layoutType);
}, (a0) => `${a0.theme}:${a0.layoutType}`);
export default r16;
@@ -0,0 +1,434 @@
// Metro module 7997 (f7998).
import AccessibilityStore from "../../a11y/AccessibilityStore";
import EmojiStore from "../../emojis/EmojiStore";
import ChannelStore from "../../../stores/ChannelStore";
import GuildMemberStore from "../../../stores/GuildMemberStore";
import MessageStore from "../../../stores/MessageStore";
import UserStore from "../../../stores/UserStore";
import { getPollState } from "../PollsInteractionStore";
import { MessageStates, EMPTY_STRING_SNOWFLAKE_ID } from "../../../Constants";
import { match } from "../../../_bundle/Module4389";
import UnicodeEmojis from "../../emojis/UnicodeEmojis";
import EmojiUtils from "../../../utils/EmojiUtils";
import AvatarUtils from "../../../utils/AvatarUtils";
import { formatExpirationLabel } from "./useFormattedExpirationLabel";
import * as _AutomodPermissionUtils from "../../guild_automod/AutomodPermissionUtils";
import * as _CommunicationDisabledUtils from "../../guild_communication_disabled/CommunicationDisabledUtils";
import { getAvatarUrl } from "./buildPlatformPollResources.native";
import { intl, t } from "../../../intl/index.native";
import { getTotalVotes } from "../PollsUtils";
import { PollLayoutTypes } from "../../../_bundle/Module8002";
import { isIOS } from "../../../utils/PlatformUtils";
import { PollChatAnswerInteractionType } from "./PollMessageChatDataTypes";
import buildPollResources from "./buildPollResources";
let c5060_11, computeBasicPollChatData;
const reactionForId = function reactionForId(reactions, a1) {
for (const item of reactions) {
if ((typeof item.emoji.id === "number" ? `${item.emoji.id}` : item.emoji.id) !== a1) {
continue;
}
return item;
}
};
computeBasicPollChatData = function computeBasicPollChatData(a0, a1, r7 = {}) {
let formattedExpirationLabel = r7.formattedExpirationLabel;
const poll = a0.poll;
if (poll != null) {
const isSent = a0.state === MessageStates.SENT;
let expirationLabel = "";
if (isSent) {
if (formattedExpirationLabel == null) {
formattedExpirationLabel = formatExpirationLabel(poll.expiry);
}
expirationLabel = formattedExpirationLabel;
}
const isExpired2 = expirationLabel == null && isSent;
let r31 = a1 == null ? getPollState(a0.getChannelId(), a0.id) : a1;
if (r31 == null) {
r31 = c5060_11;
}
const { selectedAnswerIds: selectedAnswerIds2, submitting: submitting2, editing, showResults: showResults2 } = r31;
const reactions2 = a0.reactions;
const r2 = a0.poll == null || MessageStore.getMessage(a0.channel_id, a0.id) === a0;
let isInteractive = true;
let r42 = reactions2;
if (!r2) {
const message = MessageStore.getMessage(a0.channel_id, a0.id);
const isSearchHit = a0.isSearchHit;
const r48 = isSearchHit ? !isSearchHit : message != null;
let r49 = message?.reactions;
if (r49 == null) {
r49 = reactions2;
}
r42 = r49;
isInteractive = r48;
}
const hasSelectedAnswer2 = selectedAnswerIds2.size > 0;
const hasVoteRecorded = r42.some((item) => item.me_vote === true);
let hasVoted2 = !editing;
const reactions3 = r42;
if (!editing) {
hasVoted2 = hasVoteRecorded;
}
const canShowVoteCounts = (hasVoted2 ? hasVoted2 : isExpired2) || showResults2;
const canTapAnswers = (isSent ? isInteractive : isSent) && ((hasVoteRecorded ? editing : !hasVoteRecorded) || canShowVoteCounts);
const channel = ChannelStore.getChannel(a0.getChannelId());
const r63 = channel == null;
let r64 = void 0;
if (!r63) {
const getGuildId = channel.getGuildId;
r64 = getGuildId == null ? void 0 : getGuildId.call(channel);
}
const r68 = r64 != null ? GuildMemberStore.getSelfMember(r64) : null;
const hasAutomodQuarantinedProfile = _AutomodPermissionUtils.hasAutomodQuarantinedProfile(r68);
const isMemberCommunicationDisabled = _CommunicationDisabledUtils.isMemberCommunicationDisabled(r68);
return {
poll,
canTapAnswers,
canRemoveVote: hasVoted2 && isSent && !isExpired2,
canShowVoteCounts,
canSubmitVote: (submitting2 ? !submitting2 : hasSelectedAnswer2) && !hasVoted2 && isSent && !hasAutomodQuarantinedProfile && !isMemberCommunicationDisabled,
expirationLabel,
hasSelectedAnswer: hasSelectedAnswer2,
hasVoted: hasVoted2,
hasVoteRecorded,
isEditingVote: editing,
isExpired: isExpired2,
isInteractive,
isSent,
reactions: reactions3,
selectedAnswerIds: selectedAnswerIds2,
submitting: submitting2,
tapShouldOpenVotersModal: canShowVoteCounts,
showResults: showResults2
};
}
};
c5060_11 = {
channelId: EMPTY_STRING_SNOWFLAKE_ID,
selectedAnswerIds: new Set(),
submitting: false,
editing: false,
showResults: false
};
export default function formatPollMessageChatData(a0, a1, r4 = {}) {
let animateEmoji2 = r4.animateEmoji;
if (animateEmoji2 === void 0) {
animateEmoji2 = false;
}
let useReducedMotion, layout_type, canSubmitVote, secondaryLabel, hasSelectedAnswer, hasVoted, isExpired, reactions, selectedAnswerIds, submitting, showResults, totalVotes, label, c16156_14, accessibilityHint;
const animateEmoji = animateEmoji2;
const { theme = "dark", formattedExpirationLabel } = r4;
useReducedMotion = void 0;
layout_type = void 0;
canSubmitVote = void 0;
secondaryLabel = void 0;
hasSelectedAnswer = void 0;
hasVoted = void 0;
isExpired = void 0;
reactions = void 0;
selectedAnswerIds = void 0;
submitting = void 0;
showResults = void 0;
totalVotes = void 0;
label = void 0;
c16156_14 = void 0;
accessibilityHint = void 0;
const poll = a0.poll;
if (poll != null) {
const currentUser = UserStore.getCurrentUser();
if (currentUser != null) {
useReducedMotion = AccessibilityStore.useReducedMotion;
const channel = ChannelStore.getChannel(a0.getChannelId());
const r3 = channel == null;
let r40 = void 0;
if (!r3) {
const getGuildId = channel.getGuildId;
r40 = getGuildId == null ? void 0 : getGuildId.call(channel);
}
const avatarUrl = getAvatarUrl(currentUser, r40);
const answers = poll.answers;
layout_type = poll.layout_type;
const r49 = computeBasicPollChatData(a0, a1, {
formattedExpirationLabel
});
if (r49 != null) {
const { canTapAnswers, canRemoveVote, canShowVoteCounts } = r49;
canSubmitVote = r49.canSubmitVote;
let expirationLabel = r49.expirationLabel;
if (expirationLabel === void 0) {
expirationLabel = intl.string(t["e+J3JZ"]);
}
secondaryLabel = expirationLabel;
hasSelectedAnswer = r49.hasSelectedAnswer;
hasVoted = r49.hasVoted;
const isEditingVote = r49.isEditingVote;
isExpired = r49.isExpired;
const isInteractive = r49.isInteractive;
reactions = r49.reactions;
selectedAnswerIds = r49.selectedAnswerIds;
submitting = r49.submitting;
const tapShouldOpenVotersModal = r49.tapShouldOpenVotersModal;
showResults = r49.showResults;
totalVotes = getTotalVotes(reactions);
label = intl.formatToPlainString(t.XRkuof, {
count: totalVotes
});
const r78 = Math;
c16156_14 = r78.max.apply(r78, [...answers.map((answer) => {
const r15 = reactionForId(reactions, `${answer.answer_id}`);
let r16 = r15 == null ? void 0 : r15.count_details?.vote;
if (r16 == null) {
r16 = 0;
}
return r16;
})]);
const answers2 = answers.map((answer) => {
const answerId = `${answer.answer_id}`;
const r9 = reactionForId(reactions, answerId);
let r32 = r9 == null ? void 0 : r9.count_details?.vote;
if (r32 == null) {
r32 = 0;
}
const count = r32;
const r13 = totalVotes !== 0 ? count / totalVotes : 0;
const isSelected = selectedAnswerIds.has(answerId);
const isLeader = count >= c16156_14 && count !== 0;
let didSelfVote = hasVoted;
if (hasVoted) {
let r40 = r9?.me_vote;
if (r40 == null) {
r40 = false;
}
didSelfVote = r40;
}
let isVictor = isExpired;
const style = match({
didSelfVote,
hasVoted,
isExpired,
isSelected,
isLeader,
showResults
}).with({
isExpired: true,
isLeader: true,
didSelfVote: true
}, () => "victorSelected").with({
isExpired: true,
isLeader: true,
didSelfVote: false
}, () => "victorNotSelected").with({
isExpired: true,
didSelfVote: true
}, () => "loserSelected").with({
isExpired: true
}, () => "notVoted").with({
didSelfVote: true,
isExpired: false
}, () => "voted").with({
hasVoted: true,
isExpired: false
}, () => "notVoted").with({
isSelected: true
}, () => "selected").with({
isExpired: false,
showResults: true
}, () => "notVoted").otherwise(() => "normalVote");
const emoji = answer.poll_media.emoji;
const r88 = {
animateEmoji
};
let animateEmoji2 = r88.animateEmoji;
if (animateEmoji2 === void 0) {
animateEmoji2 = false;
}
let size = r88.size;
if (size === void 0) {
size = 48;
}
const r89 = emoji != null;
let emoji2 = void 0;
if (r89) {
let animated = emoji.animated;
if (animated == null && emoji.id != null) {
let r96 = EmojiStore.getCustomEmojiById(emoji.id)?.animated;
if (r96 == null) {
r96 = false;
}
animated = r96;
}
if (animateEmoji2) {
if (animated == null) {
animated = false;
}
animateEmoji2 = animated;
}
emoji2 = {
id: emoji.id == null ? null : `${emoji.id}`,
name: emoji.name,
displayName: emoji.id == null ? UnicodeEmojis.convertSurrogateToName(emoji.name) : emoji.name,
src: emoji.id == null ? EmojiUtils.getURL(emoji.name) : AvatarUtils.getEmojiURL({
id: emoji.id,
animated: animateEmoji2,
size
}),
animated: animateEmoji2
};
}
const pollMedia = {
text: answer.poll_media.text,
emoji: emoji2,
stickerId: answer.poll_media.sticker_id,
attachmentIds: answer.poll_media.attachment_ids
};
if (isExpired) {
isVictor = isLeader;
}
let shouldAnimateTransition = submitting;
if (submitting) {
shouldAnimateTransition = !useReducedMotion;
}
return {
answerId,
pollMedia,
isSelected,
isVictor,
didSelfVote,
style,
shouldAnimateTransition,
votesPercentage: Math.round(100 * r13),
votes: match(layout_type).with(PollLayoutTypes.IMAGE_ONLY_ANSWERS, () => `(${count.toLocaleString()})`).otherwise(() => intl.formatToPlainString(t.XRkuof, {
count
}))
};
});
const primaryAction = match({
isExpired,
canSubmitVote,
hasVoted,
isEditingVote,
canRemoveVote,
isInteractive,
showResults
}).with({
isInteractive: false
}, () => {}).with({
isExpired: true
}, () => {}).with({
isEditingVote: true
}, () => ({
label: intl.string(t.JwkNU4),
presentation: "button",
enabled: hasSelectedAnswer,
type: "submit"
})).with({
canRemoveVote: true
}, () => ({
label: intl.string(t.XhQEh8),
presentation: "secondaryButton",
enabled: true,
type: "remove"
})).with({
hasVoted: false,
showResults: true
}, () => ({
label: intl.string(t.gNj6In),
presentation: "secondaryButton",
enabled: true,
type: "showVotes"
})).otherwise(() => ({
label: intl.string(t.JwkNU4),
presentation: "button",
enabled: canSubmitVote,
type: "submit"
}));
accessibilityHint = isIOS() ? intl.string(t["PVATM/"]) : intl.string(t.cHfFql);
const secondaryAction = match({
isExpired,
isInteractive,
isEditingVote
}).with({
isInteractive: false,
isExpired: false
}, () => ({
label: intl.string(t.trrip0),
presentation: "text",
enabled: false
})).with({
isEditingVote: true
}, () => ({
label: intl.string(t["ETE/oC"]),
presentation: "textButton",
enabled: true,
type: "cancel"
})).otherwise(() => ({
label,
secondaryLabel,
accessibilityHint,
presentation: "text",
enabled: true,
type: "showVoterDetails"
}));
const tertiaryAction = isInteractive ? isExpired ? void 0 : hasVoted ? void 0 : showResults ? void 0 : {
label: intl.string(t["/KHAUF"]),
presentation: "textButton",
enabled: true,
type: "showVotes"
} : void 0;
const allow_multiselect = poll.allow_multiselect;
return {
question: poll.question,
promptLabel: match({
isInteractive,
isExpired,
canSelectMultipleAnswers: allow_multiselect
}).with({
isInteractive: false
}, () => {}).with({
isExpired: true
}, () => {}).with({
canSelectMultipleAnswers: true
}, () => intl.string(t.yCXvxa)).otherwise(() => intl.string(t["9Y2wKO"])),
answers: answers2,
answersInteraction: match({
tapShouldOpenVotersModal,
canTapAnswers,
canSelectMultipleAnswers: allow_multiselect
}).with({
tapShouldOpenVotersModal: true
}, () => PollChatAnswerInteractionType.LIST).with({
canTapAnswers: false
}, () => PollChatAnswerInteractionType.LIST).with({
canSelectMultipleAnswers: false
}, () => PollChatAnswerInteractionType.RADIO_BUTTONS).with({
canSelectMultipleAnswers: true
}, () => PollChatAnswerInteractionType.CHECKBOXES).exhaustive(),
answerTapAccessibilityLabel: tapShouldOpenVotersModal ? accessibilityHint : void 0,
layoutType: layout_type,
resources: buildPollResources({
theme,
layoutType: layout_type
}),
containerStyle: "normal",
primaryAction,
isInteractive,
canTapAnswers,
canSelectMultipleAnswers: allow_multiselect,
hasSelectedAnswer,
canShowVoteCounts,
hasVoted,
isExpired,
myAvatarUrl: avatarUrl,
secondaryAction,
tertiaryAction
};
}
}
}
};
export { reactionForId };
export function isPollMessageDirectlyInteractive(a0) {
return a0.poll == null || MessageStore.getMessage(a0.channel_id, a0.id) === a0;
}
export { computeBasicPollChatData };
+107
View File
@@ -0,0 +1,107 @@
// Metro module 8001 (f8002).
import { match } from "../../../../_bundle/Module4389";
import { PollLayoutTypes } from "../../../../_bundle/Module8002";
import { PollRadioStyle } from "../PollMessageChatDataTypes";
import { HermesBuiltin } from "../../../../_hermes/prelude";
function $mk79657($env) {
return () => $env[0].colors.WHITE;
}
function $mk79658($env) {
return () => $env[0].colors.TEXT_DEFAULT;
}
let normalVote, notVoted, victorNotSelected;
const normal = (a0, a1) => {
let env16164;
const r5 = env16164 = {};
env16164[0] = a0;
return {
border: a0.colors.BORDER_SUBTLE,
borderWidth: 1,
fill: a0.colors.CARD_SECONDARY_BG,
label: match(a1).with(PollLayoutTypes.IMAGE_ONLY_ANSWERS, $mk79657(r5)).otherwise($mk79658(r5)),
opacity: 1,
answerBackground: a0.colors.BACKGROUND_MOD_MUTED,
answerFill: a0.colors.BACKGROUND_MOD_SUBTLE,
radioStyle: PollRadioStyle.HOLLOW,
radioBackground: a0.colors.INTERACTIVE_TEXT_ACTIVE,
radioForeground: a0.colors.WHITE
};
};
normalVote = (a0, a1) => {
let env16165;
const r15 = {};
const r7 = env16165 = {};
env16165[0] = a0;
HermesBuiltin.copyDataProperties(r15, {
border: a0.colors.BORDER_SUBTLE,
borderWidth: 1,
fill: a0.colors.CARD_SECONDARY_BG,
label: match(a1).with(PollLayoutTypes.IMAGE_ONLY_ANSWERS, $mk79657(r7)).otherwise($mk79658(r7)),
opacity: 1,
answerBackground: a0.colors.BACKGROUND_MOD_MUTED,
answerFill: a0.colors.BACKGROUND_MOD_SUBTLE,
radioStyle: PollRadioStyle.HOLLOW,
radioBackground: a0.colors.INTERACTIVE_TEXT_ACTIVE,
radioForeground: a0.colors.WHITE
});
r15.borderWidth = 0;
return r15;
};
notVoted = (a0, a1) => ({
...normalVote(a0, a1),
answerFill: a0.colors.INTERACTIVE_BACKGROUND_ACTIVE,
radioStyle: PollRadioStyle.NONE
});
victorNotSelected = (a0, a1) => ({
...normalVote(a0, a1),
border: a0.colors.STATUS_POSITIVE,
borderWidth: 1,
answerFill: a0.colors.POLLS_VICTOR_FILL,
radioStyle: PollRadioStyle.NONE
});
const r19 = {
loserSelected: (a0, a1) => ({
...{
...normalVote(a0, a1),
answerFill: a0.colors.INTERACTIVE_BACKGROUND_ACTIVE,
radioStyle: PollRadioStyle.NONE
},
radioStyle: PollRadioStyle.CHECKMARK,
radioBackground: a0.colors.INTERACTIVE_TEXT_ACTIVE,
radioForeground: a0.colors.BACKGROUND_BASE_LOW
}),
normal,
notVoted,
selected: (a0, a1) => ({
...normalVote(a0, a1),
border: a0.colors.BACKGROUND_BRAND,
borderWidth: 1,
radioStyle: PollRadioStyle.FILLED,
radioBackground: a0.colors.REDESIGN_INPUT_CONTROL_SELECTED,
radioForeground: a0.colors.STATUS_POSITIVE_TEXT
}),
victorNotSelected,
victorSelected: (a0, a1) => ({
...{
...normalVote(a0, a1),
border: a0.colors.STATUS_POSITIVE,
borderWidth: 1,
answerFill: a0.colors.POLLS_VICTOR_FILL,
radioStyle: PollRadioStyle.NONE
},
radioStyle: PollRadioStyle.CHECKMARK,
radioBackground: a0.colors.STATUS_POSITIVE,
radioForeground: a0.colors.STATUS_POSITIVE_TEXT
}),
voted: (a0, a1) => ({
...normalVote(a0, a1),
border: a0.colors.BACKGROUND_BRAND,
borderWidth: 1,
answerFill: a0.colors.POLLS_VOTED_FILL,
radioStyle: PollRadioStyle.CHECKMARK,
radioBackground: a0.colors.REDESIGN_INPUT_CONTROL_SELECTED,
radioForeground: a0.colors.STATUS_POSITIVE_TEXT
}),
normalVote
};
export { r19 as pollStyleSets };
@@ -0,0 +1,30 @@
// Metro module 7999 (f8000).
import Module3771 from "../../../_bundle/Module3771";
import { intl, t } from "../../../intl/index.native";
const formatExpirationLabel = function formatExpirationLabel(expiry) {
const r7 = Module3771();
if (expiry <= r7) {
return void 0;
}
const days = expiry.diff(r7, "days");
if (days > 1) {
return intl.formatToPlainString(t.dex68a, {
days
});
}
const hours = expiry.diff(r7, "hours");
if (hours > 1) {
return intl.formatToPlainString(t.BWqf0c, {
hours
});
}
return intl.formatToPlainString(t["3SLXAz"], {
minutes: expiry.diff(r7, "minutes")
});
};
export default function useFormattedExpirationLabel(a0) {
if (a0 != null) {
return formatExpirationLabel(a0);
}
};
export { formatExpirationLabel };
@@ -0,0 +1,23 @@
// Metro module 9559 (f9560).
import AuthenticationStore from "../../../stores/AuthenticationStore";
import { useStateFromStores } from "../../../_bundle/Module589";
let c6304_3 = {
END_EARLY: 0,
0: "END_EARLY"
};
let c6304_4 = [];
export default function usePollMessageContextItemTypes(a0) {
const stateFromStores = useStateFromStores([AuthenticationStore], () => AuthenticationStore.getId());
const poll = a0.poll;
if (a0.isPoll() && poll != null) {
const isSameOrBefore = poll.expiry.isSameOrBefore(Date.now());
const r24 = isSameOrBefore ? !isSameOrBefore : a0.author.id === stateFromStores;
const r27 = [];
if (r24) {
r27.push(c6304_3.END_EARLY);
}
return r27;
}
return c6304_4;
};
export { c6304_3 as PollMessageContextItemTypes };
@@ -0,0 +1,96 @@
// Metro module 11389 (f11390).
import { useState, useCallback } from "react";
import { TouchableOpacity, View } from "react-native";
import { MAX_POLL_ANSWER_LENGTH } from "../PollsConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useRenderPollAnswerImage from "./useRenderPollAnswerImage";
import { closeEditPollCreationImageAltTextModal } from "./EditPollCreationImageAltTextModalActionCreators";
import { SafeAreaPaddingView } from "../../../components_native/common/SafeAreaView";
import { intl, t } from "../../../intl/index.native";
import { Icon, Spacer, ClearButtonVisibility } from "../../../design/void/native";
import Module7699 from "../../../_bundle/Module7699";
import { Text } from "../../../design/components/Text/native/Text";
import KeyboardAwareView from "../../keyboard/native/KeyboardAwareView";
import FormHeader from "../../guild_member_verification/native/components/form_fields/FormHeader";
import { FormInput } from "../../../design/void/Form/native/index";
const useStyles = createStyles({
container: {
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
flex: 1
},
header: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: 18,
paddingTop: 10
},
separator: {
borderBottomWidth: 1,
borderColor: Module712.colors.INTERACTIVE_BACKGROUND_HOVER
},
contentContainer: {
flex: 1,
justifyContent: "center"
},
imageContainer: {
borderRadius: Module712.radii.lg,
justifyContent: "center",
alignItems: "center",
alignSelf: "center",
overflow: "hidden",
aspectRatio: 1
},
formContainer: {
paddingHorizontal: 16
},
textInput: {
backgroundColor: Module712.colors.REDESIGN_CHAT_INPUT_BACKGROUND,
borderRadius: Module712.radii.lg
}
});
export default function EditPollCreationImageAltTextModal(props) {
const { channelId, answer, onSave, imageSize } = props;
const styles = useStyles();
const renderPollAnswerImage = useRenderPollAnswerImage(channelId, answer.localCreationAnswerId, answer.image, imageSize, imageSize);
const renderImage = renderPollAnswerImage.renderImage;
let r38 = renderPollAnswerImage.upload?.description;
if (r38 == null) {
r38 = "";
}
const [state, onChange] = useState(r38);
const callback = useCallback(() => {
if (state != null) {
onSave(state);
}
closeEditPollCreationImageAltTextModal();
}, [onSave, state]);
return <SafeAreaPaddingView top style={styles.container}>
<View style={styles.header}>
<TouchableOpacity onPress={closeEditPollCreationImageAltTextModal} activeOpacity={0.5} accessibilityRole="button" accessibilityLabel={intl.string(t.cpT0Cq)}>
<Icon source={Module7699} />
</TouchableOpacity>
<Text variant="redesign/heading-18/bold" color="mobile-text-heading-primary">
{intl.string(t.Cq44Rg)}
</Text>
<TouchableOpacity onPress={callback} activeOpacity={0.5}>
<Text variant="text-md/medium" color="text-brand">
{intl.string(t["R3BPH+"])}
</Text>
</TouchableOpacity>
</View>
<View style={styles.separator} />
<KeyboardAwareView style={styles.contentContainer}>
<View style={styles.imageContainer}>{renderImage}</View>
<View style={styles.formContainer}>
<Spacer size={27} />
<FormHeader>
{intl.string(t["/2Gnoa"])}
</FormHeader>
<FormInput showTopContainer={false} showBorder={false} multiline={false} value={state} onChange={onChange} clearButtonVisibility={ClearButtonVisibility.WITH_CONTENT} style={styles.textInput} textContentType="none" maxLength={MAX_POLL_ANSWER_LENGTH} autoFocus autoCorrect accessibilityLabel={intl.string(t["/2Gnoa"])} />
<Spacer size={27} />
</View>
</KeyboardAwareView>
</SafeAreaPaddingView>;
};
@@ -0,0 +1,9 @@
// Metro module 11388 (f11389).
import ModalActionCreators from "../../../actions/ModalActionCreators";
let c7741_3 = "edit-poll-creation-image-alt-text-modal";
export function openEditPollCreationImageAltTextModal(a0) {
ModalActionCreators.pushLazy(import("./EditPollCreationImageAltTextModal"), a0, c7741_3);
}
export function closeEditPollCreationImageAltTextModal() {
ModalActionCreators.popWithKey(c7741_3);
}
@@ -0,0 +1,70 @@
// Metro module 11387 (f11388).
import { useCallback } from "react";
import { View } from "react-native";
import { POLL_CREATION_IMAGE_INPUT_ACTION_SHEET_KEY } from "../PollsConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useRenderPollAnswerImage from "./useRenderPollAnswerImage";
import { dismissKeyboard } from "../../../utils/native/ChatInputUtils";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { ActionSheet } from "../../../design/components/Sheet/native/ActionSheet.native";
import { Text } from "../../../design/components/Text/native/Text";
import { Spacer } from "../../../design/void/native";
import { ActionSheetRow } from "../../../design/components/Sheet/native/ActionSheetRow.native";
import { intl, t } from "../../../intl/index.native";
import { openEditPollCreationImageAltTextModal } from "./EditPollCreationImageAltTextModalActionCreators";
const useStyles = createStyles({
emojiContainer: {
flexDirection: "row",
alignItems: "center",
marginHorizontal: 24
},
emojiIcon: {
marginRight: 12,
borderRadius: Module712.radii.sm
}
});
export default function ImageInputAnswerActionSheet(props) {
const { channelId, index, answer, onSaveAltText, onRemoveAnswerImage, openExpressionPicker } = props;
const styles = useStyles();
const renderPollAnswerImage = useRenderPollAnswerImage(channelId, answer.localCreationAnswerId, answer.image, 40, 40);
const { renderImage, upload } = renderPollAnswerImage;
const r2 = upload != null || answer.image?.emoji != null;
const callback = useCallback(() => {
dismissKeyboard();
ActionSheetActionCreators.hideActionSheet(POLL_CREATION_IMAGE_INPUT_ACTION_SHEET_KEY);
}, []);
let r46 = r2;
if (r46) {
const r51 = [<View style={styles.emojiIcon}>{renderImage}</View>, ,];
const image = answer.image;
r51[1] = <Text variant="text-md/bold" color="mobile-text-heading-primary">
{`:${image == null ? void 0 : image.emoji?.name}:`}
</Text>;
r46 = <View style={styles.emojiContainer}>{r51}</View>;
}
return <ActionSheet startExpanded>
{r46}
<Spacer size={21} />
<ActionSheetRow.Group hasIcons={false}>
<ActionSheetRow label={r2 ? intl.string(t.CZeRhU) : intl.string(t.dzcU1Q)} onPress={() => {
callback();
openExpressionPicker();
}} />
{upload != null ? <ActionSheetRow label={intl.string(t.w7x2t4)} onPress={() => {
callback();
openEditPollCreationImageAltTextModal({
channelId,
answer,
index,
onSave: onSaveAltText,
imageSize: 40
});
}} /> : null}
{r2 ? <ActionSheetRow label={intl.string(t.IhMxgu)} onPress={() => {
onRemoveAnswerImage(index);
callback();
}} /> : null}
</ActionSheetRow.Group>
</ActionSheet>;
};
+168
View File
@@ -0,0 +1,168 @@
// Metro module 11385 (f11386).
import { useMemo, useCallback } from "react";
import { Keyboard, TouchableOpacity, View } from "react-native";
import ChannelStore from "../../../stores/ChannelStore";
import { DraftType } from "../../../stores/DraftStore";
import { MAX_POLL_ANSWER_LENGTH, POLL_CREATION_IMAGE_INPUT_ACTION_SHEET_KEY } from "../PollsConstants";
import { EmojiIntention } from "../../emojis/EmojiConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useRenderPollAnswerImage from "./useRenderPollAnswerImage";
import { intl, t } from "../../../intl/index.native";
import { filterOutUUID } from "../PollsUtils";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import { Icon } from "../../../design/void/native";
import { openEmojiPickerActionSheet } from "../../emoji_picker/native/openEmojiPickerActionSheet";
import UploadAttachmentActionCreators from "../../../actions/UploadAttachmentActionCreators";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import Module6577 from "../../../_bundle/Module6577";
import { FormInput } from "../../../design/void/Form/native/index";
import Module4149 from "../../../_bundle/Module4149";
import PollCreationInputError from "./PollCreationInputError";
let useStyles;
const ImageInput = function ImageInput(props) {
const { channelId: channelId2, localCreationAnswerId: localCreationAnswerId2, image, iconSrc } = props;
let openExpressionPicker3 = props.openExpressionPicker;
const { emojiSize = 24, containerStyle, imageSize, answerIndex, openImageInputActionSheet: openImageInputActionSheet2 } = props;
const styles = useStyles();
const renderPollAnswerImage = useRenderPollAnswerImage(channelId2, localCreationAnswerId2, image, imageSize, emojiSize);
const { renderImage, upload, setUploadSize } = renderPollAnswerImage;
const memo = useMemo(() => {
if (image?.emoji != null) {
return intl.formatToPlainString(t.vcC7Qn, {
imageName: image.emoji.name,
answerNumber: answerIndex + 1
});
}
if (upload != null) {
let filename = upload.item.filename;
if (filename == null) {
filename = "";
}
return intl.formatToPlainString(t.vcC7Qn, {
imageName: filterOutUUID(filename),
answerNumber: answerIndex + 1
});
}
return intl.formatToPlainString(t.ieNrxk, {
answerNumber: answerIndex + 1
});
}, [image, upload, answerIndex]);
const callback = useCallback((a0) => {
setUploadSize(a0.nativeEvent.layout.width);
}, [setUploadSize]);
const r2 = upload != null || image?.emoji != null;
if (r2) {
openExpressionPicker3 = openImageInputActionSheet2;
}
return <PressableOpacity accessibilityRole="button" accessibilityLabel={memo} onPress={openExpressionPicker3} onLongPress={r2 ? void 0 : openImageInputActionSheet2} onLayout={imageSize == null ? callback : void 0} style={[containerStyle, upload != null && styles.uploadContainer]}>
{r2 ? <View>{renderImage}</View> : <Icon source={iconSrc} />}
</PressableOpacity>;
};
useStyles = createStyles({
defaultContainer: {
flexDirection: "row",
alignItems: "center"
},
defaultImageAndTextContainer: {
flexDirection: "row",
alignItems: "center",
backgroundColor: Module712.colors.INPUT_BACKGROUND_DEFAULT,
borderRadius: Module712.radii.lg,
flex: 1,
overflow: "hidden"
},
cannotRemove: {
marginRight: 30
},
defaultImageContainer: {
width: 60,
height: 48,
justifyContent: "center",
alignItems: "center"
},
pollAnswerTextInput: {
flex: 1,
paddingStart: 0
},
defaultRemoveButtonContainer: {
paddingLeft: 6,
height: 48,
justifyContent: "center",
color: Module712.colors.TEXT_MUTED
},
uploadContainer: {
alignItems: "flex-start"
},
errorInput: {
borderColor: Module712.colors.BORDER_FEEDBACK_CRITICAL,
borderWidth: 2
}
});
export default function PollAnswerInput(props) {
let localCreationAnswerId, handleSaveAltText2;
const { answer, index, inputRef, channelId, onAnswerTextChange, onAnswerEmojiSelect } = props;
let canRemoveAnswer = props.canRemoveAnswer;
const { onRemoveAnswer, onRemoveAnswerImage, onSubmitEditing, error } = props;
localCreationAnswerId = void 0;
const openExpressionPicker2 = function openExpressionPicker() {
const channel = ChannelStore.getChannel(channelId);
if (channel != null) {
Keyboard.dismiss();
openEmojiPickerActionSheet({
channel,
onPressEmoji: (a0) => {
onAnswerEmojiSelect(a0, index);
},
pickerIntention: EmojiIntention.POLLS,
startExpanded: false,
autoFocus: false
});
}
};
handleSaveAltText2 = function handleSaveAltText(a0) {
UploadAttachmentActionCreators.update(channelId, answer.localCreationAnswerId, DraftType.Poll, {
description: a0
});
};
const styles = useStyles();
const image2 = answer.image;
localCreationAnswerId = answer.localCreationAnswerId;
let r7 = error != null && error.length > 0;
const style = [styles.defaultContainer, canRemoveAnswer ? !canRemoveAnswer : styles.cannotRemove];
const r88 = [<View style={[styles.defaultImageAndTextContainer, r7 ? styles.errorInput : r7]}>
<ImageInput channelId={channelId} localCreationAnswerId={localCreationAnswerId} image={image2} openExpressionPicker={openExpressionPicker2} openImageInputActionSheet={function openImageInputActionSheet() {
ActionSheetActionCreators.openLazy(import("./ImageInputActionSheet"), POLL_CREATION_IMAGE_INPUT_ACTION_SHEET_KEY, {
channelId,
index,
answer,
onSaveAltText: handleSaveAltText2,
onRemoveAnswerImage,
openExpressionPicker: openExpressionPicker2
});
}} iconSrc={Module6577} containerStyle={styles.defaultImageContainer} imageSize={48} answerIndex={index} />
<FormInput ref={inputRef} textAlignVertical="center" showTopContainer={false} showBorder={false} placeholder={intl.string(t.NNHVlv)} onChange={(event) => onAnswerTextChange({
text: event,
index,
localCreationAnswerId
})} onSubmitEditing={onSubmitEditing} blurOnSubmit={false} style={styles.pollAnswerTextInput} textContentType="none" accessibilityLabel={intl.formatToPlainString(t["3+V8G9"], {
answerNumber: index + 1
})} accessibilityHint={r7 ? intl.formatToPlainString(t.jnq5Ho, {
errorMessage: error
}) : void 0} maxLength={MAX_POLL_ANSWER_LENGTH} returnKeyType="next" required autoCorrect aria-invalid={error} />
</View>, ,];
if (canRemoveAnswer) {
canRemoveAnswer = <TouchableOpacity onPress={() => onRemoveAnswer(index)} accessibilityRole="button" style={styles.defaultRemoveButtonContainer} accessibilityLabel={intl.formatToPlainString(t["22fjEc"], {
answerNumber: index + 1
})}>
<Icon size={Icon.Sizes.MEDIUM} source={Module4149} color={styles.defaultRemoveButtonContainer.color} />
</TouchableOpacity>;
}
r88[1] = canRemoveAnswer;
const r119 = [<View style={style}>{r88}</View>, ,];
if (r7) {
r7 = <PollCreationInputError message={error} />;
}
r119[1] = r7;
return <>{r119}</>;
};
+32
View File
@@ -0,0 +1,32 @@
// Metro module 15509 (f15510).
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Icon, IconSizes } from "../../../design/void/native";
import Module15510 from "../../../_bundle/Module15510";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
const useStyles = createStyles({
container: {
borderRadius: Module712.radii.round,
paddingHorizontal: 8,
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
color: Module712.colors.TEXT_MUTED,
flexDirection: "row",
alignItems: "center"
},
text: {
marginLeft: 4,
textTransform: "uppercase"
}
});
export default function PollBadge(props) {
const style = props.style;
const styles = useStyles();
return <View style={[styles.container, style]}>
<Icon size={IconSizes.EXTRA_SMALL_10} source={Module15510} />
<Text style={styles.text} variant="text-xs/semibold">
{intl.string(t.RgIi2B)}
</Text>
</View>;
};
+266
View File
@@ -0,0 +1,266 @@
// Metro module 11372 (f11373).
import { forwardRef, useEffect, useRef, useCallback } from "react";
import { ScrollView, TouchableOpacity, View } from "react-native";
import { MAX_POLL_QUESTION_LENGTH, POLL_CREATION_DURATION_ACTION_SHEET_KEY } from "../PollsConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { isAndroid } from "../../../utils/PlatformUtils";
import { AlertModal, AlertActionButton } from "../../../design/components/AlertModal/native/AlertModal.native";
import { intl, t } from "../../../intl/index.native";
import { TextInput } from "../../../design/components/TextInput/native/TextInput.native";
import { Icon } from "../../../design/void/native";
import Module11373 from "../../../_bundle/Module11373";
import { Text } from "../../../design/components/Text/native/Text";
import usePollDurationOptions from "../usePollDurationOptions";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { TableRow } from "../../../design/components/TableRow/native/TableRow.native";
import { dismissKeyboard } from "../../../utils/native/ChatInputUtils";
import useTrackImpression from "../../app_analytics/useTrackImpression";
import { ImpressionTypes, ImpressionNames } from "../../../_bundle/Module503";
import useSafeAreaInsetsKeyboardAware_native from "../../safe_area/useSafeAreaInsetsKeyboardAware.native";
import { closeCreatePollModal } from "./PollCreationModalActionCreators";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import { PollsIcon } from "../../../design/components/Icon/native/redesign/generated/PollsIcon";
import { AccessibilityAnnouncer } from "../../../_bundle/Module3902";
import useCreatePollFormData from "../useCreatePollFormData";
import { useTrackPollCreationEvents } from "../useTrackPollEvents";
import { useNavigatorBackPressHandler } from "../../../design/components/Navigator/native/useNavigatorBackPressHandler.native";
import { isPollCreationEmpty } from "../PollsUtils";
import { openAlert } from "../../../design/components/AlertModal/native/useAlertStore.native";
import useFocusHelper from "./useFocusHelper";
import { HeaderActionButton } from "../../../design/components/Navigator/native/HeaderActionButton.native";
import Module5176 from "../../../_bundle/Module5176";
import ErrorBlock from "../../guild_role_subscriptions/native/components/ErrorBlock";
import { FormLabel } from "../../../design/void/Form/native/index";
import PollAnswerInput from "./PollAnswerInput";
import { TableCheckboxRow } from "../../../design/components/TableRow/native/TableCheckboxRow.native";
let useStyles, Component, AddAnswerButton, PollDurationSelectionRow;
const UnsavedChangesAlertModal = function UnsavedChangesAlertModal(props) {
const onConfirm = props.onConfirm;
return <AlertModal title={intl.string(t.HMrgcp)} content={intl.string(t["Wxa/j8"])} actions={<>
<AlertActionButton key="confirm" text={intl.string(t.TzJA4g)} onPress={onConfirm} />
<AlertActionButton key="back" variant="secondary" text={intl.string(t["2BR5R2"])} />
</>} />;
};
AddAnswerButton = function AddAnswerButton(props) {
const onPress2 = props.onPress;
const styles = useStyles();
const addAnswerButtonDefault = styles.addAnswerButtonDefault;
const r24 = <Icon source={Module11373} size={Icon.Sizes.LARGE} color={styles.addAnswerIcon.color} />;
return <TouchableOpacity onPress={onPress2} style={addAnswerButtonDefault} accessibilityRole="button" accessibilityLabel={intl.string(t.B2Uvme)}>
{r24}
<Text variant="text-md/medium" color="text-muted">
{intl.string(t.B2Uvme)}
</Text>
</TouchableOpacity>;
};
PollDurationSelectionRow = function PollDurationSelectionRow(props) {
const { selectedDuration, onChange } = props;
const r6 = usePollDurationOptions()[selectedDuration];
return <TableRow label={intl.string(t.bGHzxb)} accessibilityLabel={`${intl.string(t.bGHzxb)} ${r6}`} accessibilityHint={intl.string(t.A4PJ1o)} onPress={function onPress() {
dismissKeyboard();
ActionSheetActionCreators.openLazy(import("./PollDurationActionSheet"), POLL_CREATION_DURATION_ACTION_SHEET_KEY, {
selectedDuration,
onChange
});
}} trailing={<Text variant="text-md/normal" color="text-muted">{r6}</Text>} arrow />;
};
useStyles = createStyles({
viewPadding: {
paddingHorizontal: 18
},
scrollContainer: {
paddingVertical: 20,
gap: 16
},
safeAreaContainer: {
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
flex: 1
},
header: {
flexDirection: "row",
paddingHorizontal: 18,
paddingVertical: 10
},
actionButton: {
flex: 0,
justifyContent: "flex-start",
minWidth: 48,
paddingHorizontal: 0,
marginHorizontal: 0
},
postButton: {
justifyContent: "flex-end"
},
title: {
textAlign: "center",
flexGrow: 1
},
label: {
fontSize: 14
},
answerInputsContainer: {
marginVertical: 20,
rowGap: 16
},
addAnswerButtonDefault: {
paddingVertical: isAndroid() ? 10 : 8,
paddingLeft: 14,
marginRight: 30,
display: "flex",
flexDirection: "row",
gap: 16,
alignItems: "center",
justifyContent: "flex-start",
backgroundColor: Module712.colors.MESSAGE_BACKGROUND_HOVER,
borderRadius: Module712.radii.lg
},
addAnswerIcon: {
color: Module712.colors.TEXT_MUTED
},
pollConfigSection: {
borderTopWidth: 1,
borderColor: Module712.colors.INTERACTIVE_BACKGROUND_HOVER
}
});
Component = forwardRef(function({ onChange: onChange2, onSubmitEditing, error }, a1) {
const r2 = error != null && error.length > 0;
return <TextInput ref={a1} textAlignVertical="center" label={intl.string(t.WBiKnI)} accessibilityLabel={intl.string(t.WBiKnI)} accessibilityHint={r2 ? intl.formatToPlainString(t.jnq5Ho, {
errorMessage: error
}) : void 0} placeholder={intl.string(t["/uQqJW"])} onChange={onChange2} isClearable status={r2 ? "error" : "default"} errorMessage={error} maxLength={MAX_POLL_QUESTION_LENGTH} returnKeyType="next" blurOnSubmit={false} onSubmitEditing={onSubmitEditing} textContentType="none" autoFocus autoCorrect />;
});
export default function PollCreation(props) {
let ref, answers, question, allowMultiSelect, setAllowMultiSelect, canRemoveMoreAnswers, handleAnswerTextChange, handleEmojiSelect, handleAddAnswer, handleRemoveAnswer, handleRemoveAnswerImage, fieldErrors, shouldFocusOnInvalidField, setShouldFocusOnInvalidField, trackPollCreationCancelled, c18787_18;
const { channel, onCancel } = props;
ref = void 0;
answers = void 0;
question = void 0;
allowMultiSelect = void 0;
setAllowMultiSelect = void 0;
canRemoveMoreAnswers = void 0;
handleAnswerTextChange = void 0;
handleEmojiSelect = void 0;
handleAddAnswer = void 0;
handleRemoveAnswer = void 0;
handleRemoveAnswerImage = void 0;
fieldErrors = void 0;
shouldFocusOnInvalidField = void 0;
setShouldFocusOnInvalidField = void 0;
trackPollCreationCancelled = void 0;
c18787_18 = void 0;
const handleCancelClose2 = function handleCancelClose() {
trackPollCreationCancelled();
closeCreatePollModal();
AccessibilityAnnouncer.announce(intl.string(t["+G3oRq"]));
};
useTrackImpression({
type: ImpressionTypes.VIEW,
name: ImpressionNames.POLL_EDITOR_VIEWED
});
useEffect(() => () => {
if (!ref.current && onCancel != null) {
onCancel();
}
}, [onCancel]);
const styles = useStyles();
const insets = useSafeAreaInsetsKeyboardAware_native({
includeKeyboardHeight: true
}).insets;
ref = useRef(false);
const createPollFormData = useCreatePollFormData(channel, useCallback(() => {
ref.current = true;
closeCreatePollModal();
ToastActionCreators.open({
key: "POLL_CREATED_SUCCESS",
IconComponent: PollsIcon,
content: intl.string(t.OPsckI)
});
}, []), useCallback((a0) => {
AccessibilityAnnouncer.announce(intl.formatToPlainString(t.BByGU4, {
number: a0.indexToRemove + 1
}));
}, []));
answers = createPollFormData.answers;
question = createPollFormData.question;
allowMultiSelect = createPollFormData.allowMultiSelect;
setAllowMultiSelect = createPollFormData.setAllowMultiSelect;
let canAddMoreAnswers = createPollFormData.canAddMoreAnswers;
canRemoveMoreAnswers = createPollFormData.canRemoveMoreAnswers;
const handleQuestionChange = createPollFormData.handleQuestionChange;
handleAnswerTextChange = createPollFormData.handleAnswerTextChange;
handleEmojiSelect = createPollFormData.handleEmojiSelect;
handleAddAnswer = createPollFormData.handleAddAnswer;
handleRemoveAnswer = createPollFormData.handleRemoveAnswer;
handleRemoveAnswerImage = createPollFormData.handleRemoveAnswerImage;
const handleSubmitPoll = createPollFormData.handleSubmitPoll;
fieldErrors = createPollFormData.fieldErrors;
const { duration, setDuration, createPollError, submitting } = createPollFormData;
shouldFocusOnInvalidField = createPollFormData.shouldFocusOnInvalidField;
setShouldFocusOnInvalidField = createPollFormData.setShouldFocusOnInvalidField;
trackPollCreationCancelled = useTrackPollCreationEvents(answers, allowMultiSelect).trackPollCreationCancelled;
useNavigatorBackPressHandler(() => {
let r0;
if (isPollCreationEmpty(question, answers)) {
trackPollCreationCancelled();
AccessibilityAnnouncer.announce(intl.string(t["+G3oRq"]));
r0 = false;
} else {
openAlert("poll-creation-unsaved-changes", <UnsavedChangesAlertModal onConfirm={handleCancelClose2} />);
r0 = true;
}
return r0;
});
const focusHelper = useFocusHelper({
onAddAnswer: () => {
handleAddAnswer();
}
});
c18787_18 = focusHelper;
useEffect(() => {
const r13 = Object.keys(fieldErrors);
if (r13.length > 0) {
AccessibilityAnnouncer.announce(intl.formatToPlainString(t.w8e4qF, {
numOfErrors: r13.length
}));
if (shouldFocusOnInvalidField) {
c18787_18.focus(r13[0]);
setShouldFocusOnInvalidField(false);
}
}
}, [fieldErrors, focusHelper, setShouldFocusOnInvalidField, shouldFocusOnInvalidField]);
const r152 = [<View style={styles.header}>
<HeaderActionButton accessibilityLabel={intl.string(t["ETE/oC"])} onPress={function onPress() {
if (isPollCreationEmpty(question, answers)) {
trackPollCreationCancelled();
closeCreatePollModal();
AccessibilityAnnouncer.announce(intl.string(t["+G3oRq"]));
} else {
openAlert("poll-creation-unsaved-changes", <UnsavedChangesAlertModal onConfirm={handleCancelClose2} />);
}
}} source={Module5176} style={styles.actionButton} />
<Text accessibilityRole="header" variant="redesign/heading-18/bold" color="mobile-text-heading-primary" style={styles.title}>
{intl.string(t.Flr51u)}
</Text>
<HeaderActionButton text={intl.string(t.JOj8Zk)} style={[styles.actionButton, styles.postButton]} disabled={submitting} onPress={handleSubmitPoll} />
</View>, , ,];
const r164 = [createPollError != null && <ErrorBlock>
{createPollError == null ? void 0 : createPollError.getAnyErrorMessage()}
</ErrorBlock>, <Component ref={focusHelper.refWithKey("question")} onChange={handleQuestionChange} onSubmitEditing={focusHelper.focusNext} error={fieldErrors?.question} />, ,];
const r191 = [<FormLabel text={intl.string(t.oMBfeS)} color="text-subtle" style={styles.label} />, answers.map((a0, a1) => <PollAnswerInput key={a0.localCreationAnswerId} inputRef={c18787_18.refWithKey(`answer-${a0.localCreationAnswerId}`)} answer={a0} index={a1} channelId={channel.id} onSubmitEditing={c18787_18.focusNext} onAnswerTextChange={handleAnswerTextChange} onAnswerEmojiSelect={handleEmojiSelect} onRemoveAnswer={handleRemoveAnswer} onRemoveAnswerImage={handleRemoveAnswerImage} canRemoveAnswer={canRemoveMoreAnswers} error={fieldErrors == null ? void 0 : fieldErrors[`answer-${a0.localCreationAnswerId}`]} />), ,];
if (canAddMoreAnswers) {
canAddMoreAnswers = <AddAnswerButton onPress={handleAddAnswer} />;
}
r191[2] = canAddMoreAnswers;
r164[2] = <View style={styles.answerInputsContainer}>{r191}</View>;
r152[1] = <ScrollView style={styles.viewPadding} contentContainerStyle={styles.scrollContainer} keyboardShouldPersistTaps="handled">{r164}</ScrollView>;
r152[2] = <View style={styles.pollConfigSection}>
<PollDurationSelectionRow selectedDuration={duration} onChange={setDuration} />
<TableCheckboxRow label={intl.string(t["Ux+iQU"])} checked={allowMultiSelect} onPress={() => setAllowMultiSelect(!allowMultiSelect)} />
</View>;
return <View style={[styles.safeAreaContainer, {
paddingTop: insets.top,
paddingBottom: insets.bottom
}]}>
<>{r152}</>
</View>;
};
@@ -0,0 +1,33 @@
// Metro module 11390 (f11391).
import { useEffect } from "react";
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { AccessibilityAnnouncer } from "../../../_bundle/Module3902";
import { WarningCircle } from "../../../design/void/native";
import { Text } from "../../../design/components/Text/native/Text";
const useStyles = createStyles({
container: {
flexDirection: "row",
alignItems: "center",
marginTop: -10
},
icon: {
alignSelf: "center",
marginRight: 5,
color: Module712.colors.TEXT_FEEDBACK_CRITICAL
}
});
export default function PollCreationInputError(props) {
const message = props.message;
const styles = useStyles();
useEffect(() => {
if (message != null && message !== "") {
AccessibilityAnnouncer.announce(message);
}
}, [message]);
return <View style={styles.container}>
<WarningCircle width={16} height={16} style={styles.icon} />
<Text variant="text-xs/medium" color="text-feedback-critical">{message}</Text>
</View>;
};
@@ -0,0 +1,9 @@
// Metro module 11371 (f11372).
import ModalActionCreators from "../../../actions/ModalActionCreators";
let c7726_3 = "create-poll-modal";
export function openCreatePollModal(a0) {
ModalActionCreators.pushLazy(import("./PollCreation"), a0, c7726_3);
}
export function closeCreatePollModal() {
ModalActionCreators.popWithKey(c7726_3);
}
@@ -0,0 +1,30 @@
// Metro module 11375 (f11376).
import { useCallback } from "react";
import usePollDurationOptions from "../usePollDurationOptions";
import { AccessibilityAnnouncer } from "../../../_bundle/Module3902";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { TableRadioGroup } from "../../../design/components/TableRow/native/TableRadioGroup.native";
import { intl, t } from "../../../intl/index.native";
import { TableRadioRow } from "../../../design/components/TableRow/native/TableRadioRow.native";
import { ActionSheet } from "../../../design/components/Sheet/native/ActionSheet.native";
const PollDurationRadioGroup = function PollDurationRadioGroup(props) {
const { selectedDuration, onChange } = props;
const pollDurationOptions = usePollDurationOptions();
let c18788_1 = pollDurationOptions;
const callback = useCallback((a0) => {
onChange(a0);
AccessibilityAnnouncer.announce(c18788_1[a0]);
ActionSheetActionCreators.hideActionSheet();
}, [pollDurationOptions, onChange]);
return <TableRadioGroup title={intl.string(t["0ZStp9"])} hasIcons={false} onChange={callback} defaultValue={selectedDuration}>
{Object.entries(pollDurationOptions).map((item) => {
const [key, label] = item;
return <TableRadioRow key={key} value={parseInt(key)} label={label} />;
})}
</TableRadioGroup>;
};
export default function PollDurationActionSheet(props) {
return <ActionSheet>
<PollDurationRadioGroup selectedDuration={props.selectedDuration} onChange={props.onChange} />
</ActionSheet>;
};
@@ -0,0 +1,426 @@
// Metro module 9959 (f9960).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import { useMemo, useRef, useEffect, useCallback, forwardRef, useState } from "react";
import { Image as Image2, ScrollView, View } from "react-native";
import AccessibilityStore from "../../a11y/AccessibilityStore";
import EmojiStore from "../../emojis/EmojiStore";
import ChannelStore from "../../../stores/ChannelStore";
import MessageStore from "../../../stores/MessageStore";
import UserStore from "../../../stores/UserStore";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useStateFromStores } from "../../../_bundle/Module589";
import AvatarUtils from "../../../utils/AvatarUtils";
import Emoji from "../../emojis/native/Emoji";
import { intl, t } from "../../../intl/index.native";
import { PressableHighlight } from "../../../design/void/Pressables/native/Pressables";
import { Text } from "../../../design/components/Text/native/Text";
import { getTotalVotes } from "../PollsUtils";
import { Gesture, GestureDetector } from "../../../_bundle/Module5273";
import { reactionForId } from "../chat/formatPollMessageChatData";
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../app_analytics/useAnalyticsLocations";
import useVoteReactors from "../useVoteReactors";
import { useReactorsOnScrollNative } from "../../reactions/native/MessageReactionsContent";
import { ReactionTypes } from "../../messages/MessageReactionsTypes";
import NicknameUtils from "../../../utils/NicknameUtils";
import UserUtils from "../../../utils/UserUtils";
import { TableRow } from "../../../design/components/TableRow/native/TableRow.native";
import { Avatar, AvatarSizes } from "../../../design/void/native";
import DiscordTag from "../../user_profile/native/DiscordTag";
import showUserProfileActionSheet from "../../user_profile/native/showUserProfileActionSheet";
import ReanimatedRexport, { useSharedValue, useAnimatedStyle } from "../../reanimated/ReanimatedRexport";
import { withTiming } from "../../../design/animation/reanimated/timing/timing";
import { BottomSheetFlashList } from "../../../_bundle/noop_6676";
import useTheme from "../../../hooks/useTheme";
import { isThemeDark } from "../../../design/shared";
import Module9961 from "../../../_bundle/Module9961";
import Module9962 from "../../../_bundle/Module9962";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
let useStyles, Component, PollVotesHeader, __initData, VotersList, NoResults;
const PollEmoji = function PollEmoji(props) {
const { style, emoji } = props;
const styles = useStyles();
return <Emoji style={style} src={useStateFromStores([EmojiStore], () => {
if (emoji.id != null) {
let animated = emoji.animated;
if (!animated) {
let r12 = EmojiStore.getCustomEmojiById(emoji.id)?.animated;
if (r12 == null) {
r12 = false;
}
animated = r12;
}
return AvatarUtils.getEmojiURL({
id: emoji.id,
animated,
size: 16
});
}
})} name={emoji.name} textEmojiStyle={styles.emojiText} fastImageStyle={styles.emojiImage} />;
};
PollVotesHeader = function PollVotesHeader(props) {
let ref, ref2, ref3;
const { message, selectedAnswerId, setSelectedAnswerId } = props;
ref = void 0;
ref2 = void 0;
ref3 = void 0;
const styles = useStyles();
const memo2 = useMemo(() => getTotalVotes(message.reactions), [message.reactions]);
ref = useRef(null);
ref2 = useRef(null);
ref3 = useRef(false);
useEffect(() => {
setTimeout(async () => {
let c30171_0, c30171_1;
L24: {
L22: {
L16: {
let env31518;
c30171_1 = void 0;
const r9 = env31518 = {};
c30171_0 = r9;
env31518[0] = void 0;
env31518[1] = void 0;
env31518[2] = void 0;
env31518[3] = void 0;
env31518[4] = void 0;
env31518[5] = void 0;
env31518[6] = void 0;
env31518[7] = void 0;
env31518[8] = void 0;
env31518[9] = void 0;
env31518[10] = void 0;
env31518[11] = void 0;
const current = ref.current;
env31518[0] = current;
const current2 = ref2.current;
env31518[1] = current2;
if (current == null) {
break L24;
}
if (current2 != null) {
env31518[2] = await Promise.all([new Promise((c31995_0) => {
env31518[0].measure((a0, a1, a2, a3, a4) => c31995_0({
scrollWidth: a2,
scrollPageX: a4
}));
}), new Promise((c31996_0) => {
env31518[1].measure((a0, a1, a2, a3, a4) => c31996_0({
width: a2,
pageX: a4
}));
}), new Promise((c31997_0) => {
env31518[1].measureLayout(env31518[0], (a0) => c31997_0({
x: a0
}));
})]);
env31518[3] = (0, _slicedToArray)(env31518[2], 3);
env31518[4] = env31518[3][0];
env31518[5] = env31518[4].scrollWidth;
env31518[6] = env31518[4].scrollPageX;
env31518[7] = env31518[3][1];
env31518[8] = env31518[7].width;
env31518[9] = env31518[7].pageX;
env31518[10] = env31518[3][2].x;
env31518[11] = !AccessibilityStore.useReducedMotion;
if (ref3.current) {
if (env31518[9] < env31518[6]) {
const current4 = ref.current;
if (current4 == null) {
break L22;
}
current4.scrollTo({
x: env31518[10] - 16,
y: 0,
animated: env31518[11]
});
break L22;
}
if (!(env31518[9] + env31518[8] > env31518[6] + env31518[5])) {
break L22;
}
const current5 = ref.current;
if (current5 == null) {
break L22;
}
current5.scrollTo({
x: env31518[10] + env31518[8] - env31518[5] + 16,
y: 0,
animated: env31518[11]
});
break L22;
}
const current3 = ref.current;
if (current3 != null) {
current3.scrollTo({
x: env31518[10] + env31518[8] / 2 - env31518[5] / 2,
y: 0,
animated: env31518[11]
});
}
ref3.current = true;
break L16;
}
break L24;
}
return void 0;
}
return void 0;
}
}, 0);
}, [selectedAnswerId]);
const memo = useMemo(() => Gesture.Native().disallowInterruption(true), []);
return message.poll == null ? null : <View>
<Text style={styles.headerText} variant="redesign/heading-18/bold" color="mobile-text-heading-primary" accessibilityRole="header">{message.poll.question.text}</Text>
<Text style={styles.subheaderText} variant="text-md/medium" color="text-default">
{intl.format(t.XRkuof, {
count: memo2
})}
</Text>
<GestureDetector gesture={memo}>
<ScrollView ref={ref} style={styles.answerScroll} contentContainerStyle={styles.answerScrollContainer} horizontal showsHorizontalScrollIndicator={false} accessibilityRole="tablist" accessibilityLabel={intl.string(t["qbir+4"])}>
{message.poll.answers.map((a0) => {
const selected = selectedAnswerId === String(a0.answer_id);
return <Component key={a0.answer_id} ref={selected ? ref2 : void 0} answer={a0} selected={selected} reaction={reactionForId(message.reactions, String(a0.answer_id))} setSelectedAnswerId={setSelectedAnswerId} />;
})}
</ScrollView>
</GestureDetector>
</View>;
};
VotersList = function VotersList(props) {
let sharedValue;
const { channelId, messageId, reaction } = props;
sharedValue = void 0;
const styles = useStyles();
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const voteReactors = useVoteReactors({
channelId,
messageId,
reaction
});
const reactors = voteReactors.reactors;
const reactorsOnScrollNative = useReactorsOnScrollNative({
channelId,
messageId,
reactionSelected: reaction,
reactors,
reactorsHasMore: voteReactors.hasMore,
reactionType: ReactionTypes.VOTE
});
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId));
const callback = useCallback(({ item, index }) => {
let r21 = NicknameUtils.getNickname(stateFromStores?.guild_id, stateFromStores?.id, item);
if (r21 == null) {
r21 = UserUtils.getGlobalName(item);
}
const userTag = UserUtils.getUserTag(item);
let user = UserStore.getUser(item.id);
const guild_id = stateFromStores?.guild_id;
if (user == null) {
user = item;
}
const props = {
start: index === 0,
end: reactors.length - 1 === index,
icon: <Avatar guildId={guild_id} user={user} size={AvatarSizes.SMALL} />,
label: null,
subLabel: null,
onPress: null
};
let label = r21;
if (label == null) {
label = <DiscordTag user={item} />;
}
props.label = label;
props.subLabel = r21 != null ? userTag : null;
props.onPress = () => showUserProfileActionSheet({
userId: item.id,
localUser: item,
sourceAnalyticsLocations: analyticsLocations,
channelId,
messageId
});
return <TableRow {...props} />;
}, [stateFromStores, reactors.length, channelId, messageId, analyticsLocations]);
sharedValue = useSharedValue(reactors.length === 0 ? 0 : 1);
useEffect(() => {
if (reactors.length !== 0) {
sharedValue.set(withTiming(1, {
duration: 200
}));
} else {
sharedValue.set(0);
}
}, [sharedValue, reactors.length]);
const I = function I() {
return {
flex: 1,
opacity: sharedValue.get(),
marginBottom: 32
};
};
I.__closure = {
opacity: sharedValue
};
I.__workletHash = 8593850252158;
I.__initData = __initData;
return <ReanimatedRexport.View style={useAnimatedStyle(I)}>
<BottomSheetFlashList contentContainerStyle={styles.list} data={reactors} renderItem={callback} onScroll={reactorsOnScrollNative} />
</ReanimatedRexport.View>;
};
NoResults = function NoResults() {
const styles = useStyles();
return <View style={styles.noResultsContainer}>
<Image2 style={styles.noResultsImage} source={isThemeDark(useTheme()) ? Module9961 : Module9962} />
<Text style={styles.noResultsTitle} variant="heading-md/bold" color="mobile-text-heading-primary">
{intl.string(t.vhQK3o)}
</Text>
<Text style={styles.noResultsSubtitle} variant="text-sm/semibold" color="text-default">
{intl.string(t.bwytdh)}
</Text>
</View>;
};
useStyles = createStyles({
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
},
answerButton: {
padding: 8,
flexDirection: "row",
alignItems: "center",
borderRadius: Module712.radii.xs,
maxWidth: 200
},
answerSelected: {
backgroundColor: Module712.colors.BORDER_SUBTLE
},
answerEmoji: {
marginRight: 8
},
answerText: {
flexShrink: 1
},
emojiText: {
fontSize: 16
},
emojiImage: {
height: 16,
width: 16,
flexShrink: 0
},
noResultsContainer: {
flexDirection: "column",
alignItems: "center",
paddingHorizontal: 16
},
noResultsImage: {
marginTop: 32,
width: 138
},
noResultsTitle: {
marginTop: 16,
textAlign: "center"
},
noResultsSubtitle: {
marginTop: 4,
textAlign: "center"
}
});
Component = forwardRef(function({ answer, reaction, selected, setSelectedAnswerId: setSelectedAnswerId2 }, a1) {
const styles = useStyles();
let numVotes = reaction == null ? void 0 : reaction.count_details?.vote;
if (numVotes == null) {
numVotes = 0;
}
const callback = useCallback(() => {
setSelectedAnswerId2(String(answer.answer_id));
}, [setSelectedAnswerId2, answer.answer_id]);
const color = selected ? "interactive-text-active" : "text-default";
return <PressableHighlight ref={a1} onPress={callback} style={[styles.answerButton, selected ? styles.answerSelected : void 0]} accessibilityRole="tab" accessibilityState={{
selected
}} accessibilityLabel={intl.formatToPlainString(t.wqBc7A, {
numVotes,
option: answer.poll_media.text
})}>
{answer.poll_media.emoji != null ? <PollEmoji style={styles.answerEmoji} emoji={answer.poll_media.emoji} /> : null}
{answer.poll_media.text != null ? <Text style={styles.answerText} variant="text-sm/semibold" color={color} lineClamp={1}>{answer.poll_media.text}</Text> : null}
<Text variant="text-sm/semibold" color={color} lineClamp={1}>
{" "}
(
{numVotes.toLocaleString()}
)
</Text>
</PressableHighlight>;
});
__initData = {
code: "function PollVotesActionSheetTsx1(){const{opacity}=this.__closure;return{flex:1,opacity:opacity.get(),marginBottom:32};}"
};
export default function PollVotesActionSheet(props) {
let c17586_4;
const { channelId: channelId2, messageId: messageId2, initialAnswerId } = props;
c17586_4 = void 0;
const styles = useStyles();
const analyticsLocations2 = useAnalyticsLocations(AnalyticsLocation.POLL_VOTES).analyticsLocations;
const [state, setSelectedAnswerId3] = useState(initialAnswerId);
const stateFromStores2 = useStateFromStores([MessageStore], () => MessageStore.getMessage(channelId2, messageId2));
const r2 = stateFromStores2 != null && stateFromStores2.poll != null;
c17586_4 = r2;
useEffect(() => {
if (!c17586_4) {
ActionSheetActionCreators.hideActionSheet("PollVotesActionSheet");
}
}, [r2]);
const memo = useMemo(() => {
if (stateFromStores2?.reactions != null) {
return reactionForId(stateFromStores2.reactions, state);
}
}, [stateFromStores2?.reactions, state]);
if (r2) {
const r50 = stateFromStores2 == null;
let r18 = void 0;
if (!r50) {
const poll = stateFromStores2.poll;
r18 = poll == null ? void 0 : poll.answers.find((answer) => String(answer.answer_id) === state);
}
let count = memo == null ? void 0 : memo.count_details?.vote;
if (count == null) {
count = 0;
}
return <AnalyticsLocationProvider value={analyticsLocations2}>
<BottomSheet scrollable header={<PollVotesHeader message={stateFromStores2} selectedAnswerId={state} setSelectedAnswerId={setSelectedAnswerId3} />}>
<Text style={styles.answerName} variant="text-sm/semibold" color="text-default">
{r18 == null ? void 0 : r18.poll_media.text}
{" - "}
{intl.format(t["SG/Cyy"], {
count
})}
</Text>
{memo != null && count > 0 ? <VotersList channelId={channelId2} messageId={messageId2} reaction={memo} /> : <NoResults />}
</BottomSheet>
</AnalyticsLocationProvider>;
}
return null;
};
+152
View File
@@ -0,0 +1,152 @@
// Metro module 11382 (f11383).
import { createRef, useEffect } from "react";
import Module38 from "../../../_bundle/Module38";
import useInitialValue from "../../../hooks/useInitialValue";
import { $forInKeys } from "../../../_hermes/prelude";
function $mk87080($env) {
return () => {
let r18;
const r6 = $env;
const validState = r6[0].validState;
const { refsByKey, keyOrder } = validState;
let r10 = void 0;
const r13 = $forInKeys(refsByKey);
let r1 = 0;
const length = r13.length;
if (r13 !== void 0) {
do {
r10 = void 0;
const r11 = r1 < length ? r13[r1++] : void 0;
if (r11 === void 0) {
break;
}
const r15 = refsByKey[r11];
const r4 = r15 == null;
r18 = void 0;
if (!r4) {
const current = r15.current;
r18 = current == null ? void 0 : current.isFocused();
}
r10 = r11;
} while (r18 !== true);
}
L14: {
if (r10 != null) {
const r22 = keyOrder.indexOf(r10);
if (r22 !== -1 && !(r22 >= keyOrder.length - 1)) {
const r32 = refsByKey[r6[0].validState.keyOrder[r22 + 1]];
if (r32 == null) {
break L14;
}
const current2 = r32.current;
if (current2 == null) {
break L14;
}
current2.focus();
break L14;
}
const r36 = r6[0];
const onAddAnswer2 = r36.onAddAnswer;
if (onAddAnswer2 != null) {
onAddAnswer2.call(r36);
}
}
}
};
}
function $mk87081($env) {
return (a0) => {
const r6 = $env[0].validState.refsByKey[a0];
if (r6 != null) {
const current = r6.current;
if (current != null) {
current.focus();
}
}
};
}
class FocusHelperState {
constructor() {
const r3 = {
__proto__: new.target.prototype,
refsByKey: {},
keyOrder: null
};
r3.keyOrder = [];
return r3;
}
}
class FocusHelperImpl {
constructor() {
let env18793;
const r1 = env18793 = {};
env18793[0] = this;
const validState = {
__proto__: FocusHelperState.prototype,
refsByKey: {},
keyOrder: null
};
validState.keyOrder = [];
this.validState = validState;
this.focusNext = $mk87080(r1);
this.focus = $mk87081(r1);
}
restartState() {
const pendingState = {
__proto__: FocusHelperState.prototype,
refsByKey: {},
keyOrder: null
};
pendingState.keyOrder = [];
this.pendingState = pendingState;
}
commitState() {
const pendingState = this.pendingState;
if (pendingState != null) {
this.validState = pendingState;
}
this.pendingState = void 0;
}
refWithKey(a0) {
const pendingState = this.pendingState;
Module38(pendingState != null, "Called refWithKey without a valid state");
pendingState.keyOrder.push(a0);
const r17 = pendingState.refsByKey[a0];
if (r17 != null) {
return r17;
}
const ref = createRef();
pendingState.refsByKey[a0] = ref;
return ref;
}
}
export default function useFocusHelper(r1 = {}) {
let c18794_1;
const onAddAnswer = r1.onAddAnswer;
c18794_1 = void 0;
const initialValue = useInitialValue(() => {
let env27051;
const r7 = {
__proto__: FocusHelperImpl.prototype
};
const r8 = env27051 = {};
env27051[0] = r7;
const validState = {
__proto__: FocusHelperState.prototype,
refsByKey: {},
keyOrder: null
};
validState.keyOrder = [];
r7.validState = validState;
r7.focusNext = $mk87080(r8);
r7.focus = $mk87081(r8);
return r7;
});
c18794_1 = initialValue;
initialValue.restartState();
useEffect(() => {
c18794_1.onAddAnswer = onAddAnswer;
c18794_1.commitState();
});
return initialValue;
};
@@ -0,0 +1,59 @@
// Metro module 11386 (f11387).
import { useState, useMemo } from "react";
import { ActivityIndicator } from "react-native";
import { DraftType } from "../../../stores/DraftStore";
import UploadAttachmentStore from "../../../stores/UploadAttachmentStore";
import { EMOJI_URL_BASE_SIZE } from "../../emojis/EmojiConstants";
import { useStateFromStores } from "../../../_bundle/Module589";
import { PollMediaUploadAttachmentStatus } from "../PollTypes";
import FastImage from "../../../components_native/common/FastImage";
import Emoji from "../../emojis/native/Emoji";
import { EmojiTypes } from "../../emojis/EmojiTypes";
import AvatarUtils from "../../../utils/AvatarUtils";
export default function useRenderPollAnswerImage(c18797_0, c18797_1, a2, a3, a4) {
let c18797_7;
const width = a4;
const stateFromStores = useStateFromStores([UploadAttachmentStore], () => UploadAttachmentStore.getUpload(c18797_0, c18797_1, DraftType.Poll));
const [state, setUploadSize] = useState();
const r34 = (a2 == null ? void 0 : a2.mediaAttachmentState?.status) === PollMediaUploadAttachmentStatus.PREPARING;
c18797_7 = r34;
return {
renderImage: useMemo(() => {
if (c18797_7) {
return <ActivityIndicator />;
}
if (stateFromStores != null) {
const item = stateFromStores.item;
let width2 = a3;
if (width2 == null) {
width2 = state;
}
return <FastImage style={{
width: width2,
height: width2
}} source={{
uri: item.uri
}} />;
}
if (a2?.emoji != null) {
const emoji = a2.emoji;
let name = emoji.type === EmojiTypes.UNICODE ? emoji.surrogates : emoji.name;
if (name == null) {
name = "";
}
return <Emoji fastImageStyle={{
width,
height: width
}} textEmojiStyle={{
fontSize: width
}} name={name} src={emoji.id != null ? AvatarUtils.getEmojiURL({
id: emoji.id,
animated: emoji.animated,
size: EMOJI_URL_BASE_SIZE
}) : void 0} />;
}
}, [a2, a4, a3, stateFromStores, r34, state]),
upload: stateFromStores,
setUploadSize
};
};
@@ -0,0 +1,37 @@
// Metro module 7824 (f7825).
export default function parsePollResultSystemMessageEmbed(a0) {
if (a0?.fields == null) {
return null;
}
const r32 = {};
const victorEmoji = {};
for (const field of a0.fields) {
const rawName = field.rawName;
if (rawName === "poll_question_text") {
r32.questionText = field.rawValue;
} else if (rawName === "victor_answer_id") {
r32.victorAnswerId = field.rawValue;
} else if (rawName === "victor_answer_text") {
r32.victorAnswerText = field.rawValue;
} else if (rawName === "victor_answer_votes") {
r32.victorAnswerVotes = parseInt(field.rawValue, 10);
} else if (rawName === "total_votes") {
r32.totalVotes = parseInt(field.rawValue, 10);
} else if (rawName === "victor_answer_emoji_id") {
victorEmoji.id = field.rawValue;
} else if (rawName === "victor_answer_emoji_name") {
victorEmoji.name = field.rawValue;
} else if (rawName === "victor_answer_emoji_animated") {
victorEmoji.animated = field.rawValue === "true";
}
}
if (victorEmoji.name != null) {
let animated = victorEmoji.animated;
if (animated == null) {
animated = false;
}
victorEmoji.animated = animated;
r32.victorEmoji = victorEmoji;
}
return r32;
};
+8
View File
@@ -0,0 +1,8 @@
// Metro module 4521 (f4522).
import Module3771 from "../../_bundle/Module3771";
export default function transformMessagePoll(a0) {
return {
...a0,
expiry: Module3771(a0.expiry)
};
};
+294
View File
@@ -0,0 +1,294 @@
// Metro module 11376 (f11377).
import _slicedToArray from "../../_bundle/_slicedToArray";
import { useState, useCallback, useEffect } from "react";
import { PollDurations, MIN_NUMBER_OF_ANSWERS_PER_POLL, MAX_NUMBER_OF_ANSWERS_PER_POLL } from "./PollsConstants";
import { generateEmptyPollAnswer, isAnswerFilled, isIncompleteAnswer } from "./PollsUtils";
import useRequest from "../../hooks/useRequest";
import PollsActionCreators from "./PollsActionCreators";
import { removePollUploadAttachment, handlePollGifAttachmentAdd, handlePollMediaAttachmentAdd, removeAllPollUploadAttachments } from "./PollUploadAttachmentActionCreators.native";
import { getFileNameFromGifUrl } from "./PollAttachmentUtils";
import { PollMediaUploadAttachmentStatus } from "./PollTypes";
import { intl, t } from "../../intl/index.native";
import { PollLayoutTypes } from "../../_bundle/Module8002";
let env7730 = {};
const createPollCreationImageForMedia = function createPollCreationImageForMedia(a0, a1) {
return {
mediaAttachmentState: {
status: a1,
mediaURL: a0
},
emoji: void 0,
stickerId: void 0
};
};
export default function useCreatePollCommonData(a0, a1, a2, a3) {
let env18789 = {
$parent: env7730
};
env18789[0] = a0;
env18789[1] = a1;
env18789[2] = a2;
env18789[3] = a3;
const id = a0.id;
env18789[4] = id;
const r39 = _slicedToArray(useState(() => {
const r4 = env18789[3];
const r2 = r4 == null;
let r8 = void 0;
if (!r2) {
const initialAnswers = r4.initialAnswers;
r8 = initialAnswers == null ? void 0 : initialAnswers.map((initialAnswer) => ({
...generateEmptyPollAnswer(),
...initialAnswer
}));
}
if (r8 == null) {
r8 = [generateEmptyPollAnswer(), generateEmptyPollAnswer()];
}
return r8;
}), 2);
const answers = r39[0];
env18789[5] = answers;
env18789[6] = r39[1];
let r42 = a3?.initialQuestion;
if (r42 == null) {
r42 = "";
}
const r44 = _slicedToArray(useState(r42), 2);
const question = r44[0];
env18789[7] = question;
const setQuestion = r44[1];
env18789[8] = setQuestion;
const r48 = _slicedToArray(useState(false), 2);
const allowMultiSelect = r48[0];
env18789[9] = allowMultiSelect;
const setAllowMultiSelect = r48[1];
let r50 = a3?.initialDuration;
if (r50 == null) {
r50 = PollDurations.ONE_DAY;
}
const r53 = _slicedToArray(useState(r50), 2);
const duration = r53[0];
env18789[10] = duration;
const setDuration = r53[1];
const r57 = _slicedToArray(useState({}), 2);
const fieldErrors = r57[0];
env18789[11] = r57[1];
const [shouldFocusOnInvalidField, setShouldFocusOnInvalidField] = useState(false);
env18789[12] = setShouldFocusOnInvalidField;
const r35 = answers.filter((answer) => isAnswerFilled(answer));
env18789[13] = r35;
const r67 = answers.filter((answer) => isIncompleteAnswer(answer));
const canPost = question.length > 0 && r35.length >= MIN_NUMBER_OF_ANSWERS_PER_POLL && r67.length === 0;
let c18790_0;
const r80 = _slicedToArray(useRequest(PollsActionCreators.createPoll), 2);
const r34 = r80[0];
env18789[14] = r34;
const r81 = r80[1];
const { error, loading } = r81;
env18789[15] = loading;
const canAddMoreAnswers = answers.length < MAX_NUMBER_OF_ANSWERS_PER_POLL;
env18789[16] = canAddMoreAnswers;
const canRemoveMoreAnswers = answers.length > MIN_NUMBER_OF_ANSWERS_PER_POLL;
env18789[17] = canRemoveMoreAnswers;
const callback3 = useCallback((a0) => {
(0, env18789[11])((a0) => {
const r1 = {
...a0
};
delete r1["question"];
return r1;
});
(0, env18789[8])(a0);
}, []);
const callback2 = useCallback(({ text, index, localCreationAnswerId }) => {
(0, env18789[11])((a0) => {
const r1 = {
...a0
};
delete r1[`answer-${localCreationAnswerId}`];
return r1;
});
(0, env18789[6])((a0) => {
const r1 = [...a0];
r1[index] = {
...r1[index],
text
};
return r1;
});
}, []);
const callback4 = useCallback((image, c27040_1) => {
(0, env18789[6])((a0) => {
const r1 = [...a0];
r1[c27040_1] = {
...r1[c27040_1],
image
};
return r1;
});
}, []);
env18789[18] = callback4;
const callback5 = useCallback((a0, a1, a2) => {
const r8 = env18789[5][a1];
const mediaAttachmentState = r8.image?.mediaAttachmentState;
if (mediaAttachmentState != null && mediaAttachmentState.mediaURL !== a2) {
removePollUploadAttachment(a0, r8.localCreationAnswerId, getFileNameFromGifUrl(r8.localCreationAnswerId, mediaAttachmentState.mediaURL));
}
}, [answers]);
env18789[19] = callback5;
c18790_0 = void 0;
c18790_0 = async (c30396_0, c30396_1, c30396_2) => {
let c30396_4;
c30396_4 = void 0;
let c31622_0 = c30396_1;
let c31622_1 = c30396_2;
const localCreationAnswerId2 = env18789[5][c30396_1].localCreationAnswerId;
(0, env18789[19])(c30396_0, c30396_1);
(0, env18789[18])(createPollCreationImageForMedia(c30396_2, PollMediaUploadAttachmentStatus.PREPARING), c30396_1);
if (await handlePollGifAttachmentAdd(c30396_0, localCreationAnswerId2, c30396_2) != null) {
env18789[18]((0, createPollCreationImageForMedia)(c31622_1, PollMediaUploadAttachmentStatus.READY_TO_UPLOAD), c31622_0);
} else {
env18789[18]((0, createPollCreationImageForMedia)(c31622_1, PollMediaUploadAttachmentStatus.ERROR), c31622_0);
}
};
const callback = useCallback(function() {
return c18790_0.apply(this, arguments);
}, [answers, callback4, callback5]);
const callback6 = useCallback((a0, a1, a2) => {
const localCreationAnswerId2 = env18789[5][a1].localCreationAnswerId;
const objectURL = URL.createObjectURL(a2);
(0, env18789[19])(a0, a1);
const r18 = env18789[18];
r18({
mediaAttachmentState: {
status: PollMediaUploadAttachmentStatus.PREPARING,
mediaURL: objectURL
},
emoji: void 0,
stickerId: void 0
}, a1);
handlePollMediaAttachmentAdd(a0, localCreationAnswerId2, a2);
r18({
mediaAttachmentState: {
status: PollMediaUploadAttachmentStatus.READY_TO_UPLOAD,
mediaURL: objectURL
},
emoji: void 0,
stickerId: void 0
}, a1);
}, [answers, callback4, callback5]);
const callback7 = useCallback((a0, a1) => {
(0, env18789[19])(env18789[4], a1);
(0, env18789[18])({
emoji: a0,
stickerId: void 0,
mediaAttachmentState: void 0
}, a1);
}, [id, callback4, callback5]);
const callback8 = useCallback((c27041_0) => {
(0, env18789[6])((a0) => {
const r2 = [...a0];
r2[c27041_0] = {
...r2[c27041_0],
image: void 0
};
return r2;
});
}, []);
const callback9 = useCallback(() => {
if (env18789[16]) {
(0, env18789[6])((a0) => [...a0, generateEmptyPollAnswer()]);
}
}, [canAddMoreAnswers]);
const callback10 = useCallback((a0) => {
let c27042_0 = a0;
if (env18789[17]) {
const length = env18789[5].length;
(0, env18789[19])(env18789[4], a0);
(0, env18789[6])((a0) => {
const r1 = [...a0];
r1.splice(c27042_0, 1);
return r1;
});
const r14 = env18789[2];
if (r14 != null) {
r14({
indexToRemove: a0,
numberOfAnswers: length
});
}
}
}, [answers.length, canRemoveMoreAnswers, id, a2, callback5]);
useEffect(() => () => {
removeAllPollUploadAttachments(env18789[4]);
}, [id]);
const callback11 = useCallback(() => {
let c27043_0 = true;
const r6 = {};
let c27043_1 = r6;
if (env18789[7].trim().length === 0) {
c27043_0 = false;
r6.question = intl.string(t.gPX3oI);
}
const r25 = env18789[5];
if (r25.filter((item) => isAnswerFilled(item)).length < MIN_NUMBER_OF_ANSWERS_PER_POLL) {
c27043_0 = false;
r6[`answer-${r25[0].localCreationAnswerId}`] = intl.string(t.fYvzEX);
}
r25.forEach((item) => {
if (isIncompleteAnswer(item)) {
c27043_0 = false;
c27043_1[`answer-${item.localCreationAnswerId}`] = intl.string(t["8Qqkc+"]);
}
});
(0, env18789[11])(r6);
(0, env18789[12])(!c27043_0);
return c27043_0;
}, [answers, question]);
env18789[20] = callback11;
const callback12 = useCallback(async () => {
await (0, env18789[14])({
channel: env18789[0],
question: env18789[7],
answers: env18789[13],
allowMultiSelect: env18789[9],
duration: env18789[10],
layout: PollLayoutTypes.DEFAULT,
onClose: env18789[1]
});
}, [question, r35, allowMultiSelect, duration, r34, a0, a1]);
env18789[21] = callback12;
return {
answers,
question,
setQuestion,
allowMultiSelect,
setAllowMultiSelect,
duration,
setDuration,
canPost,
canAddMoreAnswers,
canRemoveMoreAnswers,
handleQuestionChange: callback3,
handleAnswerTextChange: callback2,
handleGifSelect: callback,
handleEmojiSelect: callback7,
handleCustomUpload: callback6,
handleAddAnswer: callback9,
handleRemoveAnswer: callback10,
handleRemoveAnswerImage: callback8,
fieldErrors,
createPoll: callback12,
handleSubmitPoll: useCallback(() => {
const r3 = env18789[15];
if (r3 ? !r3 : (0, env18789[20])()) {
(0, env18789[21])();
}
}, [callback12, loading, callback11]),
submitting: loading,
createPollError: error,
shouldFocusOnInvalidField,
setShouldFocusOnInvalidField
};
};
@@ -0,0 +1,10 @@
// Metro module 9414 (f9415).
import LocaleStore from "../user_settings/LocaleStore";
import { useStateFromStores } from "../../_bundle/Module589";
import { intl, t } from "../../intl/index.native";
export default function useMaybeAddPollsMarketingEasterEggNote(a0) {
const stateFromStores = useStateFromStores([LocaleStore], () => LocaleStore.locale.startsWith("en-"));
return a0 === ":pizza:" ? stateFromStores ? intl.formatToPlainString(t["1knDPI"], {
emojiName: a0
}) : a0 : a0;
};
+23
View File
@@ -0,0 +1,23 @@
// Metro module 11374 (f11375).
import { PollDurations } from "./PollsConstants";
import { intl, t } from "../../intl/index.native";
export default function usePollDurationOptions() {
const r3 = Object;
const r12 = {};
r12[PollDurations.ONE_HOUR] = intl.formatToPlainString(t["b/mgtw"], {
num: 1
});
r12[PollDurations.FOUR_HOURS] = intl.formatToPlainString(t["b/mgtw"], {
num: 4
});
r12[PollDurations.EIGHT_HOURS] = intl.formatToPlainString(t["b/mgtw"], {
num: 8
});
r12[PollDurations.ONE_DAY] = intl.formatToPlainString(t["b/mgtw"], {
num: 24
});
r12[PollDurations.THREE_DAYS] = intl.string(t.Xn5rX3);
r12[PollDurations.SEVEN_DAYS] = intl.string(t["Lmq+rj"]);
r12[PollDurations.FOURTEEN_DAYS] = intl.string(t["mb8A/O"]);
return r3.freeze(r12);
};
+34
View File
@@ -0,0 +1,34 @@
// Metro module 11381 (f11382).
import { useCallback } from "react";
import { AnalyticEvents } from "../../Constants";
import AppAnalyticsUtils from "../app_analytics/AppAnalyticsUtils";
import { PollLayoutTypes } from "../../_bundle/Module8002";
export function useTrackPollCreationEvents(a0, a1) {
const allow_multiselect = a1;
return {
trackPollCreationCancelled: useCallback(() => {
let attachments_count = 0;
let emojis_count = 0;
let stickers_count = 0;
a0.forEach(({ image }) => {
if (image != null) {
if (image.emoji != null) {
emojis_count = emojis_count + 1;
} else if (image.stickerId != null) {
stickers_count = stickers_count + 1;
} else if (image.mediaAttachmentState != null) {
attachments_count = attachments_count + 1;
}
}
});
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.POLL_CREATION_CANCELLED, {
answers_count: a0.length,
attachments_count,
emojis_count,
stickers_count,
allow_multiselect,
layout_type: PollLayoutTypes.DEFAULT
});
}, [a0, a1])
};
}
+25
View File
@@ -0,0 +1,25 @@
// Metro module 9960 (f9961).
import MessageReactionsStore from "../../stores/MessageReactionsStore";
import { DEFAULT_NUM_REACTION_USERS } from "../../Constants";
import { useStateFromStores } from "../../_bundle/Module589";
import { ReactionTypes } from "../messages/MessageReactionsTypes";
import isUndefinedOrNull from "../../_bundle/isUndefinedOrNull";
export default function useVoteReactors({ channelId, messageId, reaction }) {
const stateFromStores = useStateFromStores([MessageReactionsStore], () => {
const reactions = MessageReactionsStore.getReactions(channelId, messageId, reaction.emoji, DEFAULT_NUM_REACTION_USERS, ReactionTypes.VOTE);
const r5 = Array;
let r25 = reactions == null ? void 0 : reactions.values();
if (r25 == null) {
r25 = [];
}
return r5.from(r25);
}, [channelId, messageId, reaction.emoji], isUndefinedOrNull);
let r29 = reaction.count_details?.vote;
if (r29 == null) {
r29 = 0;
}
return {
reactors: stateFromStores,
hasMore: r29 > stateFromStores.length
};
};