77 lines
2.6 KiB
TypeScript
77 lines
2.6 KiB
TypeScript
// Metro module 3828 (f3829).
|
|
import AuthenticationStore from "../../stores/AuthenticationStore";
|
|
import { AnalyticEvents, AnalyticsSections } from "../../Constants";
|
|
import { NotificationSettingsUpdateType } from "../notifications/NotificationConstants";
|
|
import UnicodeEmojis from "../emojis/UnicodeEmojis";
|
|
import { t, intl } from "../../intl/index.native";
|
|
import { ReactionNotifications } from "../user_settings/UserSettings";
|
|
import AnalyticsUtils from "../../utils/AnalyticsUtils";
|
|
export const MAX_REACTIONS = 20;
|
|
export function getReactionEmojiName(a0) {
|
|
return a0.id == null ? UnicodeEmojis.convertSurrogateToName(a0.name) : `:${a0.name}:`;
|
|
}
|
|
export function getAccessibleEmojiDisplayName(a0, a1, a2, a3) {
|
|
const r6 = a3 ? a0 ? t.i9DXqM : t["Z/l+qu"] : a0 ? t.CLuzw5 : t.PirBBE;
|
|
const r41 = a2.id == null ? UnicodeEmojis.convertSurrogateToName(a2.name) : `:${a2.name}:`;
|
|
const r2 = r41 == null;
|
|
let emojiName = void 0;
|
|
if (!r2) {
|
|
const r51 = r41.replace(/[:_]/g, " ");
|
|
emojiName = r51 == null ? void 0 : r51.trim();
|
|
}
|
|
if (emojiName == null) {
|
|
emojiName = "";
|
|
}
|
|
return intl.formatToPlainString(r6, {
|
|
reactions: a1,
|
|
emojiName
|
|
});
|
|
}
|
|
export function toReactionEmoji(a0) {
|
|
let id = a0.id;
|
|
if (id == null) {
|
|
id = null;
|
|
}
|
|
let name = a0.id != null ? a0.name : a0.optionallyDiverseSequence;
|
|
if (name == null) {
|
|
name = a0.name;
|
|
}
|
|
if (name == null) {
|
|
name = "";
|
|
}
|
|
return {
|
|
id,
|
|
name,
|
|
animated: Boolean(a0.animated)
|
|
};
|
|
}
|
|
export function isCustomReactionEmojiId(a0) {
|
|
return a0 != null && a0 !== "" && (typeof a0 === "number" ? a0 !== 0 : String(a0) !== "0");
|
|
}
|
|
export function emojiEquals(a0, a1) {
|
|
if (a1.id != null) {
|
|
return `${a1.id}` === (a0.id != null ? `${a0.id}` : a0.id);
|
|
}
|
|
return a0.id == null && a1.name === a0.name;
|
|
}
|
|
export function getBurstAnalyticsSection(a0) {
|
|
return a0.isThread() ? AnalyticsSections.THREAD_TEXT_AREA : a0.isForumPost() ? AnalyticsSections.FORUM_CHANNEL_TEXT_AREA : a0.isGuildVocal() ? AnalyticsSections.TEXT_IN_VOICE : AnalyticsSections.CHANNEL_TEXT_AREA;
|
|
}
|
|
export function shouldApplyReaction(a0) {
|
|
const userId = a0.userId;
|
|
let optimistic = a0.optimistic;
|
|
const id = AuthenticationStore.getId();
|
|
if (optimistic) {
|
|
optimistic = !(id === userId);
|
|
}
|
|
return !optimistic;
|
|
}
|
|
export function updateReactionNotificationsSetting(a0, a1) {
|
|
ReactionNotifications.updateSetting(a0);
|
|
AnalyticsUtils.track(AnalyticEvents.NOTIFICATION_SETTINGS_UPDATED, {
|
|
update_type: NotificationSettingsUpdateType.ACCOUNT,
|
|
reaction_notifications: a0,
|
|
reaction_notifications_old: a1
|
|
});
|
|
}
|