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

+240
View File
@@ -0,0 +1,240 @@
// Metro module 5093 (f5094).
import _slicedToArray from "../../_bundle/_slicedToArray";
import { TypeTag } from "../../_bundle/Module1413";
import { LibdiscoreStore } from "../libdiscore/stores/LibdiscoreStore";
import GuildStore from "../../stores/GuildStore";
import { StickerMetadataTypes } from "./StickersTypes";
import UnicodeEmojis from "../emojis/UnicodeEmojis";
import { LibdiscoreBatchStoreRefactorExperiment } from "../libdiscore/libdiscoreExperiments";
let parseServerGuildStickers, deriveStickerMetadata, syncStickers;
const parseServerGuildSticker = function parseServerGuildSticker(a0) {
const r0 = {
id: a0.id,
tags: a0.tags,
type: a0.type,
name: a0.name,
description: a0.description,
format_type: a0.format_type,
guild_id: a0.guild_id,
available: a0.available,
version: a0.version,
user_id: a0.user_id
};
r0[TypeTag] = "GuildSticker";
return r0;
};
parseServerGuildStickers = function parseServerGuildStickers(a0) {
const r0 = {};
for (const item of a0) {
r0[item.id] = parseServerGuildSticker(item);
}
return r0;
};
deriveStickerMetadata = function deriveStickerMetadata(key, a1) {
const r4 = [];
let c14606_0 = r4;
const tags = a1.tags;
r4.push({
type: StickerMetadataTypes.STICKER_NAME,
value: a1.name.trim().toLocaleLowerCase()
});
if (tags != null) {
r4.push({
type: StickerMetadataTypes.TAG,
value: tags.trim().toLocaleLowerCase()
});
const guild = GuildStore.getGuild(key);
if (guild != null) {
const value = guild.name.trim().toLocaleLowerCase();
if (value != null && value !== "") {
r4.push({
type: StickerMetadataTypes.GUILD_NAME,
value
});
}
}
const byName = UnicodeEmojis.getByName(tags);
if (byName != null) {
r4.push({
type: StickerMetadataTypes.CORRELATED_EMOJI,
value: byName.surrogates
});
byName.forEachDiversity((a0) => c14606_0.push({
type: StickerMetadataTypes.CORRELATED_EMOJI,
value: a0.surrogates
}));
}
}
return r4;
};
syncStickers = function syncStickers(id, stickers, a2) {
L15: {
if (stickers.op === "full_sync") {
a2.setPartition(id, parseServerGuildStickers(stickers.items));
} else {
const nullablePartition = a2.getNullablePartition(id);
if (nullablePartition == null) {
a2.setPartition(id, parseServerGuildStickers(stickers.writes));
} else {
if (!(stickers.writes.length > 0) && !(stickers.deletes.length > 0)) {
break L15;
}
const r32 = {
...nullablePartition
};
for (const delete2 of stickers.deletes) {
delete r32[delete2];
}
for (const write of stickers.writes) {
r32[write.id] = parseServerGuildSticker(write);
}
a2.setPartition(id, r32);
}
}
}
};
class GuildStickersStore extends LibdiscoreStore {
static displayName = "GuildStickersStore";
database = this.addKKVDatabase("guildStickers");
stickerByIdIndex = this.database.addSecondaryKVIndex("id");
getAllGuildStickers = this.database.memoized((a0) => {
const map = new Map();
for (const key in a0) {
map.set(key, Object.values(a0[key].root));
}
return map;
});
getStickerMetadataMap = this.database.memoized((a0) => {
const map = new Map();
for (const key in a0) {
for (const item of Object.entries(a0[key].root)) {
const r42 = _slicedToArray(item, 2);
map.set(r42[0], deriveStickerMetadata(key, r42[1]));
}
}
return map;
});
getStickersByGuildId = this.database.memoizedPartition((a0, a1) => Object.values(a1));
getStickerById(a0) {
let r5 = this.stickerByIdIndex.get(a0);
if (r5 == null) {
r5 = void 0;
}
return r5;
}
stateWrapper() {
return this.database;
}
}
const guildStickersStore = new GuildStickersStore({
LOGOUT: (a0, a1) => a1.clear(),
BACKGROUND_SYNC: (a0, a1) => a1.clear(),
RESET_SOCKET: (a0, a1) => a1.clear(),
CONNECTION_OPEN: ({ guilds, unavailableGuilds }, a1) => {
let r22;
const set = new Set(guilds.map((guild) => guild.id));
let r31 = unavailableGuilds[Symbol.iterator]();
const next = r31.next;
while (true) {
const r8 = r31 === void 0 ? void 0 : (r22 = next.call(r31)).done ? r31 = void 0 : r22.value;
if (r31 === void 0) {
for (const item of a1.getPartitionKeys()) {
if (!set.has(item)) {
a1.removePartition(item);
}
}
for (const item2 of guilds) {
syncStickers(item2.id, item2.stickers, a1);
}
return void 0;
} else {
try {
set.add(r8);
} catch (r37) {
if (r31 !== void 0 && typeof r31.return === "function") {
try {
r31.return();
} catch {}
}
throw r37;
}
}
}
},
GUILD_CREATE: (a0, a1) => {
if (a0.guild.joined_at == null) {
return false;
}
syncStickers(a0.guild.id, a0.guild.stickers, a1);
},
GUILD_DELETE: (a0, a1) => {
a1.removePartition(a0.guild.id);
},
GUILD_STICKERS_CREATE_SUCCESS: (a0, a1) => {
const setRecord = a1.setRecord;
const guildId = a0.guildId;
const id = a0.sticker.id;
const sticker = a0.sticker;
const r9 = {
id: sticker.id,
tags: sticker.tags,
type: sticker.type,
name: sticker.name,
description: sticker.description,
format_type: sticker.format_type,
guild_id: sticker.guild_id,
available: sticker.available,
version: sticker.version,
user_id: sticker.user_id
};
r9[TypeTag] = "GuildSticker";
setRecord.call(a1, guildId, id, r9);
},
GUILD_STICKER_FETCH_SUCCESS: (a0, a1) => {
const setRecord = a1.setRecord;
const guild_id = a0.sticker.guild_id;
const id = a0.sticker.id;
const sticker = a0.sticker;
const r10 = {
id: sticker.id,
tags: sticker.tags,
type: sticker.type,
name: sticker.name,
description: sticker.description,
format_type: sticker.format_type,
guild_id: sticker.guild_id,
available: sticker.available,
version: sticker.version,
user_id: sticker.user_id
};
r10[TypeTag] = "GuildSticker";
setRecord.call(a1, guild_id, id, r10);
},
GUILD_STICKERS_UPDATE: (a0, a1) => {
const partition = a1.getPartition(a0.guildId);
const r21 = parseServerGuildStickers(a0.stickers);
if (partition != null) {
for (const key in r21) {
const r15 = r21[key];
const r14 = partition[key];
if (r14 != null && r15.user_id == null && r14.user_id != null) {
r21[key] = {
...r15,
user_id: r14.user_id
};
}
}
}
a1.setPartition(a0.guildId, r21);
},
CACHED_STICKERS_LOADED: (a0, a1) => {
for (const sticker of a0.stickers) {
const r28 = _slicedToArray(sticker, 2);
a1.setPartition(r28[0], parseServerGuildStickers(r28[1]));
}
},
GUILD_STICKERS_FETCH_SUCCESS: (a0, a1) => {
a1.setPartition(a0.guildId, parseServerGuildStickers(a0.stickers));
}
}, LibdiscoreBatchStoreRefactorExperiment.getCachedBridgedStoreMode());
export default guildStickersStore;
@@ -0,0 +1,29 @@
// Metro module 4855 (f4856).
import { DraftType } from "../../stores/DraftStore";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c2989_1 = {};
let c2989_2 = {};
class StickerMessagePreviewStore extends Module589.Store {
static displayName = "StickerMessagePreviewStore";
getStickerPreview(a0, a1) {
return (a1 === DraftType.FirstThreadMessage ? c2989_2 : c2989_1)[a0];
}
}
const stickerMessagePreviewStore = new StickerMessagePreviewStore(Dispatcher, {
ADD_STICKER_PREVIEW: function handleAddStickerPreview(a0) {
(a0.draftType === DraftType.FirstThreadMessage ? c2989_2 : c2989_1)[a0.channelId] = [a0.sticker];
},
CLEAR_STICKER_PREVIEW: function handleClearStickerPreview(a0) {
const channelId = a0.channelId;
const r7 = a0.draftType === DraftType.FirstThreadMessage ? c2989_2 : c2989_1;
if (r7[channelId] != null) {
delete r7[channelId];
}
},
LOGOUT: function resetState() {
c2989_1 = {};
c2989_2 = {};
}
});
export default stickerMessagePreviewStore;
+46
View File
@@ -0,0 +1,46 @@
// Metro module 9621 (f9622).
import GuildMemberStore from "../../stores/GuildMemberStore";
import StickersPackStore from "./StickersPackStore";
import { Permissions } from "../../Constants";
import PremiumUtils from "../../utils/PremiumUtils";
import { isStandardSticker, isGuildSticker } from "./StickersUtils";
import { can } from "../../utils/PermissionUtils";
let c6361_7;
const getStickerSendability = function getStickerSendability(stickerById, a1, channel) {
let r24;
if (a1 == null) {
return c6361_7.NONSENDABLE;
}
L29: {
const canUseCustomStickersEverywhere = PremiumUtils.canUseCustomStickersEverywhere(a1);
if (isStandardSticker(stickerById)) {
r24 = StickersPackStore.getStickerPack(stickerById.pack_id) == null ? c6361_7.NONSENDABLE : c6361_7.SENDABLE;
} else {
if (isGuildSticker(stickerById) && channel != null) {
r24 = GuildMemberStore.getSelfMember(stickerById.guild_id) == null ? c6361_7.NONSENDABLE : stickerById.available ? channel.guild_id != null && (channel.guild_id !== "" && channel.guild_id === stickerById.guild_id) ? c6361_7.SENDABLE : channel.guild_id != null && !can({
permission: Permissions.USE_EXTERNAL_STICKERS,
user: a1,
context: channel
}) ? c6361_7.NONSENDABLE : canUseCustomStickersEverywhere ? c6361_7.SENDABLE : c6361_7.SENDABLE_WITH_PREMIUM : c6361_7.SENDABLE_WITH_BOOSTED_GUILD;
break L29;
}
r24 = c6361_7.NONSENDABLE;
}
}
return r24;
};
c6361_7 = {
SENDABLE: 0,
0: "SENDABLE",
SENDABLE_WITH_PREMIUM: 1,
1: "SENDABLE_WITH_PREMIUM",
NONSENDABLE: 2,
2: "NONSENDABLE",
SENDABLE_WITH_BOOSTED_GUILD: 3,
3: "SENDABLE_WITH_BOOSTED_GUILD"
};
export { c6361_7 as StickerSendability };
export { getStickerSendability };
export function isSendableSticker(a0, a1, a2) {
return getStickerSendability(a0, a1, a2) === c6361_7.SENDABLE;
}
+222
View File
@@ -0,0 +1,222 @@
// Metro module 9620 (f9621).
import GatewayConnectionStore from "../gateway/GatewayConnectionStore";
import LocaleStore from "../user_settings/LocaleStore";
import GuildAvailabilityStore from "../../stores/GuildAvailabilityStore";
import UserStore from "../../stores/UserStore";
import StickersStore from "./StickersStore";
import { Endpoints } from "../../Constants";
import { MAX_FAVORITES, UserSettingsDelay } from "../user_settings/UserSettingsConstants";
import { httpGetWithCountryCodeQuery } from "../../utils/StoreUtils";
import { rejectWithMigratedError, HTTP } from "../../_bundle/sendRequest";
import Dispatcher from "../../Dispatcher";
import { isGuildSticker, isStandardSticker } from "./StickersUtils";
import InlineUploader from "../../lib/uploader_inline/InlineUploader";
import { FrecencyUserSettingsActionCreators } from "../user_settings/UserSettingsProtoActionCreators";
import Module12 from "../../_bundle/Module12";
import AlertActionCreators from "../../actions/AlertActionCreators";
import { intl, t } from "../../intl/index.native";
function $mk115512($env) {
return () => {
Dispatcher.dispatch({
type: "STICKER_PACKS_FETCH_START"
});
};
}
let $mk82917 = function() {
return (a0) => StickersStore.getStickerById(a0) != null;
};
let env6360 = {};
export async function fetchStickerPack(c26485_0, c26485_1) {
let c30123_0 = c26485_0;
let c30123_1 = c26485_1;
let c30123_2 = (await httpGetWithCountryCodeQuery({
url: Endpoints.STICKER_PACK(c26485_0),
rejectWithError: rejectWithMigratedError()
})).body;
Dispatcher.dispatch({
type: "STICKER_PACK_FETCH_SUCCESS",
packId: c30123_0,
pack: c30123_2,
ingestStickers: c30123_1
});
return c30123_2;
}
export async function fetchStickerPacks(c26486_0) {
let env30124;
const r12 = env6360;
let c26486_2 = r12;
const r10 = env30124 = {
$parent: r12
};
let c26486_1 = r10;
env30124[0] = void 0;
let r11 = c26486_0;
if (r11 === void 0) {
r11 = {};
}
let locale = r11.locale;
if (locale === void 0) {
locale = LocaleStore.locale;
}
env30124[0] = locale;
env30124[1] = void 0;
await void 0;
if (!StickersStore.isFetchingStickerPacks && !StickersStore.hasLoadedStickerPacks) {
Dispatcher.wait($mk115512(env6360));
env30124[1] = (await HTTP.get({
url: Endpoints.STICKER_PACKS,
query: {
locale: env30124[0]
},
rejectWithError: rejectWithMigratedError()
})).body.sticker_packs;
Dispatcher.dispatch({
type: "STICKER_PACKS_FETCH_SUCCESS",
packs: env30124[1]
});
}
}
export async function fetchSticker(c26487_0) {
let c30125_0 = (await HTTP.get({
url: Endpoints.STICKER(c26487_0),
rejectWithError: rejectWithMigratedError()
})).body;
if (isGuildSticker(c30125_0)) {
Dispatcher.dispatch({
type: "GUILD_STICKER_FETCH_SUCCESS",
sticker: c30125_0
});
} else {
if (!isStandardSticker(c30125_0)) {
throw new Error("Invalid sticker type");
}
Dispatcher.dispatch({
type: "PACK_STICKER_FETCH_SUCCESS",
sticker: c30125_0
});
}
}
export async function fetchGuildStickersWithCreator(c26488_0, signal) {
let env30126;
let c26488_3 = env6360;
const r28 = env30126 = {};
let c26488_2 = r28;
env30126[0] = c26488_0;
env30126[1] = void 0;
env30126[1] = (await HTTP.get({
url: Endpoints.GUILD_STICKER_PACKS(c26488_0),
rejectWithError: rejectWithMigratedError(),
signal
})).body;
Dispatcher.dispatch({
type: "GUILD_STICKERS_FETCH_SUCCESS",
guildId: env30126[0],
stickers: env30126[1].map((item) => item.user != null ? {
...item,
user_id: item.user.id,
user: item.user
} : item)
});
}
export async function deleteGuildSticker(c26489_0) {
await HTTP.del({
url: Endpoints.GUILD_STICKER(c26489_0.guild_id, c26489_0.id),
rejectWithError: rejectWithMigratedError()
});
}
export async function createGuildSticker(c26490_0) {
const guildId = c26490_0.guildId;
let c30127_0 = guildId;
let c30127_1 = await HTTP.post({
url: Endpoints.GUILD_STICKER_PACKS(guildId),
body: c26490_0.platform === "web" ? c26490_0.body : void 0,
fields: c26490_0.platform === "mobile" ? [{
name: "name",
value: c26490_0.name
}, {
name: "tags",
value: c26490_0.tags
}, {
name: "description",
value: c26490_0.description
}] : void 0,
attachments: c26490_0.platform === "mobile" ? [{
name: "file",
file: {
uri: c26490_0.uri,
name: c26490_0.name,
type: c26490_0.mimeType
}
}] : void 0,
headers: InlineUploader.buildHeadersForMd5(c26490_0.originalMd5),
rejectWithError: rejectWithMigratedError()
});
let user_id = void 0;
const currentUser = UserStore.getCurrentUser();
if (currentUser != null) {
user_id = currentUser.id;
}
Dispatcher.dispatch({
type: "GUILD_STICKERS_CREATE_SUCCESS",
guildId: c30127_0,
sticker: {
...c30127_1.body,
user_id
}
});
return c30127_1.body;
}
export async function updateGuildSticker(c26491_0, c26491_1, body) {
return (await HTTP.patch({
url: Endpoints.GUILD_STICKER(c26491_0, c26491_1),
body,
rejectWithError: rejectWithMigratedError()
})).body;
}
export function addStickerPreview(a0, a1, a2) {
Dispatcher.dispatch({
type: "ADD_STICKER_PREVIEW",
channelId: a0,
sticker: a1,
draftType: a2
});
}
export function clearStickerPreview(a0, a1) {
Dispatcher.dispatch({
type: "CLEAR_STICKER_PREVIEW",
channelId: a0,
draftType: a1
});
}
export function favoriteSticker(c17357_0) {
FrecencyUserSettingsActionCreators.updateAsync("favoriteStickers", (a0) => {
let r1;
const stickerIds = a0.stickerIds;
a0.stickerIds = GuildAvailabilityStore.totalUnavailableGuilds > 0 ? stickerIds : GatewayConnectionStore.isConnected() ? stickerIds.filter($mk82917()) : stickerIds;
if (Module12.size(a0.stickerIds) >= MAX_FAVORITES) {
AlertActionCreators.show({
title: intl.string(t["+XYXtZ"]),
body: intl.formatToPlainString(t.JaIyFi, {
count: MAX_FAVORITES
})
});
r1 = false;
} else {
const stickerIds2 = a0.stickerIds;
const r29 = stickerIds2.includes(c17357_0);
r1 = !r29;
if (!r29) {
a0.stickerIds.push(c17357_0);
r1 = void 0;
}
}
return r1;
}, UserSettingsDelay.INFREQUENT_USER_ACTION);
}
export function unfavoriteSticker(c17358_0) {
FrecencyUserSettingsActionCreators.updateAsync("favoriteStickers", (a0) => {
a0.stickerIds = a0.stickerIds.filter((stickerId) => stickerId !== c17358_0);
const stickerIds = a0.stickerIds;
a0.stickerIds = GuildAvailabilityStore.totalUnavailableGuilds > 0 ? stickerIds : GatewayConnectionStore.isConnected() ? stickerIds.filter($mk82917()) : stickerIds;
}, UserSettingsDelay.INFREQUENT_USER_ACTION);
}
+20
View File
@@ -0,0 +1,20 @@
// Metro module 3865 (f3866).
const r9 = {
ALWAYS_ANIMATE: 0,
0: "ALWAYS_ANIMATE",
ANIMATE_ON_INTERACTION: 1,
1: "ANIMATE_ON_INTERACTION",
NEVER_ANIMATE: 2,
2: "NEVER_ANIMATE"
};
export const STICKER_PICKER_TAB_PANEL_ID = "sticker-picker-tab-panel";
export const STICKER_PICKER_TAB_ID = "sticker-picker-tab";
export const GRID_NAVIGATOR_ID = "sticker-picker-grid";
export const INACTIVE_CATEGORY_INDEX = -1;
export const DEFAULT_STICKER_DIMENSIONS = 160;
export const STICKER_SEARCH_HEADER_HEIGHT = 56;
export const STICKER_APPLICATION_ID = "710982414301790216";
export const EMPTY_STATE_STICKERS = ["781323769960202280", "809209266556764241", "818597810047680532", "819129296374595614"];
export const MAX_STICKER_FILE_SIZE = 524288;
export const STAFF_MAX_STICKER_FILE_SIZE = 1572864;
export { r9 as StickerAnimationSettings };
+441
View File
@@ -0,0 +1,441 @@
// Metro module 9619 (f9620).
import { useMemo, useEffect, useState, useRef } from "react";
import GuildStore from "../../stores/GuildStore";
import SelectedGuildStore from "../../stores/SelectedGuildStore";
import SortedGuildStore from "../../stores/SortedGuildStore";
import UserStore from "../../stores/UserStore";
import StickersPersistedStore from "./StickersPersistedStore";
import StickersStore from "./StickersStore";
import { Permissions } from "../../Constants";
import { useStateFromStoresArray, useStateFromStoresObject, useStateFromStores } from "../../_bundle/Module589";
import { fetchStickerPacks, fetchStickerPack, fetchSticker } from "./StickersActionCreators";
import { AnimateStickers } from "../user_settings/UserSettings";
import * as _StickersUtils from "./StickersUtils";
import { createStickerPackCategory, isStandardSticker, shouldAnimateSticker } from "./StickersUtils";
import { getManageResourcePermissions } from "../permissions/useManageResourcePermissions";
import { StickerCategoryTypes, StickerGridItemTypes } from "./StickersTypes";
import { getTotalStickerCountForTier } from "../../utils/GuildBoostingUtils";
import { intl, t } from "../../intl/index.native";
import { can } from "../../utils/PermissionUtils";
import { useFrecencySettings } from "../user_settings/FrecencyUserSettingsHooks";
import { getStickerSendability, StickerSendability } from "./StickerSendability";
import { HermesBuiltin } from "../../_hermes/prelude";
function $mk82898($env) {
return () => {
const r3 = $env[0];
const r4 = $env.$parent;
return r3.map($mk106566(r4)).filter($mk106567(r4));
};
}
function $mk106566($env) {
return (a0) => $env[11].getStickerById(a0);
}
function $mk106567($env) {
return (a0) => {
let r1 = a0 != null;
if (r1) {
const r2 = $env;
const r4 = r2[0];
const r3 = r2[2];
const isGuildSticker = r4(r3[13]).isGuildSticker(a0);
r1 = isGuildSticker ? r4(r3[13]).isAvailableGuildSticker(a0) : !isGuildSticker;
}
return r1;
};
}
let c6359_13;
let $mk82897 = function() {
return () => {
fetchStickerPacks();
};
};
let env6359 = {};
export function useStickerPackCategories(a0) {
let packs, frequentlyUsedStickers, stateFromStores, memo;
let r12 = useFrecencySettings().favoriteStickers?.stickerIds;
if (r12 == null) {
r12 = c6359_13;
}
let env17350;
let context, stateFromStores2, stateFromStoresArray2, stateFromStores3;
const r23 = env17350 = {
$parent: env6359
};
env17350[0] = r12;
const stateFromStoresArray = useStateFromStoresArray([StickersStore], $mk82898(r23), [r12]);
const stateFromStoresObject = useStateFromStoresObject([StickersStore, StickersPersistedStore], () => ({
packs: StickersStore.getPremiumPacks(),
frequentlyUsedStickers: StickersPersistedStore.stickerFrecencyWithoutFetchingLatest.frequently
}), []);
packs = stateFromStoresObject.packs;
frequentlyUsedStickers = stateFromStoresObject.frequentlyUsedStickers;
stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
context = a0;
stateFromStores2 = void 0;
stateFromStoresArray2 = void 0;
stateFromStores3 = void 0;
stateFromStores2 = useStateFromStores([StickersStore], () => StickersStore.getAllGuildStickers());
stateFromStoresArray2 = useStateFromStoresArray([SortedGuildStore, GuildStore], () => {
const flattenedGuildIds = SortedGuildStore.getFlattenedGuildIds();
const r5 = [];
let c30119_0 = r5;
flattenedGuildIds.forEach((flattenedGuildId) => {
const guild = GuildStore.getGuild(flattenedGuildId);
if (guild != null) {
c30119_0.push(guild);
}
});
return r5;
}, []);
stateFromStores3 = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
memo = useMemo(() => {
const r0 = [];
for (const item of stateFromStoresArray2) {
const { name, id } = item;
const id2 = id;
const stickers = stateFromStores2.get(id);
if (stickers != null && stickers.length !== 0) {
r0.push({
type: StickerCategoryTypes.GUILD,
id: id2,
name,
stickers
});
}
}
if ((context == null ? void 0 : context.getGuildId()) != null) {
const guild = GuildStore.getGuild(context.getGuildId());
const canManageAllExpressions = getManageResourcePermissions(guild).canManageAllExpressions;
const r69 = r0.findIndex((item) => item.id === context.getGuildId());
if (r69 >= 1) {
r0.unshift(r0.splice(r69, 1)[0]);
} else if (r69 === -1 && guild != null && canManageAllExpressions) {
r0.unshift({
type: StickerCategoryTypes.EMPTY_GUILD_UPSELL,
id: guild.id,
name: guild.name,
stickers: []
});
}
if (stateFromStores3 != null) {
can({
permission: Permissions.USE_EXTERNAL_EMOJIS,
user: stateFromStores3,
context
});
}
}
return r0;
}, [stateFromStores2, stateFromStoresArray2, stateFromStores3, a0]);
return useMemo(() => {
const r18 = packs.map(createStickerPackCategory);
const r36 = [{
type: StickerCategoryTypes.FAVORITE,
id: StickerCategoryTypes.FAVORITE,
name: intl.string(t.y3LQCG),
stickers: stateFromStoresArray
}, ,];
const r41 = {
type: StickerCategoryTypes.RECENT,
id: StickerCategoryTypes.RECENT,
name: intl.string(t["6hjpXW"]),
stickers: null
};
let stickers = frequentlyUsedStickers == null ? void 0 : frequentlyUsedStickers.filter((frequentlyUsedSticker) => {
let r19;
if (_StickersUtils.isGuildSticker(frequentlyUsedSticker)) {
const stickersByGuildId = StickersStore.getStickersByGuildId(frequentlyUsedSticker.guild_id);
let r25 = stickersByGuildId == null ? void 0 : stickersByGuildId.some((item) => item.id === frequentlyUsedSticker.id);
if (r25 == null) {
r25 = false;
}
if (r25) {
r25 = getStickerSendability(frequentlyUsedSticker, stateFromStores, a0) !== StickerSendability.NONSENDABLE;
}
r19 = r25;
} else {
r19 = isStandardSticker(frequentlyUsedSticker) ? packs.some((pack) => pack.id === frequentlyUsedSticker.pack_id) : void 0;
}
return r19;
});
if (stickers == null) {
stickers = [];
}
r41.stickers = stickers;
r36[1] = r41;
HermesBuiltin.arraySpread(r36, r18, HermesBuiltin.arraySpread(r36, memo, 2));
return r36;
}, [packs, stateFromStoresArray, frequentlyUsedStickers, memo, stateFromStores, a0]);
}
c6359_13 = [];
export function useFetchStickerPack(a0) {
useEffect($mk82897(), []);
const stateFromStores4 = useStateFromStores([StickersStore], () => StickersStore.hasLoadedStickerPacks);
useEffect(() => {
let r2 = stateFromStores4;
if (stateFromStores4) {
r2 = StickersStore.getStickerPack(a0) == null;
}
if (r2) {
fetchStickerPack(a0);
}
}, [a0, stateFromStores4]);
}
export function useShouldAnimateSticker(a0) {
return shouldAnimateSticker(AnimateStickers.useSetting(), a0);
}
export function useStickersGrid(a0) {
const { collapsedStickersCategories, filteredStickers, listPaddingRight = 0 } = a0;
let c17353_2 = listPaddingRight;
let listWidth = a0.listWidth;
if (listWidth === void 0) {
listWidth = 0;
}
let c17353_3 = listWidth;
let stickerNodeMargin = a0.stickerNodeMargin;
if (stickerNodeMargin === void 0) {
stickerNodeMargin = 0;
}
let c17353_4 = stickerNodeMargin;
const { stickerNodeWidth, stickersCategories } = a0;
return useMemo(() => {
const r6 = Math;
const r1 = c17353_3 - c17353_2;
const r36 = r6.floor((r1 + c17353_4) / (stickerNodeWidth + c17353_4));
let c26484_0 = r36;
const gutterWidth = Math.floor(Math.max(c17353_4, (c17353_3 - c17353_2 - stickerNodeWidth * r36) / (r36 - 1)));
const columnCounts = [];
let c26484_1 = columnCounts;
const rowCountBySection = [];
let c26484_2 = rowCountBySection;
const stickersGrid = [];
let c26484_3 = stickersGrid;
let rowCount = 0;
let gridSectionIndex = 0;
let visibleRowIndex = 0;
if (c17353_3 !== 0) {
const addGridSection = function addGridSection(a0, category, r8 = false) {
const r28 = _StickersUtils.isGuildSticker(a0[0]) ? GuildStore.getGuild(a0[0].guild_id) : void 0;
const canCreateExpressions = getManageResourcePermissions(r28).canCreateExpressions;
const guildId = SelectedGuildStore.getGuildId();
const r14 = stickersCategories.findIndex((stickersCategory) => stickersCategory.type === StickerCategoryTypes.FAVORITE);
const r44 = stickersCategories.findIndex((stickersCategory) => stickersCategory.type === StickerCategoryTypes.RECENT);
const length = a0.length;
const r53 = r28 != null && guildId === r28.id && canCreateExpressions && a0.length < getTotalStickerCountForTier(r28.premiumTier) ? length + 1 : length;
const r60 = Math.ceil(r53 / c26484_0);
c26484_2[gridSectionIndex] = r8 ? 0 : r60;
const r63 = 0 < r60;
let r64 = 0;
if (r63) {
do {
const r1 = r64 * c26484_0;
const r71 = a0.slice(r1, r1 + c26484_0).map((item, index) => ({
type: StickerGridItemTypes.STICKER,
sticker: item,
packId: isStandardSticker(item) ? item.pack_id : "TODO - fix",
gridSectionIndex,
rowIndex: rowCount,
columnIndex: index,
visibleRowIndex,
category
}));
let r73 = gridSectionIndex > r44;
const r74 = r64;
if (r73) {
r73 = gridSectionIndex > r14;
}
if (r73) {
r73 = r28 != null;
}
if (r73) {
r73 = r53 > a0.length;
}
if (r73) {
r71.push({
type: StickerGridItemTypes.CREATE_STICKER,
guild_id: r28.id,
name: intl.string(t["UwF+Cw"]),
gridSectionIndex,
rowIndex: rowCount,
columnIndex: r71.length,
visibleRowIndex
});
}
if (!r8) {
visibleRowIndex = visibleRowIndex + 1;
c26484_3.push(r71);
c26484_1.push(r71.length);
}
rowCount = rowCount + 1;
r64 = r74 + 1;
} while (r64 < r60);
}
gridSectionIndex = gridSectionIndex + 1;
};
if (filteredStickers == null) {
for (const stickersCategory of stickersCategories) {
const r83 = stickersCategory;
if (stickersCategory.stickers.length > 0) {
rowCount = rowCount + 1;
addGridSection(r83.stickers, r83.type, (collapsedStickersCategories == null ? void 0 : collapsedStickersCategories.has(r83.id)) === true);
} else if (r83.type === StickerCategoryTypes.EMPTY_GUILD_UPSELL) {
rowCountBySection[gridSectionIndex] = 0;
gridSectionIndex = gridSectionIndex + 1;
}
}
} else {
if (filteredStickers.sendable.length > 0) {
addGridSection(filteredStickers.sendable, StickerCategoryTypes.SEARCH_RESULTS);
}
if (filteredStickers.sendableWithPremium.length > 0) {
addGridSection(filteredStickers.sendableWithPremium, StickerCategoryTypes.SEARCH_RESULTS);
}
}
}
return {
rowCount,
rowCountBySection,
stickersGrid,
gutterWidth,
columnCounts
};
}, [collapsedStickersCategories, filteredStickers, listPaddingRight, listWidth, stickerNodeMargin, stickerNodeWidth, stickersCategories]);
}
export function useHasSendableSticker() {
return true;
}
export function useFetchStickerPacks() {
useEffect($mk82897(), []);
}
export function useFavoriteStickerIds() {
let r11 = useFrecencySettings().favoriteStickers?.stickerIds;
if (r11 == null) {
r11 = c6359_13;
}
return r11;
}
export function useFavoriteStickers() {
let r8 = useFrecencySettings().favoriteStickers?.stickerIds;
if (r8 == null) {
r8 = c6359_13;
}
let env17348;
const r12 = env17348 = {
$parent: env6359
};
env17348[0] = r8;
return useStateFromStoresArray([StickersStore], $mk82898(r12), [r8]);
}
export function useLatestFrecentStickerIds() {
const frecencySettings = useFrecencySettings();
let r11 = c6359_13;
if ((frecencySettings == null ? void 0 : frecencySettings.stickerFrecency?.stickers) != null) {
r11 = Object.keys(frecencySettings == null ? void 0 : frecencySettings.stickerFrecency?.stickers);
}
return r11;
}
export function useLatestFrecentStickers() {
const frecencySettings = useFrecencySettings();
let r8 = c6359_13;
if ((frecencySettings == null ? void 0 : frecencySettings.stickerFrecency?.stickers) != null) {
r8 = Object.keys(frecencySettings == null ? void 0 : frecencySettings.stickerFrecency?.stickers);
}
let c17354_0 = r8;
return useStateFromStoresArray([StickersStore], () => c17354_0.map((item) => StickersStore.getStickerById(item)).filter((item) => item !== void 0), [r8]);
}
export function useStickerForRenderableSticker(a0) {
let r48;
let setState, setState2, current, ref;
let r11 = arguments[1];
if (r11 === void 0) {
r11 = false;
}
let c17355_1 = r11;
setState = void 0;
setState2 = void 0;
current = void 0;
ref = void 0;
const stateFromStores5 = useStateFromStores([StickersStore], () => StickersStore.getStickerById(a0.id));
let shouldFetch;
[shouldFetch, setState] = useState(true);
let hasFetched;
[hasFetched, setState2] = useState(false);
const isReturnable = _StickersUtils.isGuildSticker(a0) || isStandardSticker(a0);
current = {
hasFetched,
isReturnable,
renderableSticker: a0,
shouldFetch,
stickersStoreDefinition: stateFromStores5
};
ref = useRef(current);
useEffect(() => {
ref.current = current;
});
useEffect(() => {
(async () => {
let c30122_2 = 0;
L18: {
L17: {
try {
const current2 = ref.current;
const { hasFetched, isReturnable, renderableSticker, shouldFetch, stickersStoreDefinition } = current2;
if (!c17355_1) {
break L18;
}
if (isReturnable) {
break L18;
}
if (stickersStoreDefinition != null) {
break L18;
}
if (!shouldFetch) {
break L18;
}
if (hasFetched) {
break L18;
}
setState(false);
c30122_2 = 1;
await fetchSticker(renderableSticker.id);
c30122_2 = 0;
(0, setState2)(true);
} catch ($e) {
let r26 = $e;
if (c30122_2 !== 0) {
while (true) {
try {
c30122_2 = 0;
(0, setState2)(true);
break L17;
} catch ($e) {
r26 = $e;
if (c30122_2 === 0) {
break;
}
}
}
}
throw r26;
}
}
return void 0;
}
})();
}, [r11]);
if (isReturnable) {
r48 = [a0, hasFetched];
} else {
let r47 = stateFromStores5;
if (r47 == null) {
r47 = null;
}
r48 = [r47, hasFetched];
}
return r48;
}
export function useFilteredStickerPackCategories(a0) {
const stickerPackCategories = useStickerPackCategories(a0);
let c17356_0 = stickerPackCategories;
return useMemo(() => c17356_0.filter((item) => item.type === StickerCategoryTypes.EMPTY_GUILD_UPSELL || item.stickers.length > 0, []), [stickerPackCategories]);
}
+140
View File
@@ -0,0 +1,140 @@
// Metro module 5094 (f5095).
import _slicedToArray from "../../_bundle/_slicedToArray";
import { TypeTag } from "../../_bundle/Module1413";
import { LibdiscoreStore } from "../libdiscore/stores/LibdiscoreStore";
import Durations from "../../utils/Durations";
import { StickerMetadataTypes } from "./StickersTypes";
let c3061_4, c3061_5, HOUR, deriveStickerMetadata, ingestStickerPack, $mk75383 = function() {
return function parsePackStickers(a0) {
const r0 = {};
for (const item of a0) {
r0[item.id] = parseServerPackSticker(item);
}
return r0;
};
};
const parseServerPackSticker = function parseServerPackSticker(item) {
const r0 = {
id: item.id,
tags: item.tags,
type: item.type,
name: item.name,
description: item.description,
format_type: item.format_type,
pack_id: item.pack_id
};
r0[TypeTag] = "PackSticker";
return r0;
};
deriveStickerMetadata = function deriveStickerMetadata(a0, a1) {
const r2 = [];
r2.push({
type: StickerMetadataTypes.STICKER_NAME,
value: a0.name.trim().toLocaleLowerCase()
});
if (a1 != null) {
r2.push({
type: StickerMetadataTypes.PACK_NAME,
value: a1.name
});
}
return r2;
};
ingestStickerPack = function ingestStickerPack(item, packStickersDatabase, packsDatabase, premiumPacksDatabase, a4) {
packsDatabase.set(item.id, item);
premiumPacksDatabase.set(item.id, item);
const setPartition = packStickersDatabase.setPartition;
const { id, stickers } = item;
setPartition.call(packStickersDatabase, id, $mk75383()(stickers));
};
c3061_4 = false;
c3061_5 = null;
HOUR = Durations.Millis.HOUR;
class StickersPackStore extends LibdiscoreStore {
static displayName = "StickersPackStore";
packsDatabase = this.addKVDatabase("stickerPacks");
packStickersDatabase = this.addKKVDatabase("packStickers");
packStickerByIdIndex = this.packStickersDatabase.addSecondaryKVIndex("id");
premiumPacksDatabase = this.addKVDatabase("premiumPacks");
getAllPackStickers = this.packStickersDatabase.memoized((a0) => {
const map = new Map();
for (const key in a0) {
map.set(key, Object.values(a0[key].root));
}
return map;
});
getStickerMetadataMap = this.packStickersDatabase.memoized((a0) => {
const map = new Map();
for (const key in a0) {
for (const item of Object.entries(a0[key].root)) {
const r44 = _slicedToArray(item, 2);
map.set(r44[0], deriveStickerMetadata(r44[1], this.packsDatabase.get(key)));
}
}
return map;
});
getPremiumPacks = this.premiumPacksDatabase.memoized((a0) => Object.values(a0));
stateWrapper() {
return {
packsDatabase: this.packsDatabase,
packStickersDatabase: this.packStickersDatabase,
premiumPacksDatabase: this.premiumPacksDatabase,
markDirty: () => this.markDirty(),
clearAllDBs: () => this.clearAllDatabases()
};
}
get isFetchingStickerPacks() {
return c3061_4;
}
get hasLoadedStickerPacks() {
return c3061_5 != null && c3061_5 + HOUR > performance.now();
}
getStickerById(a0) {
return this.packStickerByIdIndex.get(a0);
}
isPremiumPack(a0) {
return this.premiumPacksDatabase.get(a0) != null;
}
getStickerPack(a0) {
return this.packsDatabase.get(a0);
}
}
const stickersPackStore = new StickersPackStore({
LOGOUT: (a0, a1) => {
(0, a1.clearAllDBs)();
},
STICKER_PACK_FETCH_SUCCESS: ({ pack }, a1) => {
const { packStickersDatabase, packsDatabase } = a1;
a1.premiumPacksDatabase;
packsDatabase.set(pack.id, pack);
const { id, stickers } = pack;
packStickersDatabase.setPartition(id, $mk75383()(stickers));
},
STICKER_PACKS_FETCH_START: (a0, { markDirty: markDirty2 }) => {
c3061_4 = true;
markDirty2();
},
STICKER_PACKS_FETCH_SUCCESS: ({ packs }, { packStickersDatabase, packsDatabase, premiumPacksDatabase, markDirty: markDirty2 }) => {
c3061_4 = false;
markDirty2();
c3061_5 = performance.now();
for (const item of packs) {
ingestStickerPack(item, packStickersDatabase, packsDatabase, premiumPacksDatabase, true);
}
},
PACK_STICKER_FETCH_SUCCESS: ({ sticker }, { packStickersDatabase }) => {
const { pack_id, id } = sticker;
const r9 = {
id: sticker.id,
tags: sticker.tags,
type: sticker.type,
name: sticker.name,
description: sticker.description,
format_type: sticker.format_type,
pack_id: sticker.pack_id
};
r9[TypeTag] = "PackSticker";
packStickersDatabase.setRecord(pack_id, id, r9);
}
});
export default stickersPackStore;
@@ -0,0 +1,83 @@
// Metro module 5091 (f5092).
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
import StickersStore from "./StickersStore";
import { UserSettingsTypes } from "../user_settings/UserSettingsConstants";
import Durations from "../../utils/Durations";
import Frecency from "../../lib/Frecency";
import Module12 from "../../_bundle/Module12";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c3058_5, c3058_6, handleUserSettingsProtoStoreChange;
const handleStickersStoreUpdate = function handleStickersStoreUpdate() {
if (StickersStore.isLoaded) {
c3058_6.compute();
}
};
handleUserSettingsProtoStoreChange = function handleUserSettingsProtoStoreChange() {
const stickers = UserSettingsProtoStore.frecencyWithoutFetchingLatest.stickerFrecency?.stickers;
if (stickers == null) {
return false;
}
c3058_6.overwriteHistory(Module12.mapValues(stickers, (a0) => ({
...a0,
recentUses: a0.recentUses.map(Number).filter((item) => item > 0)
})), c3058_5.pendingUsages);
};
c3058_5 = {
pendingUsages: []
};
const DAY = Durations.Millis.DAY;
c3058_6 = new Frecency({
computeBonus: () => 100,
lookupKey: (a0) => StickersStore.getStickerById(a0),
afterCompute: () => {},
numFrequentlyItems: 20
});
class StickersPersistedStore extends Module589.PersistedStore {
static displayName = "StickersPersistedStore";
static persistKey = "StickersPersistedStoreV2";
initialize(a0) {
this.waitFor(StickersStore, UserSettingsProtoStore);
if (a0 != null) {
c3058_5 = a0;
}
this.syncWith([StickersStore], handleStickersStoreUpdate);
this.syncWith([UserSettingsProtoStore], handleUserSettingsProtoStoreChange);
}
getState() {
return c3058_5;
}
hasPendingUsage() {
return c3058_5.pendingUsages.length > 0;
}
get stickerFrecencyWithoutFetchingLatest() {
return c3058_6;
}
}
const stickersPersistedStore = new StickersPersistedStore(Dispatcher, {
STICKER_TRACK_USAGE: function handleStickersUsage({ stickerIds }) {
if (stickerIds != null) {
stickerIds.forEach((stickerId) => {
c3058_6.track(stickerId);
c3058_5.pendingUsages.push({
key: stickerId,
timestamp: Date.now()
});
});
}
if (StickersStore.isLoaded) {
c3058_6.compute();
}
},
USER_SETTINGS_PROTO_UPDATE: function handleUserSettingsProtoUpdate(a0) {
const type = a0.settings.type;
const wasSaved = a0.wasSaved;
if (type === UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS && wasSaved) {
c3058_5.pendingUsages = [];
return void 0;
}
return false;
}
});
export default stickersPersistedStore;
export { DAY as STICKER_PACK_NEW_TIMESTAMP_THRESHOLD };
+12
View File
@@ -0,0 +1,12 @@
// Metro module 9626 (f9627).
import AutocompleteUtils from "../../utils/AutocompleteUtils";
import { StickerSendability } from "./StickerSendability";
export function searchAllStickers(a0) {
return AutocompleteUtils.queryStickers([a0], true).map((item) => item.sticker);
}
export function searchSendableStickers(a0, a1) {
return AutocompleteUtils.queryStickers([a0], true, [a1, (a0, a1) => a1 === StickerSendability.SENDABLE]).map((item) => item.sticker);
}
export function searchUnsendableStickers(a0, a1) {
return AutocompleteUtils.queryStickers([a0], true, [a1, (a0, a1) => a1 !== StickerSendability.SENDABLE]).map((item) => item.sticker);
}
+127
View File
@@ -0,0 +1,127 @@
// Metro module 5092 (f5093).
import GuildMembershipStore from "../../stores/GuildMembershipStore";
import GuildStore from "../../stores/GuildStore";
import GuildStickersStore from "./GuildStickersStore";
import StickersPackStore from "./StickersPackStore";
import DatabaseDaos from "../app_database/DatabaseDaos";
import { tryLoadOrResetCacheGatewayAsync } from "../app_database/app/TryLoad";
import Module10 from "../../_bundle/Module10";
import GuildStickers from "../app_database/modules/GuildStickers";
import Dispatcher from "../../Dispatcher";
import Module589 from "../../_bundle/Module589";
let c3059_8, c3059_12;
let env3059 = {};
const loadSavedGuildStickers = async function loadSavedGuildStickers() {
let c25327_0, c25327_1;
L15: {
L14: {
let env29449;
const r10 = env3059;
c25327_1 = r10;
const r25 = env29449 = {
$parent: r10
};
c25327_0 = r25;
env29449[0] = void 0;
env29449[1] = void 0;
const r14 = env3059[9];
if (r14 !== c3059_8.Unloaded) {
break L15;
}
const r32 = DatabaseDaos.database();
env29449[0] = r32;
if (r32 != null) {
env3059[9] = c3059_8.Loaded;
env29449[1] = await tryLoadOrResetCacheGatewayAsync("StickerStore.loadSavedGuildStickers", () => Module10.timeAsync("💾", "loadSavedGuildStickers", () => GuildStickers.getAsync(env29449[0])));
if (env29449[1] == null) {
break L14;
}
Dispatcher.dispatch({
type: "CACHED_STICKERS_LOADED",
stickers: env29449[1]
});
break L14;
}
break L15;
}
return void 0;
}
};
c3059_8 = {
Unloaded: 0,
0: "Unloaded",
Loaded: 1,
1: "Loaded"
};
env3059[9] = c3059_8.Unloaded;
class StickersStore extends Module589.Store {
static displayName = "StickersStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(GuildMembershipStore, GuildStickersStore, GuildStore, StickersPackStore);
this.syncWith([GuildStickersStore, StickersPackStore], () => true);
}
get isLoaded() {
return env3059[9] !== c3059_8.Unloaded;
}
get loadState() {
return env3059[9];
}
getStickerMetadataArrays() {
loadSavedGuildStickers();
return [GuildStickersStore.getStickerMetadataMap(), StickersPackStore.getStickerMetadataMap()];
}
get hasLoadedStickerPacks() {
return StickersPackStore.hasLoadedStickerPacks;
}
get isFetchingStickerPacks() {
return StickersPackStore.isFetchingStickerPacks;
}
getStickerById(a0) {
loadSavedGuildStickers();
let r7 = GuildStickersStore.getStickerById(a0);
if (r7 == null) {
r7 = StickersPackStore.getStickerById(a0);
}
return r7;
}
getStickerPack(a0) {
return StickersPackStore.getStickerPack(a0);
}
getPremiumPacks() {
return StickersPackStore.getPremiumPacks();
}
isPremiumPack(a0) {
return StickersPackStore.isPremiumPack(a0);
}
getRawStickersByGuild() {
return GuildStickersStore.getAllGuildStickers();
}
getAllGuildStickers() {
loadSavedGuildStickers();
return GuildStickersStore.getAllGuildStickers();
}
getAllPackStickers() {
return StickersPackStore.getAllPackStickers();
}
getStickersByGuildId(a0) {
loadSavedGuildStickers();
return GuildStickersStore.getStickersByGuildId(a0);
}
}
c3059_12 = StickersStore;
const r74 = new StickersStore(Dispatcher, {
BACKGROUND_SYNC: function handleBackgroundSync() {
env3059[9] = c3059_8.Unloaded;
},
CONNECTION_OPEN: function handleConnectionOpen(a0) {
const guilds = a0.guilds;
env3059[9] = a0.unavailableGuilds.length === 0 && guilds.every((guild) => guild.stickers.op === "full_sync") ? c3059_8.Loaded : c3059_8.Unloaded;
},
LOGOUT: function handleLogout() {
env3059[9] = c3059_8.Unloaded;
}
});
export default r74;
@@ -0,0 +1,9 @@
// Metro module 4858 (f4859).
let c2991_0 = /(!|\.|;|,|-|—|–|\?|"|')/g;
let c2991_1 = /(\n|\t|\s)/g;
export function removePunctuation(a0) {
return a0.replace(c2991_0, "").replace(c2991_1, " ");
}
export function getQueriesFromUserInput(a0) {
return a0 == null ? [] : a0.replace(c2991_0, "").replace(c2991_1, " ").trim().split(" ");
}
+60
View File
@@ -0,0 +1,60 @@
// Metro module 4856 (f4857).
import { TypeTag } from "../../_bundle/Module1413";
import * as _Module4857 from "../../_bundle/Module4857";
TypeTag;
const r11 = {
PNG: "png",
APNG: "png",
LOTTIE: "json",
WEBP: "webp",
GIF: "gif"
};
const r26 = {
STICKER: 0,
0: "STICKER",
CREATE_STICKER: 1,
1: "CREATE_STICKER"
};
const r29 = {
PACK: "PACK",
FAVORITE: "FAVORITE",
RECENT: "RECENT",
SEARCH_RESULTS: "SEARCH_RESULTS",
SEARCH_SUGGESTIONS: "SEARCH_SUGGESTIONS",
GUILD: "GUILD",
EMPTY_GUILD_UPSELL: "EMPTY_GUILD_UPSELL",
CREATE_STICKER: "CREATE_STICKER"
};
const r37 = {
STICKER_NAME: 0,
0: "STICKER_NAME",
TAG: 1,
1: "TAG",
CORRELATED_EMOJI: 2,
2: "CORRELATED_EMOJI",
GUILD_NAME: 3,
3: "GUILD_NAME",
PACK_NAME: 4,
4: "PACK_NAME"
};
const r44 = {
STICKER_PICKER: 0,
0: "STICKER_PICKER",
AUTOCOMPLETE: 1,
1: "AUTOCOMPLETE",
BUILT_IN_INTEGRATION: 2,
2: "BUILT_IN_INTEGRATION"
};
export const StickerFormat = _Module4857.StickerFormat;
export const MetaStickerType = _Module4857.MetaStickerType;
export { r11 as StickerExtensions };
export function isAnimatedSticker(a0) {
return a0 !== _Module4857.StickerFormat.PNG;
}
export function isCustomSticker(a0) {
return a0 !== _Module4857.MetaStickerType.STANDARD;
}
export { r26 as StickerGridItemTypes };
export { r29 as StickerCategoryTypes };
export { r37 as StickerMetadataTypes };
export { r44 as StickerSelectLocation };
+192
View File
@@ -0,0 +1,192 @@
// Metro module 4524 (f4525).
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
import GuildStore from "../../stores/GuildStore";
import UploadAttachmentStore from "../../stores/UploadAttachmentStore";
import StickerMessagePreviewStore from "./StickerMessagePreviewStore";
import { DEFAULT_STICKER_DIMENSIONS, STICKER_APPLICATION_ID, StickerAnimationSettings } from "./StickersConstants";
import { Endpoints } from "../../Constants";
import { StickerFormat, StickerExtensions, StickerCategoryTypes, StickerSelectLocation, MetaStickerType } from "./StickersTypes";
import { SUPPORTS_WEBP } from "../../utils/AvatarUtils";
import { getForceSdrEmojisStickersConfig } from "../image_upload/ForceSdrEmojisStickersExperiment";
import { isAndroid, isWeb } from "../../utils/PlatformUtils";
import { getBestMediaProxySize, getDevicePixelRatio } from "../image_upload/ImageLoaderUtils";
import { getQueriesFromUserInput } from "./StickersSuggestionUtils";
function $mk74719($env) {
return (a0) => a0.id === $env[0].cover_sticker_id;
}
let API_ENDPOINT, MEDIA_PROXY_ENDPOINT, PROJECT_ENV, ASSET_ENDPOINT, CDN_HOST, c2731_15, c2731_16, c2731_18;
const getStickerExtensionFromFormatType = function getStickerExtensionFromFormatType(format_type) {
if (StickerFormat.PNG === format_type) {
return SUPPORTS_WEBP ? StickerExtensions.WEBP : StickerExtensions.PNG;
}
if (StickerFormat.APNG === format_type) {
return StickerExtensions.APNG;
}
if (StickerFormat.LOTTIE === format_type) {
return StickerExtensions.LOTTIE;
}
if (StickerFormat.GIF === format_type) {
return StickerExtensions.GIF;
}
throw new Error(`Unexpected format type: ${format_type}`);
};
const GLOBAL_ENV = window.GLOBAL_ENV;
API_ENDPOINT = GLOBAL_ENV.API_ENDPOINT;
MEDIA_PROXY_ENDPOINT = GLOBAL_ENV.MEDIA_PROXY_ENDPOINT;
PROJECT_ENV = GLOBAL_ENV.PROJECT_ENV;
ASSET_ENDPOINT = GLOBAL_ENV.ASSET_ENDPOINT;
CDN_HOST = GLOBAL_ENV.CDN_HOST;
const r64 = decodeURIComponent(Endpoints.STICKER_ASSET("[\\d]+", `(${Object.values(StickerExtensions).join("|")})`));
c2731_15 = new RegExp(`(${location.protocol}${ASSET_ENDPOINT}|${location.protocol}${MEDIA_PROXY_ENDPOINT})(${r64})`, "ig");
c2731_16 = new RegExp(`${location.protocol}${API_ENDPOINT}(${r64})`, "ig");
c2731_18 = [];
export function getStickerPackPreviewSticker(a0) {
let env14293;
const r1 = env14293 = {};
env14293[0] = a0;
if (a0.cover_sticker_id != null) {
const r7 = a0.stickers.find($mk74719(r1));
if (r7 != null) {
return r7;
}
}
return a0.stickers[0];
}
export { getStickerExtensionFromFormatType };
export function getStickerFormatTypeFromFileType(a0) {
if (a0 === "application/json") {
return StickerFormat.LOTTIE;
}
if (a0 === "image/apng") {
return StickerFormat.APNG;
}
if (a0 !== "image/png" && a0 !== "image/webp") {
if (a0 === "image/gif") {
return StickerFormat.GIF;
}
throw new Error(`Unexpected file type: ${a0}`);
}
return StickerFormat.PNG;
}
export function getFilenameForSticker(a0) {
return a0 != null ? `${a0.name}.${getStickerExtensionFromFormatType(a0.format_type)}` : null;
}
export function getStickerTagForEmoji(a0) {
return a0.id != null ? a0.id : a0.optionallyDiverseSequence;
}
export const getStickerAssetUrl = function(a0, r0 = {}) {
let enabled;
const { isPreview = false, size = DEFAULT_STICKER_DIMENSIONS } = r0;
if (a0.format_type == null) {
return null;
}
let format_type = a0.format_type;
if (a0.format_type === StickerFormat.GIF && isPreview) {
format_type = StickerFormat.PNG;
}
const stickerExtensionFromFormatType = getStickerExtensionFromFormatType(format_type);
const r39 = Endpoints.STICKER_ASSET(a0.id, stickerExtensionFromFormatType);
try {
enabled = (0, getForceSdrEmojisStickersConfig)({
location: "sticker_url"
}).enabled;
} catch ($e) {}
const r11 = enabled ? "&force_sdr=true" : "";
const r10 = stickerExtensionFromFormatType === StickerExtensions.WEBP ? "&quality=lossless" : "";
if (PROJECT_ENV !== "development") {
if (a0.format_type === StickerFormat.LOTTIE) {
return `${location.protocol}${ASSET_ENDPOINT}${r39}`;
}
const r85 = a0.format_type === StickerFormat.APNG ? isPreview ? isAndroid() ? "" : "&passthrough=false" : "" : "";
return `${location.protocol}${MEDIA_PROXY_ENDPOINT}${r39}?size=${getBestMediaProxySize(size * Math.min(2, getDevicePixelRatio()))}${r85}${r10}${r11}`;
}
if (a0.format_type === StickerFormat.LOTTIE && isWeb()) {
return r39;
}
const r69 = `${location.protocol}${MEDIA_PROXY_ENDPOINT}${r39}`;
return enabled ? `${r69}?force_sdr=true` : r69;
};
export function getStickerPackBannerAssetUrl({ banner_asset_id }, a1) {
if (banner_asset_id == null) {
return null;
}
const r12 = SUPPORTS_WEBP ? "webp" : "png";
const r31 = CDN_HOST != null ? `https://${CDN_HOST}/app-assets/${STICKER_APPLICATION_ID}/store/${banner_asset_id}.${r12}` : `${location.protocol}${API_ENDPOINT}${Endpoints.STORE_ASSET(STICKER_APPLICATION_ID, banner_asset_id, r12)}`;
return a1 != null ? r31 + `?size=${getBestMediaProxySize(a1)}` : r31;
}
export function isStickerAssetUrl(a0) {
return a0.match.call(a0, PROJECT_ENV !== "development" ? c2731_15 : c2731_16) != null;
}
export function isStickerPackAnimated(a0) {
return a0.stickers.some(({ format_type }) => format_type === StickerFormat.APNG || format_type === StickerFormat.LOTTIE || format_type === StickerFormat.GIF);
}
export function createStickerPackCategory(a0) {
let previewSticker;
let env14294;
const r14 = env14294 = {};
env14294[0] = a0;
if (a0.cover_sticker_id != null) {
previewSticker = a0.stickers.find($mk74719(r14));
if (previewSticker == null) {
previewSticker = a0.stickers[0];
}
} else {
previewSticker = a0.stickers[0];
}
return {
type: StickerCategoryTypes.PACK,
id: a0.id,
name: a0.name,
stickers: a0.stickers,
previewSticker
};
}
export function shouldAnimateSticker(a0, a1) {
return a0 !== StickerAnimationSettings.ANIMATE_ON_INTERACTION ? a0 !== StickerAnimationSettings.NEVER_ANIMATE : a1;
}
export function shouldAttachSticker(a0, a1, a2, a3) {
if (UploadAttachmentStore.getUploadCount(a2, a3) > 0) {
return true;
}
const stickerPreview = StickerMessagePreviewStore.getStickerPreview(a2, a3);
if (stickerPreview != null && stickerPreview.length > 0) {
return true;
}
if (StickerSelectLocation.STICKER_PICKER === a0) {
return a1.trim() !== "";
}
if (StickerSelectLocation.AUTOCOMPLETE === a0) {
return getQueriesFromUserInput(a1).length > 1;
}
StickerSelectLocation.BUILT_IN_INTEGRATION;
return false;
}
export function isGuildSticker(a0) {
return a0.type === MetaStickerType.GUILD;
}
export function isStandardSticker(a0) {
return a0.type === MetaStickerType.STANDARD;
}
export function getMessageStickers(a0) {
return a0.stickerItems.length > 0 ? a0.stickerItems : a0.stickers.length > 0 ? a0.stickers : [];
}
export function isAvailableGuildSticker(a0) {
if (a0 === null) {
return false;
}
return GuildStore.getGuild(a0.guild_id) !== void 0;
}
export function getFavoriteStickerIds() {
let r6 = UserSettingsProtoStore.frecencyWithoutFetchingLatest.favoriteStickers?.stickerIds;
if (r6 == null) {
r6 = c2731_18;
}
return r6;
}
export function isFavoriteSticker(a0) {
let r4 = UserSettingsProtoStore.frecencyWithoutFetchingLatest.favoriteStickers?.stickerIds;
if (r4 == null) {
r4 = c2731_18;
}
return r4.includes(a0);
}
@@ -0,0 +1,49 @@
// Metro module 7781 (f7782).
import Module19, { useEffect, useRef } from "react";
import { requireNativeComponent } from "react-native";
import { isAndroid } from "../../../utils/PlatformUtils";
import Module7782 from "../../../_bundle/Module7782";
import codegenNativeCommands from "../../../_bundle/codegenNativeCommands";
const NativeLottieNode = isAndroid() ? Module7782 : requireNativeComponent("NativeLottieNode");
let c4902_5 = codegenNativeCommands({
supportedCommands: ["setup"]
});
let c4902_6 = {
LOOP: 0,
0: "LOOP",
STILL: 1,
1: "STILL",
ONCE: 2,
2: "ONCE"
};
export default function NativeLottieView(props) {
const { asset, url, width, height, opacity = 1, renderMode = c4902_6.LOOP } = props;
const LOOP = renderMode;
const { animating = true, accessibilityLabel } = props;
const ref = Module19.useRef(null);
const current = {
asset,
url,
width,
height,
animating,
accessibilityLabel
};
const ref2 = useRef(current);
useEffect(() => {
ref2.current = current;
});
useEffect(() => {
const current2 = ref2.current;
const { asset, url, width, height, animating, accessibilityLabel } = current2;
if (url !== "" && width !== 0 && height !== 0) {
c4902_5.setup(ref.current, asset, url, width, height, LOOP, animating, accessibilityLabel);
}
}, [LOOP]);
return <NativeLottieNode ref={ref} style={{
width,
height,
opacity
}} />;
};
export { c4902_6 as NativeLottieRenderMode };
+69
View File
@@ -0,0 +1,69 @@
// Metro module 9635 (f9636).
import { PixelRatio } from "react-native";
import ThemeStore from "../../user_settings/ThemeStore";
import { StickerFormat } from "../StickersTypes";
import * as _StickersUtils from "../StickersUtils";
import { isGuildSticker, getStickerExtensionFromFormatType } from "../StickersUtils";
import { intl, t } from "../../../intl/index.native";
import NativeLottieView, { NativeLottieRenderMode } from "./NativeLottieView";
import NativeAPNGView from "../../../components_native/common/NativeAPNGView";
import FastImage from "../../../components_native/common/FastImage";
import { isThemeDark } from "../../../design/shared";
import Module5207 from "../../../_bundle/Module5207";
import Module5208 from "../../../_bundle/Module5208";
export default function Sticker(props) {
const { sticker, size, animated = true, opaque = true } = props;
const opacity = opaque ? 1 : 0.3;
let url = sticker.format_type === StickerFormat.LOTTIE ? _StickersUtils.getStickerAssetUrl(sticker) : sticker.format_type === StickerFormat.APNG ? _StickersUtils.getStickerAssetUrl(sticker, {
isPreview: !animated,
size
}) : _StickersUtils.getStickerAssetUrl(sticker, {
isPreview: !animated,
size: PixelRatio.getPixelSizeForLayoutSize(size)
});
if (url == null) {
url = "";
}
const accessibilityLabel = intl.formatToPlainString(t.rk6pOw, {
stickerName: sticker.name
});
if (sticker.format_type === StickerFormat.LOTTIE) {
let id = sticker.id;
if (id == null) {
id = "";
}
return <NativeLottieView url={url} asset={id} width={size} height={size} opacity={opacity} renderMode={animated ? NativeLottieRenderMode.LOOP : NativeLottieRenderMode.STILL} accessibilityLabel={accessibilityLabel} />;
}
L19: {
if (sticker.format_type === StickerFormat.APNG) {
if ("type" in sticker && !isGuildSticker(sticker)) {
break L19;
}
return <NativeAPNGView style={{
height: size,
width: size,
opacity
}} url={url} name={`${sticker.id}.${getStickerExtensionFromFormatType(sticker.format_type)}`} accessibilityLabel={accessibilityLabel} />;
}
}
return <FastImage resizeMode="contain" style={{
height: size,
width: size,
opacity
}} placeholder={isThemeDark(ThemeStore.theme) ? Module5207 : Module5208} source={{
uri: url
}} accessible accessibilityLabel={accessibilityLabel} />;
};
export function getStickerAssetUrl(a0, a1, a2) {
let r25 = a0.format_type === StickerFormat.LOTTIE ? _StickersUtils.getStickerAssetUrl(a0) : a0.format_type === StickerFormat.APNG ? _StickersUtils.getStickerAssetUrl(a0, {
isPreview: !a2,
size: a1
}) : _StickersUtils.getStickerAssetUrl(a0, {
isPreview: !a2,
size: PixelRatio.getPixelSizeForLayoutSize(a1)
});
if (r25 == null) {
r25 = "";
}
return r25;
}
@@ -0,0 +1,486 @@
// Metro module 9640 (f9641).
import * as Module19 from "react";
import { useMemo, useEffect, useCallback, useState, useRef } from "react";
import { ActivityIndicator, View, Pressable } from "react-native";
import GuildStore from "../../../stores/GuildStore";
import UserStore from "../../../stores/UserStore";
import StickersStore from "../StickersStore";
import { PADDING_HORIZONTAL, MIN_MARGIN, STICKER_SIZE } from "./StickerPickerConstants";
import { AnalyticsPages, AnalyticsSections, AnalyticEvents, UserSettingsSections, GuildFeatures } from "../../../Constants";
import { ACTION_SHEET_MAX_WIDTH } from "../../action_sheet/native/ActionSheetConstants";
import { jsx } from "react/jsx-runtime";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { isAndroid } from "../../../utils/PlatformUtils";
import Module712 from "../../../_bundle/Module712";
import { useFetchStickerPack, useFavoriteStickerIds, useStickerForRenderableSticker } from "../StickersHooks";
import { StarIcon } from "../../../design/components/Icon/native/redesign/generated/StarIcon";
import { StarOutlineIcon } from "../../../design/components/Icon/native/redesign/generated/StarOutlineIcon";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import { unfavoriteSticker, favoriteSticker } from "../StickersActionCreators";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import { useStateFromStores } from "../../../_bundle/Module589";
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import StickerPickerListRow from "./StickerPickerListRow";
import { Button } from "../../../design/components/Button/native/Button.native";
import { hideStickerDetailActionSheet } from "./showStickerDetailActionSheet";
import { openStickerPickerToPackId } from "./StickersUtils";
import openStickerPackDetailActionSheet, { AnalyticsPopoutType } from "./openStickerPackDetailActionSheet";
import PremiumUtils from "../../../utils/PremiumUtils";
import TidaWebformExperiment from "../../guild/TidaWebformExperiment";
import { DeveloperMode } from "../../user_settings/UserSettings";
import { getStickerAssetUrl, isStandardSticker, isGuildSticker } from "../StickersUtils";
import { collectChannelAnalyticsMetadata } from "../../app_analytics/AppAnalyticsUtils";
import GuildActionCreators from "../../../actions/GuildActionCreators";
import getStickerDiscoverableGuild from "../../messages/getStickerDiscoverableGuild";
import { openUserSettings } from "../../user_settings/core/native/openUserSettings";
import Sticker from "./Sticker";
import { MoreHorizontalIcon } from "../../../design/components/Icon/native/redesign/generated/MoreHorizontalIcon";
import NitroUpsellButton from "../../premium/components/native/NitroUpsellButton";
import openStickersPremiumUpsellAlert from "./premium/openStickersPremiumUpsellAlert";
import { FormDivider } from "../../../design/void/Form/native/index";
import ExpressionGuildDetails from "../../messages/native/emoji/ExpressionGuildDetails";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import { HermesBuiltin } from "../../../_hermes/prelude";
let UnavailableStickerDetail, useStyles, GuildStickerDetail;
let env6375 = {};
const StandardStickerDetail = function StandardStickerDetail(props) {
let r125;
let env17365 = {
$parent: env6375
};
const { sticker: sticker2, channel: channel3 } = props;
env17365[0] = channel3;
env17365[1] = props.chatInputRef;
env17365[2] = void 0;
env17365[3] = void 0;
env17365[4] = void 0;
env17365[5] = void 0;
const styles = useStyles();
const pack_id = sticker2.pack_id;
env17365[2] = pack_id;
const name = sticker2.name;
const stateFromStores2 = useStateFromStores([StickersStore], () => StickersStore.getStickerPack(env17365[2]));
env17365[3] = stateFromStores2;
const stateFromStores3 = useStateFromStores([StickersStore], () => StickersStore.isPremiumPack(env17365[2]));
env17365[4] = stateFromStores3;
useFetchStickerPack(pack_id);
const containerWidth = useWindowDimensions_native().width - 2 * PADDING_HORIZONTAL;
const rowSize = Math.floor(Math.min(ACTION_SHEET_MAX_WIDTH, containerWidth - MIN_MARGIN) / (STICKER_SIZE + MIN_MARGIN));
const memo3 = useMemo(() => ({
page: env17365[0].guild_id != null ? AnalyticsPages.GUILD_CHANNEL : AnalyticsPages.DM_CHANNEL,
section: AnalyticsSections.STICKER_POPOUT
}), [channel3.guild_id]);
env17365[5] = memo3;
useEffect(() => {
const r5 = env17365[3];
if (r5 != null) {
AnalyticsUtils.track(AnalyticEvents.OPEN_POPOUT, {
location: env17365[5],
type: "Sticker Upsell Sheet",
sticker_pack_id: r5.id
});
}
}, [memo3, stateFromStores2]);
if (stateFromStores2 == null) {
r125 = (0, jsx)(ActivityIndicator, {
size: "large"
});
} else {
const stateFromStores = stateFromStores2;
r125 = <>
<Text variant="heading-md/extrabold" color="mobile-text-heading-primary">{name}</Text>
<Text style={styles.description} variant="text-sm/medium">
{stateFromStores3 ? intl.format(t.auckXz, {
stickerPackName: stateFromStores.name
}) : intl.format(t.OzB6e3, {
stickerPackName: stateFromStores.name
})}
</Text>
<StickerPickerListRow containerWidth={containerWidth} stickers={stateFromStores.stickers.slice(0, rowSize)} rowSize={rowSize} />
{stateFromStores3 ? <View style={{
height: Module712.space.PX_16
}} /> : null}
{stateFromStores3 && <Button variant="secondary" text={intl.string(t.GPy3Ar)} onPress={() => {
hideStickerDetailActionSheet();
if (stateFromStores != null && env17365[4]) {
const r15 = env17365[1];
if (r15 != null) {
openStickerPickerToPackId(r15, env17365[2]);
} else {
openStickerPackDetailActionSheet({
analyticsLocation: env17365[5],
analyticsPopoutType: AnalyticsPopoutType.STICKER_PACK_UPSELL,
stickerPack: stateFromStores
});
}
} else {
openStickerPackDetailActionSheet({
analyticsLocation: env17365[5],
analyticsPopoutType: AnalyticsPopoutType.STICKER_PACK_UPSELL,
stickerPack: stateFromStores
});
}
}} />}
</>;
}
return r125;
};
UnavailableStickerDetail = function UnavailableStickerDetail(props) {
let stickerAssetUrl;
const { renderableSticker, channel } = props;
stickerAssetUrl = void 0;
const styles = useStyles();
const canUseCustomStickersEverywhere = PremiumUtils.canUseCustomStickersEverywhere(UserStore.getCurrentUser());
const memo = useMemo(() => ({
page: channel.guild_id != null ? AnalyticsPages.GUILD_CHANNEL : AnalyticsPages.DM_CHANNEL,
section: AnalyticsSections.STICKER_POPOUT
}), [channel.guild_id]);
let tidaWebformEnabled = TidaWebformExperiment.useExperiment({
location: "StickerDetailActionSheet"
}, {
autoTrackExposure: false
}).tidaWebformEnabled;
const setting = DeveloperMode.useSetting();
if (tidaWebformEnabled) {
tidaWebformEnabled = setting;
}
stickerAssetUrl = getStickerAssetUrl(renderableSticker);
const callback2 = useCallback(() => {
if (stickerAssetUrl != null) {
ActionSheetActionCreators.openLazy(import("./StickerOptionsActionSheet"), "StickerOptionsActionSheet", {
stickerUrl: stickerAssetUrl
}, "stack");
}
}, [stickerAssetUrl]);
const r59 = [<Sticker sticker={renderableSticker} size={48} />, <View style={styles.guildEmojiDescription}>
<Text variant="heading-md/extrabold" color="mobile-text-heading-primary">{renderableSticker.name}</Text>
<Text style={styles.description} variant="text-sm/medium">
{canUseCustomStickersEverywhere ? intl.string(t.vZaScH) : intl.format(t.hGWuxU, {
openPremiumSettings: () => {
ActionSheetActionCreators.hideActionSheet();
AnalyticsUtils.track(AnalyticEvents.PREMIUM_PROMOTION_OPENED, {
location_page: memo.page,
location_section: memo.section
});
openUserSettings({
screen: UserSettingsSections.PREMIUM,
params: {
analyticsLocation: memo
}
});
}
})}
</Text>
</View>, ,];
if (tidaWebformEnabled) {
tidaWebformEnabled = stickerAssetUrl != null;
}
if (tidaWebformEnabled) {
tidaWebformEnabled = <Pressable accessibilityLabel={intl.string(t.PdRCRg)} style={styles.moreMenuIcon} onPress={callback2}>
<MoreHorizontalIcon color={Module712.colors.INTERACTIVE_TEXT_DEFAULT} />
</Pressable>;
}
r59[2] = tidaWebformEnabled;
return <View style={styles.guildEmojiTopContainer}>{r59}</View>;
};
useStyles = createStyles({
content: {
padding: 16,
paddingBottom: isAndroid() ? 16 : 0
},
description: {
lineHeight: 18,
marginTop: 4
},
guildEmojiTopContainer: {
flexDirection: "row",
alignItems: "center"
},
buttonContainer: {
marginTop: Module712.space.PX_12
},
guildEmojiDescription: {
paddingLeft: 16,
flex: 1
},
divider: {
marginLeft: 0,
marginTop: Module712.space.PX_16,
marginBottom: Module712.space.PX_16,
backgroundColor: Module712.colors.BORDER_SUBTLE
},
moreMenuIcon: {
height: 32,
width: 32,
justifyContent: "center",
alignItems: "center"
},
favoriteContainer: {
paddingTop: Module712.space.PX_4
},
starIcon: {
height: 32,
width: 32
},
starIconSelected: {
tintColor: Module712.colors.ICON_FEEDBACK_WARNING
},
starIconUnselected: {
tintColor: Module712.colors.INTERACTIVE_TEXT_DEFAULT
}
});
GuildStickerDetail = (props) => {
let r3, r33, r125, popoutType;
let state2, setState2, stickerAssetUrl2, memo2, current, ref;
const { sticker, channel: channel2 } = props;
state2 = void 0;
setState2 = void 0;
stickerAssetUrl2 = void 0;
memo2 = void 0;
current = void 0;
ref = void 0;
const r19 = useStyles();
let [guild, setState] = useState(null);
const state = guild;
const stateFromStores2 = useStateFromStores([GuildStore], () => GuildStore.getGuild(sticker.guild_id));
const hasJoinedGuild = stateFromStores2 != null;
const r44 = stateFromStores2 == null || stateFromStores2.features.has(GuildFeatures.DISCOVERABLE);
[state2, setState2] = useState(!r44);
const canUseCustomStickersEverywhere = PremiumUtils.canUseCustomStickersEverywhere(UserStore.getCurrentUser());
let tidaWebformEnabled = TidaWebformExperiment.useExperiment({
location: "StickerDetailActionSheet"
}, {
autoTrackExposure: false
}).tidaWebformEnabled;
const setting = DeveloperMode.useSetting();
const id = sticker.id;
const r73 = useStyles();
let c17369_1 = r73;
const r78 = useFavoriteStickerIds().includes(id);
let c17369_2 = r78;
const callback = useCallback((a0) => {
let style;
const r1 = {};
HermesBuiltin.copyDataProperties(r1, c17369_1.starIcon);
if (a0) {
HermesBuiltin.copyDataProperties(r1, c17369_1.starIconSelected);
style = r1;
} else {
HermesBuiltin.copyDataProperties(r1, c17369_1.starIconUnselected);
style = r1;
}
return a0 ? <StarIcon style={style} /> : <StarOutlineIcon style={style} />;
}, [r73]);
const callback3 = useCallback(() => {
const content = function content() {
return <Text style={{
marginLeft: 8,
marginTop: 2
}} variant="text-md/bold">
{c17369_2 ? intl.string(t.in1rga) : intl.string(t.mE2e8A)}
</Text>;
};
ActionSheetActionCreators.hideActionSheet();
if (c17369_2) {
unfavoriteSticker(id);
ToastActionCreators.open({
key: "STICKER_UNFAVORITED",
icon: () => callback(false),
content
});
} else {
favoriteSticker(id);
ToastActionCreators.open({
key: "STICKER_FAVORITED",
icon: () => callback(true),
content
});
}
}, [r78, id, callback]);
if (tidaWebformEnabled) {
tidaWebformEnabled = setting;
}
stickerAssetUrl2 = getStickerAssetUrl(sticker);
const callback2 = useCallback(() => {
if (stickerAssetUrl2 != null) {
ActionSheetActionCreators.openLazy(import("./StickerOptionsActionSheet"), "StickerOptionsActionSheet", {
stickerUrl: stickerAssetUrl2
}, "stack");
}
}, [stickerAssetUrl2]);
memo2 = useMemo(() => ({
page: channel2.guild_id != null ? AnalyticsPages.GUILD_CHANNEL : AnalyticsPages.DM_CHANNEL,
section: AnalyticsSections.STICKER_POPOUT
}), [channel2.guild_id]);
const current2 = useRef({
guild_id: channel2.getGuildId(),
...collectChannelAnalyticsMetadata(channel2)
}).current;
useEffect(() => {
let _fetchDiscoverableGuild2 = function _fetchDiscoverableGuild() {
const r9 = async () => {
let c31508_1;
c31508_1 = void 0;
let c31989_0 = await getStickerDiscoverableGuild(sticker.id);
(0, setState)(c31989_0);
(0, setState2)(true);
};
_fetchDiscoverableGuild2 = r9;
return r9.apply(this, arguments);
};
if (!state2) {
(function fetchDiscoverableGuild() {
return _fetchDiscoverableGuild2.apply(this, arguments);
})();
}
}, [sticker.id, state2]);
const r115 = sticker.guild_id === channel2.getGuildId();
const r6 = state != null;
if (canUseCustomStickersEverywhere) {
const r143 = hasJoinedGuild ? r115 ? intl.string(t.fZ0DiG) : intl.string(t["1f6D9m"]) : r6 ? intl.string(t.yHmoR9) : intl.string(t.vZaScH);
r125 = false;
popoutType = "Custom Sticker Popout";
r33 = r143;
r3 = false;
} else if (hasJoinedGuild) {
if (r115) {
r33 = intl.string(t.jNphpt);
r125 = true;
popoutType = "Custom Sticker Popout (Upsell)";
r3 = true;
} else {
r33 = intl.string(t.lyD5ZW);
r125 = true;
popoutType = "Custom Sticker Popout (Upsell)";
r3 = true;
}
} else if (r6) {
r33 = intl.string(t.IuXYch);
r125 = true;
popoutType = "Custom Sticker Popout (Upsell)";
r3 = true;
} else {
r33 = intl.format(t.hGWuxU, {
openPremiumSettings: () => {
ActionSheetActionCreators.hideActionSheet();
AnalyticsUtils.track(AnalyticEvents.PREMIUM_PROMOTION_OPENED, {
location_page: memo2.page,
location_section: memo2.section
});
openUserSettings({
screen: UserSettingsSections.PREMIUM,
params: {
analyticsLocation: memo2
}
});
}
});
r125 = false;
popoutType = "Custom Sticker Popout (Soft Upsell)";
r3 = false;
}
const showingJoinGuildCta = (r3 ? !r3 : !hasJoinedGuild) && r6;
current = {
popoutAnalyticsConfig: current2,
popoutType
};
ref = useRef(current);
useEffect(() => {
ref.current = current;
});
useEffect(() => {
const current2 = ref.current;
const { popoutAnalyticsConfig, popoutType } = current2;
if (state2) {
AnalyticsUtils.track(AnalyticEvents.OPEN_POPOUT, {
type: popoutType,
...popoutAnalyticsConfig
});
}
}, [state2]);
let r159 = null;
if (state2) {
const r208 = [<View style={r19.guildEmojiTopContainer}>
<Sticker sticker={sticker} size={48} />
<View style={r19.guildEmojiDescription}>
<Text variant="heading-md/extrabold" color="mobile-text-heading-primary">{sticker.name}</Text>
<Text style={r19.description} variant="text-sm/medium">{r33}</Text>
</View>
{(tidaWebformEnabled ? stickerAssetUrl2 != null : tidaWebformEnabled) && <Pressable accessibilityLabel={intl.string(t.PdRCRg)} style={r19.moreMenuIcon} onPress={callback2}>
<MoreHorizontalIcon color={Module712.colors.INTERACTIVE_TEXT_DEFAULT} />
</Pressable>}
</View>, , , , ,];
if (r125) {
r125 = <View style={r19.buttonContainer}>
<NitroUpsellButton text={intl.string(t["gl/XHJ"])} onPress={() => openStickersPremiumUpsellAlert(memo2)} />
<View style={{
height: Module712.space.PX_16
}} />
</View>;
}
r208[1] = r125;
r208[2] = showingJoinGuildCta && <View style={r19.buttonContainer}>
<Button text={intl.string(t.riu2R5)} onPress={() => {
if (state != null) {
const id2 = state.id;
GuildActionCreators.joinGuild(id2).then(() => {
GuildActionCreators.transitionToGuildSync(id2);
});
}
}} />
<View style={{
height: Module712.space.PX_16
}} />
</View>;
let r259 = stateFromStores2 != null || state != null;
if (r259) {
const r266 = [<FormDivider style={r19.divider} />, ,];
if (state == null) {
guild = stateFromStores2;
}
r266[1] = <ExpressionGuildDetails guild={guild} showingJoinGuildCta={showingJoinGuildCta} hasJoinedGuild={hasJoinedGuild} title={hasJoinedGuild ? intl.string(t.kx6pEG) : intl.string(t.pDE7Gb)} />;
r259 = <>{r266}</>;
}
r208[3] = r259;
if (tidaWebformEnabled) {
tidaWebformEnabled = hasJoinedGuild;
}
if (tidaWebformEnabled) {
tidaWebformEnabled = <>
{[<FormDivider style={r19.divider} />, <View style={r19.favoriteContainer}>
<Button text={r78 ? intl.string(t.XhzKyF) : intl.string(t.kWmiPW)} variant={r78 ? "tertiary" : "primary"} size="md" onPress={callback3} />
</View>]}
</>;
}
r208[4] = tidaWebformEnabled;
r159 = <>{r208}</>;
}
return r159;
};
const r105 = Module19.memo(function StickerDetailActionSheet(props) {
let r26;
const { renderableSticker, channel: channel3, chatInputRef } = props;
const styles = useStyles();
const [sticker2, r8] = useStickerForRenderableSticker(renderableSticker, true);
let r24 = <ActivityIndicator size="large" />;
if (sticker2 == null && r8) {
r26 = <UnavailableStickerDetail renderableSticker={renderableSticker} channel={channel3} />;
} else {
r26 = r24;
if (sticker2 != null) {
if (isStandardSticker(sticker2)) {
r24 = <StandardStickerDetail sticker={sticker2} channel={channel3} chatInputRef={chatInputRef} />;
} else if (isGuildSticker(sticker2)) {
r24 = <GuildStickerDetail sticker={sticker2} channel={channel3} />;
}
r26 = r24;
}
}
return <BottomSheet startExpanded>
<View style={styles.content}>{r26}</View>
</BottomSheet>;
});
export default r105;
@@ -0,0 +1,23 @@
// Metro module 9641 (f9642).
import { useCallback } from "react";
import { copy } from "../../../utils/ClipboardUtils.native";
import { presentCopiedToClipboard } from "../../toast/native/ToastUtils";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { ActionSheet } from "../../../design/components/Sheet/native/ActionSheet.native";
import { TableRowGroup } from "../../../design/components/TableRow/native/TableRowGroup.native";
import { TableRow } from "../../../design/components/TableRow/native/TableRow.native";
import { LinkIcon } from "../../../design/components/Icon/native/redesign/generated/LinkIcon";
import { intl, t } from "../../../intl/index.native";
export default function StickerOptionsActionSheet(props) {
const stickerUrl = props.stickerUrl;
const callback = useCallback(() => {
copy(stickerUrl);
presentCopiedToClipboard();
ActionSheetActionCreators.hideActionSheet();
}, [stickerUrl]);
return <ActionSheet>
<TableRowGroup hasIcons>
<TableRow icon={<LinkIcon />} label={intl.string(t.B1ubHx)} onPress={callback} />
</TableRowGroup>
</ActionSheet>;
};
@@ -0,0 +1,12 @@
// Metro module 9632 (f9633).
import { Image as Image2, View } from "react-native";
import { getStickerPackBannerAssetUrl } from "../StickersUtils";
export default function StickerPackBanner(props) {
const { containerStyle, style } = props;
const stickerPackBannerAssetUrl = getStickerPackBannerAssetUrl(props.stickerPack, 1024);
return stickerPackBannerAssetUrl != null ? <View style={containerStyle}>
<Image2 source={{
uri: stickerPackBannerAssetUrl
}} style={style} resizeMode="contain" />
</View> : null;
};
@@ -0,0 +1,109 @@
// Metro module 9628 (f9629).
import { memo, useState, useRef, useEffect } from "react";
import { MIN_MARGIN, STICKER_SIZE } from "./StickerPickerConstants";
import { AnalyticEvents } from "../../../Constants";
import { ACTION_SHEET_MAX_WIDTH } from "../../action_sheet/native/ActionSheetConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
import Module12 from "../../../_bundle/Module12";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import StickerPackHeader from "./StickerPackHeader";
import StickerPackInformationPopout, { doesStickerPackHavePopoutInformation } from "./StickerPackInformationPopout";
import { ActionSheetHeaderBar } from "../../../design/components/Sheet/native/ActionSheetHeaderBar.native";
import { BottomSheetScrollView } from "../../../_bundle/Module5245";
import StickerPickerListRow from "./StickerPickerListRow";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import Sticker from "./Sticker";
const useStyles = createStyles({
focusedStickerPreviewContainer: {
position: "absolute",
left: 0,
top: 0,
height: "100%",
width: "100%",
alignItems: "center",
justifyContent: "center",
backgroundColor: "rgba(0, 0, 0, 0.85)"
},
header: {
marginHorizontal: 16,
marginVertical: 8,
backgroundColor: "transparent",
height: void 0
},
stickers: {
paddingHorizontal: 16,
marginBottom: 16
},
popoutContainer: {
position: "absolute",
bottom: 50
}
});
const r43 = memo(function StickerPackDetailActionSheet(props) {
let setState, state, setState2, ref, containerWidth, ref2;
const { stickerPack, analyticsPopoutType, onClose } = props;
setState = void 0;
state = void 0;
setState2 = void 0;
ref = void 0;
containerWidth = void 0;
ref2 = void 0;
const onPressSticker2 = function onPressSticker(a0) {
setState(a0);
};
const toggleDisplayingPackDetails = function toggleDisplayingPackDetails() {
if (ref.current != null) {
clearTimeout(ref.current);
}
setState2(!state);
if (!state) {
ref.current = setTimeout(() => setState2(false), 4000);
}
};
const styles = useStyles();
const width = useWindowDimensions_native().width;
let sticker;
[sticker, setState] = useState(null);
let state2;
[state2, setState2] = useState(false);
state = state2;
ref = useRef(null);
const bottom = useSafeAreaInsets_native().bottom;
containerWidth = Math.floor(Math.min(ACTION_SHEET_MAX_WIDTH, width) / (STICKER_SIZE + MIN_MARGIN));
const r55 = Module12.chunk(stickerPack.stickers, containerWidth);
ref2 = useRef(onClose);
useEffect(() => {
ref2.current = onClose;
}, [onClose]);
useEffect(() => () => {
const current = ref2.current;
return current == null ? void 0 : current.call(ref2);
}, []);
useEffect(() => {
AnalyticsUtils.track(AnalyticEvents.OPEN_POPOUT, {
type: analyticsPopoutType,
sticker_pack_id: stickerPack.id
});
}, [analyticsPopoutType, stickerPack.id]);
const r109 = [<BottomSheet scrollable startExpanded handleDisabled header={<>
<StickerPackHeader stickerPack={stickerPack} style={styles.header} onPress={doesStickerPackHavePopoutInformation(stickerPack) ? toggleDisplayingPackDetails : void 0} withBanner withDescription />
<ActionSheetHeaderBar variant="floating" />
</>}>
<BottomSheetScrollView style={styles.stickers} contentContainerStyle={{
paddingBottom: 32 + bottom
}}>
{r55.map((item, index) => <StickerPickerListRow key={index} containerWidth={containerWidth} stickers={item} rowSize={containerWidth} onPressSticker={onPressSticker2} nativeRow={false} />)}
</BottomSheetScrollView>
</BottomSheet>, sticker != null && <PressableOpacity accessibilityRole="none" style={styles.focusedStickerPreviewContainer} onPress={() => setState(null)}>
<Sticker sticker={sticker} size={128} />
</PressableOpacity>, ,];
if (state) {
state2 = <StickerPackInformationPopout stickerPack={stickerPack} style={styles.popoutContainer} onClose={toggleDisplayingPackDetails} />;
}
r109[2] = state2;
return <>{r109}</>;
});
export default r43;
@@ -0,0 +1,111 @@
// Metro module 9629 (f9630).
import { memo } from "react";
import { View } from "react-native";
import * as _StickerPickerConstants from "./StickerPickerConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Text } from "../../../design/components/Text/native/Text";
import { isStickerPackAnimated } from "../StickersUtils";
import { Icon } from "../../../design/void/native";
import Module9630 from "../../../_bundle/Module9630";
import Module9631 from "../../../_bundle/Module9631";
import { intl, t } from "../../../intl/index.native";
import StickerPackBanner from "./StickerPackBanner";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
const { PADDING_HORIZONTAL, PADDING_VERTICAL } = _StickerPickerConstants;
const useStyles = createStyles({
section: {
paddingTop: PADDING_VERTICAL,
paddingHorizontal: PADDING_HORIZONTAL,
height: 36 + 2 * PADDING_VERTICAL,
justifyContent: "center",
overflow: "hidden",
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH
},
label: {
flex: -1
},
header: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between"
},
bannerContainer: {
aspectRatio: 3.824074074074074,
marginVertical: -8,
width: "100%"
},
banner: {
height: "100%"
},
headline: {
height: 20,
flex: 1,
flexDirection: "row",
alignItems: "center"
},
iconContainer: {
marginLeft: 8,
height: 16,
width: 16,
borderRadius: Module712.radii.sm,
backgroundColor: Module712.colors.BORDER_SUBTLE,
alignItems: "center",
justifyContent: "center"
},
icon: {
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
},
animatedIcon: {
position: "relative",
left: 1
},
premiumIcon: {
position: "relative",
left: -1
}
});
const r64 = memo(function(a0) {
const { stickerPack, style, onPress } = a0;
let withBanner = a0.withBanner;
if (withBanner === void 0) {
withBanner = false;
}
let withDescription = a0.withDescription;
if (withDescription === void 0) {
withDescription = false;
}
const styles = useStyles();
const r72 = [<View style={styles.header}>
<View style={styles.headline}>
<Text style={styles.label} lineClamp={1} variant="text-md/bold" color="mobile-text-heading-primary">{stickerPack.name}</Text>
{isStickerPackAnimated(stickerPack) && <View style={styles.iconContainer}>
<Icon source={Module9630} style={styles.animatedIcon} size={Icon.Sizes.EXTRA_SMALL} color={styles.icon.color} />
</View>}
<View style={styles.iconContainer}>
<Icon source={Module9631} style={styles.premiumIcon} size={Icon.Sizes.EXTRA_SMALL} color={styles.icon.color} />
</View>
</View>
</View>, , ,];
if (withDescription) {
withDescription = stickerPack.description != null;
}
if (withDescription) {
withDescription = <Text variant="text-sm/medium">{stickerPack.description}</Text>;
}
r72[1] = withDescription;
r72[2] = <Text lineClamp={1} variant="text-xs/medium" color="text-default">
{intl.format(t["0S3JpO"], {
numStickers: stickerPack.stickers.length
})}
</Text>;
const r97 = <>{r72}</>;
if (withBanner) {
withBanner = <StickerPackBanner stickerPack={stickerPack} containerStyle={styles.bannerContainer} style={styles.banner} />;
}
return <>
{withBanner}
{onPress != null ? <PressableOpacity style={[styles.section, style]} onPress={onPress} accessibilityRole="header">{r97}</PressableOpacity> : <View style={[styles.section, style]}>{r97}</View>}
</>;
});
export default r64;
@@ -0,0 +1,83 @@
// Metro module 9633 (f9634).
import { FlatList, View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { isStickerPackAnimated } from "../StickersUtils";
import { intl, t } from "../../../intl/index.native";
import { Text } from "../../../design/components/Text/native/Text";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
const useStyles = createStyles({
informationContainer: {
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
width: "90%",
marginHorizontal: "5%",
padding: 16,
borderRadius: Module712.radii.xs,
shadowColor: Module712.colors.BLACK,
shadowOffset: {
width: 2,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 5
},
headerContainer: {
flexDirection: "row",
justifyContent: "space-between",
marginBottom: 8
},
informationHeader: {
lineHeight: 20
},
informationContentContainer: {
flexDirection: "row"
},
informationContent: {
lineHeight: 20
},
informationContentDescription: {
flex: 1,
marginLeft: 5
}
});
export default function StickerPackInformationPopout(props) {
const { stickerPack, onClose, style } = props;
const styles = useStyles();
const data = [];
if (isStickerPackAnimated(stickerPack)) {
data.push({
key: "animated",
description: intl.string(t.W11rMa)
});
}
return <View style={[styles.informationContainer, style]}>
<View style={styles.headerContainer}>
<Text style={styles.informationHeader} variant="text-md/semibold" color="mobile-text-heading-primary">
{intl.format(t.XDm6yN, {
stickerPackName: stickerPack.name
})}
</Text>
<PressableOpacity onPress={onClose} accessibilityRole="button" accessibilityLabel={intl.string(t.cpT0Cq)}>
<Text variant="text-md/bold" color="text-brand">
{intl.string(t.cpT0Cq)}
</Text>
</PressableOpacity>
</View>
<FlatList data={data} renderItem={function renderItem(info) {
return <View style={styles.informationContentContainer}>
<Text style={styles.informationContent} variant="text-md/medium" color="text-default">•</Text>
<Text style={[styles.informationContent, styles.informationContentDescription]} variant="text-md/medium" color="text-default">{info.item.description}</Text>
</View>;
}} />
</View>;
};
export function doesStickerPackHavePopoutInformation(a0) {
const r2 = [];
if (isStickerPackAnimated(a0)) {
r2.push({
key: "animated",
description: intl.string(t.W11rMa)
});
}
return r2.length > 0;
}
+144
View File
@@ -0,0 +1,144 @@
// Metro module 9618 (f9619).
import { memo, useState, useCallback, useEffect } from "react";
import { ActivityIndicator, View } from "react-native";
import UserStore from "../../../stores/UserStore";
import StickersStore from "../StickersStore";
import { STICKER_SEARCH_HEADER_HEIGHT } from "../StickersConstants";
import { AnalyticEvents, AnalyticsPages, AnalyticsSections, ChatInputComponentViewedTypes, UpsellTypes } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { useFetchStickerPacks } from "../StickersHooks";
import { useStickerCategories } from "./StickersUtils";
import { useStateFromStores } from "../../../_bundle/Module589";
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../app_analytics/useAnalyticsLocations";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import useExpressionPickerInsets from "../../expression_picker/native/useExpressionPickerInsets";
import { batchUpdates } from "../../../_bundle/Module705";
import { searchAllStickers } from "../StickersSearchUtils";
import { getStickerSendability, StickerSendability } from "../StickerSendability";
import { isStandardSticker, isGuildSticker } from "../StickersUtils";
import openStickerPackDetailActionSheet, { AnalyticsPopoutType } from "./openStickerPackDetailActionSheet";
import PremiumUpsellUtils from "../../../utils/native/PremiumUpsellUtils";
import TidaWebformExperiment from "../../guild/TidaWebformExperiment";
import { showStickerDetailActionSheet } from "./showStickerDetailActionSheet";
import { SearchField } from "../../../design/components/TextField/native/SearchField.native";
import { intl, t } from "../../../intl/index.native";
import StickerPickerEmptyState from "./StickerPickerEmptyState";
import StickerPickerList from "./StickerPickerList";
import StickerPickerCategories from "./StickerPickerCategories";
const useStyles = createStyles({
container: {
flex: 1
},
header: {
paddingVertical: Module712.space.PX_8
},
loadingIndicator: {
alignItems: "center",
justifyContent: "center",
flex: 1
},
emptyState: {
marginTop: STICKER_SEARCH_HEADER_HEIGHT,
alignItems: "center",
justifyContent: "center",
flex: 1
}
});
const r54 = memo(function StickerPicker(props) {
let setState, analyticsLocations, setState2;
const { bottomSheetRef, bottomSheetIndex, channel, paddingTop, onPressSticker, stickerFormats, inPortalKeyboard } = props;
setState = void 0;
analyticsLocations = void 0;
setState2 = void 0;
const styles = useStyles();
useFetchStickerPacks();
const stickerCategories = useStickerCategories(channel);
const stateFromStores = useStateFromStores([StickersStore], () => StickersStore.hasLoadedStickerPacks);
let categoryIndex;
[categoryIndex, setState] = useState(0);
analyticsLocations = useAnalyticsLocations(AnalyticsLocation.STICKER_PICKER).analyticsLocations;
let searchResults;
[searchResults, setState2] = useState(null);
const expressionPickerInsets = useExpressionPickerInsets({
hasCategories: true
});
const { safeAreaStyle, safeAreaBottomKeyboardAware } = expressionPickerInsets;
const callback4 = useCallback((a0) => {
if (a0 === "") {
batchUpdates(() => {
setState(0);
setState2(null);
});
} else {
setState2(searchAllStickers(a0));
}
}, []);
useEffect(() => {
AnalyticsUtils.track(AnalyticEvents.CHAT_INPUT_COMPONENT_VIEWED, {
type: ChatInputComponentViewedTypes.STICKER,
channel_id: channel.id,
guild_id: channel.guild_id
});
}, [channel.id, channel.guild_id]);
const callback = useCallback((a0) => {
const stickerSendability = getStickerSendability(a0, UserStore.getCurrentUser(), channel);
if (stickerSendability === StickerSendability.SENDABLE) {
onPressSticker(a0);
} else if (stickerSendability === StickerSendability.SENDABLE_WITH_PREMIUM) {
if (isStandardSticker(a0)) {
const stickerPack = StickersStore.getStickerPack(a0.pack_id);
if (stickerPack == null) {
return void 0;
}
openStickerPackDetailActionSheet({
analyticsLocation: {
page: channel.guild_id != null ? AnalyticsPages.GUILD_CHANNEL : AnalyticsPages.DM_CHANNEL
},
analyticsPopoutType: AnalyticsPopoutType.STICKER_PACK_DETAIL,
stickerPack
});
} else if (isGuildSticker(a0)) {
PremiumUpsellUtils.handleShowUpsellAlert({
initialUpsellKey: UpsellTypes.GLOBAL_STICKER,
analyticsLocation: {
page: channel.guild_id != null ? AnalyticsPages.GUILD_CHANNEL : AnalyticsPages.DM_CHANNEL,
section: AnalyticsSections.STICKER_PICKER_UPSELL
},
analyticsLocations
});
}
}
}, [channel, onPressSticker, analyticsLocations]);
const callback3 = useCallback(() => {
AnalyticsUtils.track(AnalyticEvents.CHAT_INPUT_COMPONENT_VIEWED, {
type: ChatInputComponentViewedTypes.STICKER_SEARCH,
channel_id: channel.id,
guild_id: channel.guild_id
});
}, [channel]);
const tidaWebformEnabled = TidaWebformExperiment.useExperiment({
location: "StickerPicker"
}, {
autoTrackExposure: false
}).tidaWebformEnabled;
const callback2 = useCallback((a0) => {
showStickerDetailActionSheet({
renderableSticker: a0,
channel
});
}, [channel]);
return <AnalyticsLocationProvider value={analyticsLocations}>
<View style={styles.container}>
{stickerCategories.length !== 0 ? <View style={styles.header}>
<SearchField size="md" placeholder={intl.string(t.dt5h1C)} onChange={callback4} onFocus={callback3} isRound />
</View> : null}
{stateFromStores ? stickerCategories.length === 0 ? <View style={styles.emptyState}>
<StickerPickerEmptyState />
</View> : <StickerPickerList bottomSheetRef={bottomSheetRef} bottomSheetIndex={bottomSheetIndex} setCategoryIndex={setState} onPressSticker={callback} onLongPressStickerDetail={tidaWebformEnabled ? callback2 : void 0} insetBottom={safeAreaBottomKeyboardAware} insetTop={paddingTop} channel={channel} stickerFormats={stickerFormats} searchResults={searchResults} inPortalKeyboard={inPortalKeyboard} /> : <ActivityIndicator animating size="large" style={styles.loadingIndicator} />}
<StickerPickerCategories categories={stickerCategories} categoryIndex={categoryIndex} style={safeAreaStyle} />
</View>
</AnalyticsLocationProvider>;
});
export default r54;
@@ -0,0 +1,172 @@
// Metro module 9655 (f9656).
import * as Module19 from "react";
import { useCallback, useRef, useMemo, useState, useEffect } from "react";
import { View } from "react-native";
import GuildStore from "../../../stores/GuildStore";
import { useStickerPickerStore } from "./StickerPickerStore";
import { AnalyticEvents, AnalyticsPages, CATEGORY_ICON_RIPPLE_CONFIG, CATEGORY_ICON_SIZE, EXPRESSION_FOOTER_HEIGHT, NODE_SIZE } from "../../../Constants";
import { ExpressionPickerViewType } from "../../expression_picker/ExpressionPickerConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { AnimateStickers } from "../../user_settings/UserSettings";
import { shouldAnimateSticker } from "../StickersUtils";
import { StickerCategoryTypes } from "../StickersTypes";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import { Icon } from "../../../design/void/native";
import { makeSource } from "../../../utils/AvatarUtils";
import GuildIcon, { GuildIconSizes } from "../../guild/native/GuildIcon";
import Sticker from "./Sticker";
import { triggerHapticFeedback } from "../../haptics/HapticUtils.native";
import HapticFeedbackTypes from "../../haptics/HapticFeedbackTypes";
import useExpressionPickerCategoriesPlaceholderConfig from "../../expression_picker/native/categories/useExpressionPickerCategoriesPlaceholderConfig";
import ExpressionPickerCategories from "../../expression_picker/native/categories/ExpressionPickerCategories";
import FastestList_android from "../../fastest_list/FastestList.android";
import { intl, t } from "../../../intl/index.native";
import Module9656 from "../../../_bundle/Module9656";
const useStyles = createStyles({
list: {
flex: 1,
height: EXPRESSION_FOOTER_HEIGHT
},
item: {
height: EXPRESSION_FOOTER_HEIGHT,
width: EXPRESSION_FOOTER_HEIGHT,
justifyContent: "center",
alignItems: "center"
},
itemInner: {
justifyContent: "center",
alignItems: "center",
height: NODE_SIZE,
width: NODE_SIZE,
borderRadius: NODE_SIZE / 2
},
fadedItem: {
opacity: 0.5
},
activeItem: {
opacity: 1,
backgroundColor: Module712.colors.INTERACTIVE_BACKGROUND_ACTIVE
},
guildIcon: {
height: CATEGORY_ICON_SIZE,
width: CATEGORY_ICON_SIZE,
borderRadius: CATEGORY_ICON_SIZE / 2
},
guildItemPlaceholder: {
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED
}
});
let Component = Module19.memo(function({ category, onPressCategory, index, isActive }) {
let r75;
const styles = useStyles();
let animated = shouldAnimateSticker(AnimateStickers.useSetting(), false);
const guild = category.type === StickerCategoryTypes.GUILD ? GuildStore.getGuild(category.id) : null;
const callback3 = useCallback(() => {
if (!(category.type !== StickerCategoryTypes.PACK && category.type !== StickerCategoryTypes.GUILD)) {
AnalyticsUtils.track(AnalyticEvents.EXPRESSION_PICKER_CATEGORY_SELECTED, {
location: {
page: AnalyticsPages.EXPRESSION_PICKER
},
tab: ExpressionPickerViewType.STICKER,
sticker_pack_id: category.id,
guild_id: guild?.id
});
}
return onPressCategory == null ? void 0 : onPressCategory(index);
}, [category, guild, index, onPressCategory]);
const onPress = category.stickers.length > 0 ? callback3 : void 0;
const style = [styles.itemInner, isActive ? styles.activeItem : styles.fadedItem];
if (category.icon != null) {
r75 = <Icon style={styles.guildIcon} disableColor={category.type === StickerCategoryTypes.PACK} source={makeSource(category.icon)} />;
} else if (category.type === StickerCategoryTypes.GUILD) {
r75 = <GuildIcon guild={guild} loadingStyle={styles.guildItemPlaceholder} size={GuildIconSizes.XSMALL} style={styles.guildIcon} />;
} else {
const sticker = "previewSticker" in category && category.previewSticker != null ? category.previewSticker : category.stickers[0];
if (animated) {
animated = isActive;
}
r75 = <Sticker sticker={sticker} animated={animated} size={CATEGORY_ICON_SIZE} />;
}
return <PressableOpacity androidRippleConfig={CATEGORY_ICON_RIPPLE_CONFIG} accessibilityRole="tab" accessibilityLabel={category.name} accessibilityState={{
selected: isActive
}} disabled={category.stickers.length === 0} onPress={onPress} style={styles.item}>
<View style={style}>{r75}</View>
</PressableOpacity>;
});
export default ({ categories, categoryIndex, style }) => {
let state, setState, state2, setState2, stickerPickerStore, callback, callback2;
state = void 0;
setState = void 0;
state2 = void 0;
setState2 = void 0;
stickerPickerStore = void 0;
callback = void 0;
callback2 = void 0;
const styles = useStyles();
const ref = useRef(void 0);
const ref2 = useRef(null);
const memo = useMemo(() => [categories.length], [categories]);
[state, setState] = useState(null);
[state2, setState2] = useState(false);
stickerPickerStore = useStickerPickerStore((a0) => a0.setPackToScrollTo);
useEffect(() => {
const r7 = categories.findIndex((category) => category.type === StickerCategoryTypes.PACK);
if (r7 >= 0) {
setState(r7);
}
}, [categories]);
useEffect(() => {
if (ref.current != null && ref2.current != null) {
const r11 = categoryIndex * EXPRESSION_FOOTER_HEIGHT;
if (r11 > ref.current.end || r11 < ref.current.start) {
ref2.current.scrollToLocation({
section: 0,
item: categoryIndex,
animated: false
});
}
}
}, [categoryIndex]);
callback = useCallback(() => {
if (state != null && ref.current != null) {
setState2(state * EXPRESSION_FOOTER_HEIGHT > ref.current.end - (state2 ? 0 : EXPRESSION_FOOTER_HEIGHT));
}
}, [state, state2]);
const callback3 = useCallback((a0) => {
ref.current = {
start: a0.nativeEvent.contentOffset.x,
end: a0.nativeEvent.contentOffset.x + a0.nativeEvent.layoutMeasurement.width
};
callback();
}, [callback]);
callback2 = useCallback((a0) => {
stickerPickerStore(categories[a0].id);
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
}, [categories, stickerPickerStore]);
const callback5 = useCallback(() => {
if (state != null) {
callback2(state);
setState2(false);
}
}, [state, callback2]);
const callback4 = useCallback((a0) => {
if (ref.current == null) {
ref.current = {
start: 0,
end: a0.nativeEvent.layout.width
};
callback();
}
}, [callback]);
const callback6 = useCallback((a0, a1) => <Component category={categories[a1]} index={a1} isActive={a1 === categoryIndex} onPressCategory={callback2} />, [categories, categoryIndex, callback2]);
return <ExpressionPickerCategories portalHostName="expression-footer" style={style}>
<FastestList_android estimatedListSize="windowSize" horizontal itemSize={EXPRESSION_FOOTER_HEIGHT} keyboardShouldPersistTaps="always" listId={ExpressionPickerViewType.STICKER} onLayout={callback4} onScroll={callback3} placeholderConfig={useExpressionPickerCategoriesPlaceholderConfig()} ref={ref2} scrollReporting="callbacks" sections={memo} renderItem={callback6} showsHorizontalScrollIndicator={false} style={styles.list} />
{state != null && state2 && <PressableOpacity onPress={callback5} accessibilityRole="button" accessibilityLabel={intl.string(t.rzCcjK)}>
<View style={[styles.item, styles.fadedItem]}>
<Icon style={styles.guildIcon} source={Module9656} />
</View>
</PressableOpacity>}
</ExpressionPickerCategories>;
};
@@ -0,0 +1,18 @@
// Metro module 9589 (f9590).
import * as _ExpressionPickerConstants from "../../expression_picker/ExpressionPickerConstants";
import { StickerFormat } from "../StickersTypes";
const { PADDING_VERTICAL, PADDING_HORIZONTAL, MIN_MARGIN } = _ExpressionPickerConstants;
const r2 = 2 * PADDING_VERTICAL;
const r22 = [StickerFormat.GIF, StickerFormat.PNG, StickerFormat.APNG];
export { PADDING_HORIZONTAL };
export { PADDING_VERTICAL };
export { MIN_MARGIN };
export const STICKER_SIZE = 64;
export const LABEL_HEIGHT = 16;
export const BUTTON_HEIGHT = 32;
export const ROW_HEIGHT = 64 + r2;
export const STICKER_NUDGE_RESULTS_CAP = 4;
export const STICKER_PICKER_PADDING = 100;
export const STICKER_SCROLL_LOAD_DELAY_MS = 250;
export const STICKER_SCROLL_LOAD_DELAY_AFTER_HEIGHT_CHANGE_MS = 750;
export { r22 as STICKER_FORMATS };
@@ -0,0 +1,95 @@
// Metro module 9649 (f9650).
import { useState, useEffect } from "react";
import { View } from "react-native";
import StickersStore from "../StickersStore";
import { EMPTY_STATE_STICKERS } from "../StickersConstants";
import { AnalyticEvents, AnalyticsSections } from "../../../Constants";
import { PremiumUpsellTypes } from "../../premium/PremiumConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { useShouldAnimateSticker, useFetchStickerPacks } from "../StickersHooks";
import Sticker from "./Sticker";
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import { useStateFromStoresArray } from "../../../_bundle/Module589";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import { triggerHapticFeedback } from "../../haptics/HapticUtils.native";
import HapticFeedbackTypes from "../../haptics/HapticFeedbackTypes";
import { Button } from "../../../design/components/Button/native/Button.native";
import FastImage from "../../../components_native/common/FastImage";
import Module9377 from "../../../_bundle/Module9377";
import openStickersPremiumUpsellAlert from "./premium/openStickersPremiumUpsellAlert";
let useStyles;
const EmptyStateSticker = function EmptyStateSticker(props) {
const sticker = props.sticker;
return <Sticker key={sticker?.id} sticker={sticker} size={60} animated={useShouldAnimateSticker(props.isFocused)} />;
};
useStyles = createStyles({
header: {
marginBottom: 8,
textAlign: "center"
},
blurb: {
lineHeight: 18,
textAlign: "center",
marginBottom: 12
},
premiumButton: {
marginTop: 20,
alignSelf: "center",
paddingLeft: 5,
paddingRight: 10,
flexGrow: 0
},
nitroWheel: {
width: 32
},
stickersRow: {
flexDirection: "row",
alignSelf: "center"
},
sticker: {
paddingHorizontal: 2
}
});
export default () => {
const styles = useStyles();
useFetchStickerPacks();
const analyticsLocations = useAnalyticsLocations(AnalyticsLocation.EMPTY_STATE).analyticsLocations;
const stateFromStoresArray = useStateFromStoresArray([StickersStore], () => EMPTY_STATE_STICKERS.map((item) => StickersStore.getStickerById(item)).filter((item) => item != null));
const [state, setState] = useState(null);
useEffect(() => {
AnalyticsUtils.track(AnalyticEvents.PREMIUM_UPSELL_VIEWED, {
type: PremiumUpsellTypes.EMPTY_STICKER_PICKER_UPSELL,
source: {
section: AnalyticsSections.EMPTY_STICKER_PICKER_UPSELL
},
location_stack: analyticsLocations
});
}, [analyticsLocations]);
return <View>
<Text style={styles.header} accessibilityRole="header" variant="heading-lg/extrabold" color="mobile-text-heading-primary">
{intl.string(t.HEm04J)}
</Text>
<Text style={styles.blurb} variant="text-sm/medium" color="text-default">
{intl.string(t.FnNud4)}
</Text>
<View style={styles.stickersRow}>
{stateFromStoresArray.map((item) => {
return <PressableOpacity key={item?.id} accessible={false} onLongPress={() => {
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
setState(item.id);
}} style={styles.sticker}>
<EmptyStateSticker sticker={item} isFocused={state === item.id} />
</PressableOpacity>;
})}
</View>
<View style={styles.premiumButton}>
<Button icon={<FastImage source={Module9377} style={styles.nitroWheel} resizeMode="contain" />} text={intl.string(t.pj0XBN)} variant="active" size="sm" onPress={() => openStickersPremiumUpsellAlert({
section: AnalyticsSections.EXPRESSION_PICKER
})} />
</View>
</View>;
};
@@ -0,0 +1,253 @@
// Metro module 9650 (f9651).
import * as Module19 from "react";
import { useRef, useState, useMemo, useEffect, useCallback } from "react";
import { View } from "react-native";
import StickersStore from "../StickersStore";
import { useStickerPickerStore } from "./StickerPickerStore";
import { STICKER_SCROLL_LOAD_DELAY_AFTER_HEIGHT_CHANGE_MS, STICKER_SCROLL_LOAD_DELAY_MS, STICKER_SIZE } from "./StickerPickerConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Icon } from "../../../design/void/native";
import Module9651 from "../../../_bundle/Module9651";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import { StickerFormat } from "../StickersTypes";
import { useIsPortalKeyboardInModal } from "../../keyboard/native/PortalKeyboardModalContext";
import useExpressionPickerListWidth_native from "../../expression_picker/native/useExpressionPickerListWidth.native";
import { useStateFromStores } from "../../../_bundle/Module589";
import useStickerPickerListData, { StickerPickerSectionType } from "./useStickerPickerListData";
import StickerPickerListRow from "./StickerPickerListRow";
import Module12 from "../../../_bundle/Module12";
import { FastestListPropsPlaceholderType } from "../../fastest_list/props/FastestListPropsPlaceholder";
import StickerPickerListEmptyState from "./StickerPickerListEmptyState";
import FastestList_android from "../../fastest_list/FastestList.android";
import { getCustomKeyboardHeight } from "../../keyboard/native/useCustomKeyboardHeight";
let Component, Component2;
const useStyles = createStyles({
listPlaceholder: {
color: Module712.colors.BACKGROUND_MOD_MUTED
},
section: {
justifyContent: "center",
overflow: "hidden",
backgroundColor: Module712.colors.MOBILE_ACTIONSHEET_BACKGROUND
},
sectionSticker: {
backgroundColor: Module712.colors.MOBILE_EXPRESSION_PICKER_BACKGROUND_DEFAULT
},
nsfwContainer: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
borderRadius: Module712.radii.sm,
marginLeft: 12,
marginRight: 12,
backgroundColor: Module712.colors.BACKGROUND_MOD_NORMAL
},
nsfwText: {
marginLeft: 4,
textAlign: "center"
}
});
let Component3 = Module19.memo(function({ height }) {
const styles2 = useStyles();
return <View style={[styles2.nsfwContainer, {
height
}]}>
<Icon source={Module9651} size={Icon.Sizes.SMALL} />
<Text style={styles2.nsfwText} variant="text-sm/normal" color="interactive-text-active">
{intl.string(t.uy25Qz)}
</Text>
</View>;
});
Component = Module19.memo(function({ height, label, sectionStyle }) {
return <View style={[useStyles().section, sectionStyle, {
height
}]}>
<Text lineClamp={1} color="interactive-text-default" variant="heading-sm/semibold">{label}</Text>
</View>;
});
Component2 = Module19.memo(function(a0) {
return <View style={{
height: a0.height
}} />;
});
const r75 = Module19.memo(function(a0) {
let stickerPickerStore, memo, sectionHeights, sectionSize, sectionFooterSize, sectionLabels, rowsBySection, rowHeight, rowSize, packToScrollToIndex, setCategory;
const { bottomSheetRef, bottomSheetIndex, setCategoryIndex, searchResults, onPressSticker, onLongPressStickerDetail, insetBottom = 0, insetTop = 0, channel, inPortalKeyboard = false } = a0;
let c17373_6 = inPortalKeyboard;
let stickerFormats = a0.stickerFormats;
if (stickerFormats === void 0) {
stickerFormats = [StickerFormat.PNG, StickerFormat.APNG, StickerFormat.LOTTIE, StickerFormat.GIF];
}
stickerPickerStore = void 0;
memo = void 0;
sectionHeights = void 0;
sectionSize = void 0;
sectionFooterSize = void 0;
sectionLabels = void 0;
rowsBySection = void 0;
rowHeight = void 0;
rowSize = void 0;
packToScrollToIndex = void 0;
setCategory = void 0;
const ref = useRef(null);
const styles = useStyles();
const [state, setState] = useState(null);
const isPortalKeyboardInModal = useIsPortalKeyboardInModal();
const containerWidth = useExpressionPickerListWidth_native(inPortalKeyboard);
const stateFromStores = useStateFromStores([StickersStore], () => StickersStore.hasLoadedStickerPacks);
stickerPickerStore = useStickerPickerStore((a0) => a0.setPackToScrollTo);
memo = useMemo(() => {
let c26499_0;
const scrollToCancel2 = function scrollToCancel() {
return clearTimeout(c26499_0.scrollTo);
};
c26499_0 = {
scrollTo: -1
};
return {
scroll: function scroll({ index, delay, expand }) {
const r10 = clearTimeout;
r10(c26499_0.scrollTo);
if (expand) {
const current = bottomSheetRef.current;
if (current != null) {
current.expandActionSheet();
}
}
c26499_0.scrollTo = setTimeout(() => {
const current = ref.current;
if (current != null) {
current.scrollToLocation({
section: index,
item: 0,
animated: true
});
}
stickerPickerStore(null);
}, delay);
setCategoryIndex(index);
},
cancel: () => scrollToCancel2
};
}, [setCategoryIndex, stickerPickerStore, bottomSheetRef]);
const stickerPickerListData = useStickerPickerListData({
channel,
containerWidth,
searchResults,
stickerFormats
});
const sections = stickerPickerListData.sections;
sectionHeights = stickerPickerListData.sectionHeights;
sectionSize = stickerPickerListData.sectionSize;
sectionFooterSize = stickerPickerListData.sectionFooterSize;
sectionLabels = stickerPickerListData.sectionLabels;
rowsBySection = stickerPickerListData.rowsBySection;
rowHeight = stickerPickerListData.rowHeight;
rowSize = stickerPickerListData.rowSize;
packToScrollToIndex = stickerPickerListData.packToScrollToIndex;
useEffect(() => {
const r3 = packToScrollToIndex != null && stateFromStores;
L7: {
if (r3) {
if (c17373_6 && bottomSheetIndex.get() < 1) {
memo.scroll({
index: packToScrollToIndex,
delay: STICKER_SCROLL_LOAD_DELAY_AFTER_HEIGHT_CHANGE_MS,
expand: true
});
break L7;
}
memo.scroll({
index: packToScrollToIndex,
delay: STICKER_SCROLL_LOAD_DELAY_MS
});
}
}
return () => {
memo.cancel();
};
}, [inPortalKeyboard, bottomSheetIndex, stateFromStores, packToScrollToIndex, memo]);
const callback = useCallback((a0) => <Component label={sectionLabels[a0]} sectionStyle={styles.sectionSticker} height={sectionSize} />, [sectionLabels, sectionSize, styles.sectionSticker]);
const callback2 = useCallback(() => <Component2 height={sectionFooterSize} />, [sectionFooterSize]);
const callback3 = useCallback((a0, a1) => {
const r4 = rowsBySection[a0];
if (r4 == null) {
return null;
}
const type = r4.type;
if (StickerPickerSectionType.STICKERS === type) {
return <StickerPickerListRow containerWidth={containerWidth} stickers={r4.stickersByRow[a1]} rowSize={rowSize} onPressSticker={onPressSticker} onLongPressStickerDetail={onLongPressStickerDetail} focusedSticker={state} setFocusedSticker={setState} channel={channel} />;
}
if (StickerPickerSectionType.NSFW === type) {
return <Component3 height={rowHeight} />;
}
return null;
}, [channel, containerWidth, state, onLongPressStickerDetail, onPressSticker, rowHeight, rowSize, rowsBySection]);
const memo2 = useMemo(() => {
let c26500_0;
const setCategory2 = Module12.debounce((a0) => {
let r16;
const r6 = 0 < sectionHeights.length;
let r4 = 0;
if (r6) {
const r13 = a0 >= sectionHeights[0];
let r1 = 0;
let r0 = 0;
r4 = 0;
if (r13) {
do {
const r14 = r0 + 1;
const r3 = r1 + 1;
const length = sectionHeights.length;
r4 = r14;
if (!(r3 < length)) {
break;
}
r16 = sectionHeights[r3];
r1 = r3;
r0 = r14;
r4 = r0;
} while (a0 >= r16);
}
}
setCategoryIndex(r4);
}, 100);
c26500_0 = setCategory2;
return {
onScroll: function onScroll(a0) {
c26500_0(a0.nativeEvent.contentOffset.y);
a0.nativeEvent.layoutMeasurement.height;
a0.nativeEvent.contentOffset.y;
a0.nativeEvent.contentSize.height;
},
setCategory: setCategory2
};
}, [setCategoryIndex, sectionHeights]);
const onScroll2 = memo2.onScroll;
setCategory = memo2.setCategory;
const memo3 = useMemo(() => ({
sectionHeader: {
type: FastestListPropsPlaceholderType.SHAPE,
colorHex: styles.listPlaceholder.color,
shape: "rect",
borderRadius: Module712.radii.md,
paddingVertical: Module712.space.PX_4
},
sectionItem: {
type: FastestListPropsPlaceholderType.SHAPE,
colorHex: styles.listPlaceholder.color,
shape: "circle",
shapeCount: rowSize,
width: STICKER_SIZE,
height: STICKER_SIZE
}
}), [styles, rowSize]);
useEffect(() => () => setCategory.cancel(), [setCategory]);
useEffect(() => () => {
memo.cancel();
}, [memo]);
return searchResults?.length === 0 ? <StickerPickerListEmptyState inActionSheet insetTop={insetTop} insetBottom={insetBottom} /> : <FastestList_android accessibilityLabel={intl.string(t.nf1s3u)} estimatedListSize={getCustomKeyboardHeight()} inActionSheet preventNativeModalDismiss={isPortalKeyboardInModal} insetEnd={insetBottom} insetStart={insetTop} itemSize={rowHeight} keyboardShouldPersistTaps="always" listId="sticker-picker-list" onScroll={onScroll2} placeholderConfig={memo3} renderItem={callback3} renderSectionHeader={callback} renderSectionFooter={callback2} ref={ref} scrollReporting="callbacks" sections={sections} sectionHeaderSize={sectionSize} sectionFooterSize={sectionFooterSize} />;
});
export default r75;
@@ -0,0 +1,45 @@
// Metro module 9653 (f9654).
import * as Module19 from "react";
import { useMemo } from "react";
import { ScrollView } from "react-native";
import { EXPRESSION_FOOTER_HEIGHT } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useModalDismissGuardRefreshControl } from "../../keyboard/native/useModalDismissGuardRefreshControl";
import { BottomSheetScrollView } from "../../../_bundle/Module5245";
import { RefreshEmptyState } from "../../../design/void/native";
import { intl, t } from "../../../intl/index.native";
import Module9654 from "../../../_bundle/Module9654";
const useStyles = createStyles({
emptyStateContainer: {
padding: 0,
flex: 1
},
emptyStateBody: {
color: Module712.colors.TEXT_SUBTLE
},
emptyStateImage: {
marginBottom: Module712.space.PX_8,
marginTop: 0
}
});
const r42 = Module19.memo(function StickerPickerListEmptyState(props) {
const { inActionSheet, insetTop, insetBottom } = props;
const styles = useStyles();
const memo = useMemo(() => ({
marginBottom: insetBottom + EXPRESSION_FOOTER_HEIGHT,
marginTop: insetTop,
flex: 1
}), [insetBottom, insetTop]);
const modalDismissGuardRefreshControl = useModalDismissGuardRefreshControl();
return inActionSheet ? <BottomSheetScrollView contentContainerStyle={memo} keyboardShouldPersistTaps="always" refreshControl={inActionSheet ? modalDismissGuardRefreshControl : void 0}>
<RefreshEmptyState body={intl.string(t.jyiGfc)} bodyStyle={styles.emptyStateBody} containerStyle={styles.emptyStateContainer} imageStyle={styles.emptyStateImage} source={Module9654} titleStyle={{
marginBottom: 0
}} />
</BottomSheetScrollView> : <ScrollView contentContainerStyle={memo} keyboardShouldPersistTaps="always" refreshControl={inActionSheet ? modalDismissGuardRefreshControl : void 0}>
<RefreshEmptyState body={intl.string(t.jyiGfc)} bodyStyle={styles.emptyStateBody} containerStyle={styles.emptyStateContainer} imageStyle={styles.emptyStateImage} source={Module9654} titleStyle={{
marginBottom: 0
}} />
</ScrollView>;
});
export default r42;
@@ -0,0 +1,160 @@
// Metro module 9634 (f9635).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import { View } from "react-native";
import UserStore from "../../../stores/UserStore";
import { StickerAnimationSettings } from "../StickersConstants";
import { STICKER_SIZE, ROW_HEIGHT } from "./StickerPickerConstants";
import { PADDING_VERTICAL } from "../../expression_picker/ExpressionPickerConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { isAndroid } from "../../../utils/PlatformUtils";
import { AnimateStickers } from "../../user_settings/UserSettings";
import { triggerHapticFeedback } from "../../haptics/HapticUtils.native";
import HapticFeedbackTypes from "../../haptics/HapticFeedbackTypes";
import { shouldAnimateSticker } from "../StickersUtils";
import { isSendableSticker } from "../StickerSendability";
import { StickerFormat } from "../StickersTypes";
import Sticker, { getStickerAssetUrl } from "./Sticker";
import Module9638 from "../../../_bundle/Module9638";
import SentryUtils_native from "../../../utils/SentryUtils.native";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
const useStyles = createStyles({
row: {
height: ROW_HEIGHT,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
overflow: "hidden"
},
stickerImage: {
height: STICKER_SIZE,
width: STICKER_SIZE
}
});
export default function StickerPickerListRow(props) {
let r89;
let styles, setting, c17364_9, c17364_10;
const { containerWidth, stickers, rowSize, onPressSticker: onPressSticker2, onLongPressStickerDetail, focusedSticker, setFocusedSticker, channel, nativeRow = isAndroid() } = props;
styles = void 0;
setting = void 0;
c17364_9 = void 0;
c17364_10 = void 0;
const handleOnLongPressSticker2 = function handleOnLongPressSticker(a0) {
if (onLongPressStickerDetail != null) {
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
onLongPressStickerDetail(a0);
return void 0;
}
if (AnimateStickers.getSetting() === StickerAnimationSettings.ANIMATE_ON_INTERACTION) {
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
if (setFocusedSticker != null) {
setFocusedSticker(a0);
}
}
};
const rowTraits = function rowTraits(a0) {
return [shouldAnimateSticker(setting, a0.id === focusedSticker?.id), channel == null || isSendableSticker(a0, UserStore.getCurrentUser(), channel), onPressSticker2 == null];
};
styles = useStyles();
setting = AnimateStickers.useSetting();
const items = [];
if (nativeRow) {
const r53 = 0 < rowSize;
let r56 = 0;
if (r53) {
do {
const r25 = stickers[r56];
const r57 = r56;
if (r25 !== void 0) {
const [stickerAnimated, stickerOpaque, stickerDisabled] = rowTraits(r25);
items.push({
stickerId: r25.id,
stickerName: r25.name,
stickerType: r25.format_type,
stickerUrl: getStickerAssetUrl(r25, STICKER_SIZE, stickerAnimated),
stickerAnimated,
stickerDisabled,
stickerOpaque
});
} else {
items.push({
stickerId: null,
stickerName: "",
stickerType: StickerFormat.PNG,
stickerUrl: "",
stickerAnimated: false,
stickerDisabled: true,
stickerOpaque: false
});
}
r56 = r57 + 1;
} while (r56 < rowSize);
}
try {
r89 = <Module9638 style={styles.row} rowData={{
rowContentWidth: containerWidth,
rowContentPaddingVertical: PADDING_VERTICAL,
itemSize: STICKER_SIZE,
items
}} onPressSticker={(c26494_0) => {
const r10 = stickers.find((sticker) => sticker.id === c26494_0.nativeEvent.stickerId);
if (r10 != null) {
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
if (onPressSticker2 != null) {
onPressSticker2(r10);
}
}
}} onLongPressSticker={(c26495_0) => {
const r8 = stickers.find((sticker) => sticker.id === c26495_0.nativeEvent.stickerId);
if (r8 != null) {
handleOnLongPressSticker2(r8);
}
}} />;
} catch (r90) {
SentryUtils_native.addBreadcrumb({
message: "Error in StickerPickerListRowNativeComponent",
category: "sticker",
data: {
itemLength: items.length,
items: items.filter((item) => item.stickerId == null || item.stickerName == null || item.stickerUrl == null).map((item) => ({
stickerId: item.stickerId,
stickerName: item.stickerName,
stickerUrl: item.stickerUrl
}))
}
});
throw r90;
}
return r89;
}
c17364_9 = items;
const _loop = function _loop() {
const key = c17364_10;
const sticker = stickers[key];
let c26493_0 = sticker;
if (sticker === void 0) {
c17364_9.push(<View key={key} style={styles.stickerImage} />);
return 1;
}
const r34 = _slicedToArray([shouldAnimateSticker(setting, sticker.id === focusedSticker?.id), channel == null || isSendableSticker(sticker, UserStore.getCurrentUser(), channel), onPressSticker2 == null], 3);
c17364_9.push(<PressableOpacity key={sticker.id} accessibilityRole="button" accessibilityLabel={sticker.name} style={styles.stickerImage} disabled={r34[2]} onPress={() => {
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
if (onPressSticker2 != null) {
onPressSticker2(c26493_0);
}
}} onLongPress={() => handleOnLongPressSticker2(c26493_0)}>
<Sticker key={key} sticker={sticker} size={STICKER_SIZE} animated={r34[0]} opaque={r34[1]} />
</PressableOpacity>);
};
c17364_10 = 0;
const r14 = 0 < rowSize;
let r45 = 0;
if (r14) {
do {
_loop();
const r47 = r45 + 1;
c17364_10 = r47;
r45 = r47;
} while (r45 < rowSize);
}
return <View style={styles.row}>{items}</View>;
};
@@ -0,0 +1,12 @@
// Metro module 9623 (f9624).
import { create } from "../../../_bundle/Module644";
import { batchUpdates } from "../../../_bundle/Module705";
const r15 = create((c17361_0) => ({
packToScrollTo: null,
setPackToScrollTo: (packToScrollTo) => batchUpdates(() => {
c17361_0((a0) => a0.packToScrollTo !== packToScrollTo ? {
packToScrollTo
} : a0);
})
}));
export { r15 as useStickerPickerStore };
+48
View File
@@ -0,0 +1,48 @@
// Metro module 9622 (f9623).
import { useMemo } from "react";
import { NativeModules } from "react-native";
import GuildStore from "../../../stores/GuildStore";
import UserStore from "../../../stores/UserStore";
import { useStickerPickerStore } from "./StickerPickerStore";
import { GuildNSFWContentLevel } from "../../../Constants";
import { ExpressionPickerViewType } from "../../expression_picker/ExpressionPickerConstants";
import { useStickerPackCategories } from "../StickersHooks";
import { StickerCategoryTypes } from "../StickersTypes";
import Module9624 from "../../../_bundle/Module9624";
import Module9625 from "../../../_bundle/Module9625";
import { KeyboardTypes } from "../../keyboard/native/KeyboardTypes";
export function useStickerCategories(a0) {
const stickerPackCategories = useStickerPackCategories(a0);
const currentUser = UserStore.getCurrentUser();
const guilds = GuildStore.getGuilds();
return useMemo(() => stickerPackCategories.filter((stickerPackCategory) => stickerPackCategory.stickers.length > 0).filter((item) => {
const r8 = guilds[item.id];
return !!(item.type !== StickerCategoryTypes.GUILD || currentUser?.nsfwAllowed || r8 == null || r8.nsfwLevel !== GuildNSFWContentLevel.AGE_RESTRICTED && r8.nsfwLevel !== GuildNSFWContentLevel.EXPLICIT);
}).map((item) => {
if (item.type !== StickerCategoryTypes.FAVORITE && item.type !== StickerCategoryTypes.RECENT) {
return item;
}
return {
...item,
icon: item.type === StickerCategoryTypes.FAVORITE ? Module9624 : Module9625
};
}), [guilds, stickerPackCategories, currentUser]);
}
export function preloadSticker(a0) {
NativeModules.NativeLottieUtils.preload(a0.hash, a0.url, a0.width, a0.height, a0.frames, a0.callback);
}
export function dropPreloadedSticker(a0) {
NativeModules.NativeLottieUtils.dropPreload(a0);
}
export function openStickerPickerToPackId(c17360_0, a1) {
useStickerPickerStore.getState().setPackToScrollTo(a1);
setTimeout(() => {
const current = c17360_0.current;
if (current != null) {
current.openCustomKeyboard({
type: KeyboardTypes.EXPRESSION,
context: ExpressionPickerViewType.STICKER
});
}
}, 1);
}
@@ -0,0 +1,20 @@
// Metro module 9627 (f9628).
import { AnalyticEvents } from "../../../Constants";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
const r15 = {
EXPRESSION_SUGGESTIONS: "Sticker Pack Detail Sheet (Expression Suggestions Popout)",
STICKER_PACK_DETAIL: "Sticker Pack Detail Sheet",
STICKER_PACK_UPSELL: "Sticker Pack Detail Sheet (Sticker Upsell Popout)"
};
export default function openStickerPackDetailActionSheet({ analyticsLocation, analyticsPopoutType, stickerPack }) {
AnalyticsUtils.track(AnalyticEvents.STICKER_PACK_VIEW_ALL, {
location: analyticsLocation,
sticker_pack_id: stickerPack.id
});
ActionSheetActionCreators.openLazy(import("./StickerPackDetailActionSheet"), "StickerPackDetailActionSheet", {
stickerPack,
analyticsPopoutType
});
};
export { r15 as AnalyticsPopoutType };
@@ -0,0 +1,164 @@
// Metro module 9644 (f9645).
import { useEffect } from "react";
import { Image as Image2, ScrollView, View } from "react-native";
import IAPStore_android from "../../../../stores/native/IAPStore.android";
import { AnalyticEvents, AnalyticsObjects, AnalyticsSections } from "../../../../Constants";
import { NUM_FREE_GUILD_BOOSTS_WITH_PREMIUM, PRICE_PLACEHOLDER, SubscriptionPlans } from "../../../premium/PremiumConstants";
import Module9645 from "../../../../_bundle/Module9645";
import { intl, t } from "../../../../intl/index.native";
import Module712 from "../../../../_bundle/Module712";
import Module9646 from "../../../../_bundle/Module9646";
import Module9647 from "../../../../_bundle/Module9647";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import { Icon, ButtonColors } from "../../../../design/void/native";
import { Text } from "../../../../design/components/Text/native/Text";
import Dispatcher from "../../../../Dispatcher";
import BillingActionCreators from "../../../../actions/native/BillingActionCreators";
import usePremiumPlanPrice from "../../../premium/native/hooks/usePremiumPlanPrice";
import useWindowDimensions_native from "../../../screen/useWindowDimensions.native";
import useAnalyticsLocations from "../../../app_analytics/useAnalyticsLocations";
import Alert from "../../../../components_native/common/Alert";
import AnalyticsUtils from "../../../../utils/AnalyticsUtils";
import openPremiumModal from "../../../../components_native/premium/openPremiumModal";
import { PressableOpacity } from "../../../../design/void/Pressables/native/Pressables";
import Module7699 from "../../../../_bundle/Module7699";
import Module9648 from "../../../../_bundle/Module9648";
let c6379_16, useStyles;
const PerkRow = function PerkRow(props) {
const { perk, isLastPerk } = props;
const styles = useStyles();
return <View style={[styles.perkRow, isLastPerk ? styles.lastPerkRow : void 0]}>
<Icon style={styles.perkIcon} source={perk.icon} disableColor={perk.color == null} color={perk.color} />
<Text style={styles.perkText} variant="text-md/medium" color="interactive-text-active">
{perk.description()}
</Text>
</View>;
};
c6379_16 = [{
icon: Module9645,
description: () => intl.string(t.uAfKTe),
color: Module712.unsafe_rawColors.PREMIUM_PERK_PURPLE
}, {
icon: Module9646,
description: () => intl.formatToPlainString(t.aVSVBO, {
numFreeGuildSubscriptions: NUM_FREE_GUILD_BOOSTS_WITH_PREMIUM
})
}, {
icon: Module9647,
description: () => intl.string(t.pqHIf7),
color: Module712.unsafe_rawColors.PREMIUM_PERK_GREEN
}];
useStyles = createStyles({
alert: {
paddingTop: 18
},
shortHeightAlert: {
height: 500
},
content: {
alignItems: "center"
},
closeContainer: {
flexDirection: "row-reverse",
width: "100%",
marginBottom: 16
},
description: {
textAlign: "center",
lineHeight: 20
},
perks: {
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
borderRadius: Module712.radii.sm,
marginTop: 16,
marginBottom: 0,
paddingHorizontal: 12,
paddingVertical: 8,
width: "100%"
},
perkRow: {
paddingVertical: 10,
borderBottomColor: Module712.unsafe_rawColors.PRIMARY_560,
borderBottomWidth: 1,
flexDirection: "row",
alignItems: "center"
},
lastPerkRow: {
borderBottomWidth: 0
},
perkIcon: {
width: 24,
marginRight: 20
},
perkText: {
lineHeight: 20,
flexShrink: 1
},
imageHeader: {
marginBottom: 12
}
});
export default function StickersPremiumUpsellAlert(props) {
let analyticsLocations;
const { onClose, analyticsLocation } = props;
analyticsLocations = void 0;
const styles = useStyles();
useEffect(() => {
if (!IAPStore_android.isReady()) {
Dispatcher.wait(() => BillingActionCreators.loadProducts());
}
}, []);
let monthlyPrice = usePremiumPlanPrice(SubscriptionPlans.PREMIUM_MONTH_TIER_2)?.priceString;
const height = useWindowDimensions_native().height;
analyticsLocations = useAnalyticsLocations().analyticsLocations;
const props2 = {
cancelText: intl.string(t.f3Pet9),
confirmColor: ButtonColors.GREEN,
confirmText: intl.string(t.o3Tnif),
onConfirm: function onConfirm() {
AnalyticsUtils.track(AnalyticEvents.PREMIUM_PROMOTION_OPENED, {
location: {
...analyticsLocation,
section: AnalyticsSections.STICKER_PREMIUM_TIER_2_UPSELL_MODAL,
object: AnalyticsObjects.BUTTON_CTA
}
});
openPremiumModal({
analyticsLocations
});
},
onClose,
onCancel: onClose,
style: [styles.alert, height <= 580 ? styles.shortHeightAlert : null],
children: null
};
const children = [<View style={styles.closeContainer}>
<PressableOpacity accessibilityRole="button" accessibilityLabel="close" onPress={onClose}>
<Icon source={Module7699} />
</PressableOpacity>
</View>, ,];
const props3 = {
style: styles.content,
onStartShouldSetResponder: () => true,
children: null
};
const children2 = [<Image2 source={Module9648} style={styles.imageHeader} />, , ,];
const TBsJfQ = t.TBsJfQ;
if (monthlyPrice == null) {
monthlyPrice = PRICE_PLACEHOLDER;
}
children2[1] = <Text style={styles.description} variant="text-md/medium">
{intl.format(TBsJfQ, {
monthlyPrice
})}
</Text>;
children2[2] = <View style={styles.perks}>
{c6379_16.map((item, index) => <PerkRow key={index} perk={item} isLastPerk={index === c6379_16.length - 1} />)}
</View>;
props3.children = children2;
children[1] = <ScrollView>
<View {...props3} />
</ScrollView>;
props2.children = children;
return <Alert {...props2} />;
};
@@ -0,0 +1,40 @@
// Metro module 9643 (f9644).
import { AnalyticEvents, AnalyticsSections } from "../../../../Constants";
import AnalyticsUtils from "../../../../utils/AnalyticsUtils";
import { fetchPremiumSubscriptionPlans } from "../../../../actions/SubscriptionPlanActionCreators";
import { fetchPaymentSources } from "../../../billing/actions/BillingActionCreators";
import AlertActionCreators from "../../../../actions/native/AlertActionCreators";
function $mk115519($env) {
return () => import("./StickersPremiumUpsellAlert").then($mk118134($env));
}
function $mk118134($env) {
return (a0) => {
let env31990 = {
$parent: $env
};
env31990[0] = a0.default;
return (a0) => env31990.$parent.$parent[6](env31990[0], {
...a0,
analyticsLocation: env31990.$parent[0]
});
};
}
let env6378 = {};
export default async function openStickersPremiumUpsellAlert(location2) {
let env30129;
const r12 = env6378;
let c26497_2 = r12;
const r27 = env30129 = {
$parent: r12
};
let c26497_1 = r27;
env30129[0] = location2;
AnalyticsUtils.track(AnalyticEvents.OPEN_MODAL, {
type: AnalyticsSections.STICKER_PREMIUM_TIER_2_UPSELL_MODAL,
location: location2
});
await Promise.all([fetchPremiumSubscriptionPlans(), fetchPaymentSources()]);
AlertActionCreators.openLazy({
importer: $mk115519(c26497_1)
});
};
@@ -0,0 +1,9 @@
// Metro module 9639 (f9640).
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
let c6374_3 = "sticker_detail_action_sheet";
export function hideStickerDetailActionSheet() {
ActionSheetActionCreators.hideActionSheet(c6374_3);
}
export function showStickerDetailActionSheet(a0) {
ActionSheetActionCreators.openLazy(import("./StickerDetailActionSheet"), c6374_3, a0);
}
@@ -0,0 +1,113 @@
// Metro module 9652 (f9653).
import { useMemo } from "react";
import { useStickerPickerStore } from "./StickerPickerStore";
import { LABEL_HEIGHT, MIN_MARGIN, STICKER_SIZE, ROW_HEIGHT } from "./StickerPickerConstants";
import { PADDING_VERTICAL } from "../../expression_picker/ExpressionPickerConstants";
import { useStickerCategories } from "./StickersUtils";
import Module12 from "../../../_bundle/Module12";
import { intl, t } from "../../../intl/index.native";
import { StickerCategoryTypes } from "../StickersTypes";
import { shouldNSFWGateGuild } from "../../age_gate/native/AgeGateUtils";
function $mk115521($env) {
return (a0) => $env[2].includes(a0.format_type);
}
let env6382 = {};
const c6382_8 = {
STICKERS: 0,
0: "STICKERS",
NSFW: 1,
1: "NSFW"
};
const c6382_9 = LABEL_HEIGHT + 2 * PADDING_VERTICAL;
export default function useStickerPickerListData(a0) {
let env17374 = {
$parent: env6382
};
const { channel, containerWidth } = a0;
env17374[0] = containerWidth;
const searchResults = a0.searchResults;
env17374[1] = searchResults;
const stickerFormats = a0.stickerFormats;
env17374[2] = stickerFormats;
env17374[3] = void 0;
env17374[4] = void 0;
const stickerCategories = useStickerCategories(channel);
env17374[3] = stickerCategories;
const r16 = (0, useStickerPickerStore)((a0) => a0.packToScrollTo);
env17374[4] = r16;
return useMemo(() => {
let packToScrollToIndex;
const r12 = env17374;
const rowSize = Math.floor((env17374[0] - MIN_MARGIN) / (STICKER_SIZE + MIN_MARGIN));
let c26501_0 = rowSize;
const sections = [];
let c26501_1 = sections;
const sectionHeights = [];
const sectionLabels = [];
let c26501_2 = sectionLabels;
const rowsBySection = [];
let c26501_3 = rowsBySection;
packToScrollToIndex = void 0;
const r14 = env17374[1];
if (r14 != null) {
let r48 = intl.string(t["zkoeq/"]);
if (r48 === void 0) {
r48 = "";
}
const stickersByRow = Module12.chunk(r14.filter($mk115521(r12)), rowSize);
rowsBySection.push({
type: c6382_8.STICKERS,
stickersByRow
});
sections.push(stickersByRow.length);
sectionLabels.push(r48);
} else {
let c26502_0;
env17374[3].map((item, index) => {
const r6 = env17374;
if (env17374[4] === item.id) {
packToScrollToIndex = index;
}
const r18 = item.type === StickerCategoryTypes.GUILD && shouldNSFWGateGuild(item.id);
const { stickers, name = "" } = item;
if (r18 === true) {
c26501_3.push({
type: c6382_8.NSFW,
stickersByRow: []
});
c26501_1.push(1);
} else {
const stickersByRow = Module12.chunk(stickers.filter($mk115521(r6)), c26501_0);
c26501_3.push({
type: c6382_8.STICKERS,
stickersByRow
});
c26501_1.push(stickersByRow.length);
}
c26501_2.push(name);
});
const push = sectionHeights.push;
c26502_0 = 0;
push.apply(sectionHeights, [...sections.map((section, index) => {
if (index === 0 && section === 0) {
return 0;
}
const r12 = section * ROW_HEIGHT + c6382_9 + 12 + c26502_0;
c26502_0 = r12;
return r12;
})]);
}
return {
sections,
sectionHeights,
sectionSize: c6382_9,
sectionFooterSize: 12,
sectionLabels,
rowHeight: ROW_HEIGHT,
rowSize,
rowsBySection,
packToScrollToIndex
};
}, [containerWidth, stickerCategories, stickerFormats, searchResults, r16]);
};
export { c6382_8 as StickerPickerSectionType };
@@ -0,0 +1,71 @@
// Metro module 16410 (f16411).
import { useState, useEffect } from "react";
import UserStore from "../../stores/UserStore";
import GuildStickersStore from "./GuildStickersStore";
import { useStateFromStores } from "../../_bundle/Module589";
import { fetchGuildStickersWithCreator } from "./StickersActionCreators";
export default function useLoadGuildStickersWithCreator(a0) {
const [status, setState] = useState("loading");
const stateFromStores = useStateFromStores([GuildStickersStore], () => GuildStickersStore.getStickersByGuildId(a0));
useEffect(() => {
let c28376_0, signal;
let _fetch2 = function _fetch() {
const r9 = async () => {
let c31827_3 = 0;
L10: {
try {
c31827_3 = 1;
await fetchGuildStickersWithCreator(a0, signal);
(0, setState)("success");
c28376_0 = null;
c31827_3 = 0;
} catch ($e) {
let r7 = $e;
if (c31827_3 !== 0) {
while (true) {
try {
c31827_3 = 0;
(0, setState)("error");
c28376_0 = null;
break L10;
} catch ($e) {
r7 = $e;
if (c31827_3 === 0) {
break;
}
}
}
}
throw r7;
}
}
};
_fetch2 = r9;
return r9.apply(this, arguments);
};
const abortController = new AbortController();
c28376_0 = abortController;
signal = abortController.signal;
(function() {
return _fetch2.apply(this, arguments);
})();
return () => {
setState("loading");
if (c28376_0 != null) {
c28376_0.abort();
}
};
}, [a0]);
return status === "success" ? {
status,
stickers: stateFromStores.map((stateFromStore) => {
const user = UserStore.getUser(stateFromStore.user_id);
return user != null ? {
...stateFromStore,
user
} : stateFromStore;
})
} : {
status
};
};