Files
discord-decomp/sources/actions/EmojiActionCreators.tsx
T
2026-07-27 16:20:00 +03:00

492 lines
21 KiB
TypeScript

/* Metro module 8629; source: actions/EmojiActionCreators.tsx; dependencies: [5, 6540, 4257, 4646, 661, 670, 1362, 1345, 694, 507, 7618, 4002, 1244, 4132, 3797, 1360, 6546, 22, 4647, 2] */
function _fun68075(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#68075, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:6, offset: 0x01c3ddb3, size: 333 bytes, params: 8, frame: 19
let env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(5) /* metro dependency 5 */;
const emojiStore = importDefault(6540) /* metro dependency 6540: EmojiStore */;
const gatewayConnectionStore = importDefault(4257) /* metro dependency 4257: GatewayConnectionStore */;
const guildAvailabilityStore = importDefault(4646) /* metro dependency 4646: GuildAvailabilityStore */;
const env0_7 = (require(661) /* metro dependency 661: Constants */).Endpoints;
const userSettingsConstantsModule = require(670) /* metro dependency 670: UserSettingsConstants */;
const env0_8 = userSettingsConstantsModule.MAX_FAVORITES;
const env0_9 = userSettingsConstantsModule.UserSettingsDelay;
(require(2) /* metro dependency 2 */).fileFinishedImporting('actions/EmojiActionCreators.tsx');
exports.setDiversityColor = function(a0) {
var env0_0 = a0;
var PreloadedUserSettingsActionCreators = require(dependencyMap[6]).PreloadedUserSettingsActionCreators;
var FREQUENT_USER_ACTION = UserSettingsDelay.FREQUENT_USER_ACTION;
PreloadedUserSettingsActionCreators.updateAsync('textAndImages', _fun68083, FREQUENT_USER_ACTION);
};
exports.fetchEmoji = fetchEmoji;
exports.uploadEmoji = uploadEmoji;
exports.deleteEmoji = deleteEmoji;
exports.updateEmoji = function() {
return _updateEmoji.apply(this, arguments);
};
exports.favoriteEmoji = function(a0) {
var value2 = getFavoriteEmojiNameOrId(a0);
var env0_0 = value2;
if (value2 != null) {
require(dependencyMap[6]).FrecencyUserSettingsActionCreators.updateAsync('favoriteEmojis', _fun68094,
UserSettingsDelay.INFREQUENT_USER_ACTION);
}
};
exports.unfavoriteEmoji = function(a0) {
var value2 = getFavoriteEmojiNameOrId(a0);
var env0_0 = value2;
if (value2 != null) {
require(dependencyMap[6]).FrecencyUserSettingsActionCreators.updateAsync('favoriteEmojis', _fun68096,
UserSettingsDelay.INFREQUENT_USER_ACTION);
}
};
}
function _updateEmoji() { // fn#68076, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:208, offset: 0x01c3df00, size: 50 bytes, params: 1, frame: 14
return env0_3(_fun68078).apply(this, arguments);
}
function dedupeFavoriteEmojis(a0) { // fn#68079, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:482, offset: 0x01c3e017, size: 148 bytes, params: 2, frame: 19
var value2;
var items2;
var value;
if (!(GuildAvailabilityStore.totalUnavailableGuilds > 0)) {
if (GatewayConnectionStore.isConnected()) {
value2 = a0.map(_fun68080);
value = (importDefault(6546) /* metro dependency 6546: dedupeEmojisByNameOrId */)(value2.filter((require(1360) /* metro dependency 1360: GlobalUtils */).isNotNullish));
value = value.keys();
items2 = [];
arraySpread(items2, value, 0, require);
return items2;
}
}
return a0;
}
function getFavoriteEmojiNameOrId(a0) { // fn#68081, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:734, offset: 0x01c3e0e9, size: 93 bytes, params: 2, frame: 16
var r1;
var r0;
var id;
var value3;
var defaultImport;
var value4;
const value = null;
if (value == a0) {
r0 = value;
} else {
id = a0.id;
if (value != id) {
r1 = id;
} else {
value3 = undefined;
defaultImport = importDefault(3797) /* metro dependency 3797: UnicodeEmojis */;
value4 = defaultImport.convertSurrogateToBase(a0.surrogates);
r1 = value == value4 ? value3 : value4.name;
}
r1 = value == r1 ? a0.name : r1;
r0 = r1;
}
return r0;
}
function setDiversityColor(a0) { // fn#68082, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:994, offset: 0x01c3e146, size: 76 bytes, params: 2, frame: 16
const env0_0 = a0;
const PreloadedUserSettingsActionCreators = (require(1362) /* metro dependency 1362: UserSettingsProtoActionCreators */).PreloadedUserSettingsActionCreators;
const updateAsync = PreloadedUserSettingsActionCreators.updateAsync;
const FREQUENT_USER_ACTION = UserSettingsDelay.FREQUENT_USER_ACTION;
Reflect.apply(updateAsync, PreloadedUserSettingsActionCreators, ['textAndImages', _fun68083, FREQUENT_USER_ACTION]);
}
function fetchEmoji(a0) { // fn#68084, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:1221, offset: 0x01c3e1d8, size: 149 bytes, params: 2, frame: 18
var object2;
const env0_0 = a0;
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'EMOJI_FETCH', guildId: a0});
const HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP;
const get = HTTP.get;
object2 = {'url': null, 'oldFormErrors': true, 'rejectWithError': true};
object2.url = Endpoints.GUILD_EMOJIS(a0);
Reflect.apply(get, HTTP, [object2]).then(_fun68085, _fun68086);
}
function uploadEmoji({guildId, image, name, roles, analyticsLocation, originalMd5}) { // fn#68087, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:1532, offset: 0x01c3e2f2, size: 261 bytes, params: 2, frame: 24
var object2;
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'EMOJI_UPLOAD_START', guildId: guildId});
const HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP;
const post = HTTP.post;
object2 = {};
object2.url = Endpoints.GUILD_EMOJIS(guildId);
object2.body = {image: image, name: name, roles: roles};
object2.headers = (importDefault(7618) /* metro dependency 7618: InlineUploader */).buildHeadersForMd5(originalMd5);
object2.context = {client_event_source: analyticsLocation?.page};
object2.oldFormErrors = true;
object2.rejectWithError = false;
return Reflect.apply(post, HTTP, [object2]).then(_fun68088, _fun68089);
}
function deleteEmoji(a0, a1, a2) { // fn#68090, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:2057, offset: 0x01c3e48d, size: 176 bytes, params: 4, frame: 19
var object2;
const value2 = undefined;
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'EMOJI_DELETE', guildId: a0,
emojiId: a1});
const HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP;
const del = HTTP.del;
object2 = {};
object2.url = Endpoints.GUILD_EMOJI(a0, a1);
object2.body = a2 != null ? {replaced_by: a2} : value2;
object2.oldFormErrors = true;
object2.rejectWithError = false;
return Reflect.apply(del, HTTP, [object2]).then(function() {
var AccessibilityAnnouncer = require(dependencyMap[11]).AccessibilityAnnouncer;
AccessibilityAnnouncer.announce(require(dependencyMap[12]).intl.string(require(dependencyMap[12]).t.L3UUha));
});
}
function favoriteEmoji(a0) { // fn#68093, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:2462, offset: 0x01c3e59a, size: 91 bytes, params: 2, frame: 16
var FrecencyUserSettingsActionCreators;
if (getFavoriteEmojiNameOrId(a0) != null) {
FrecencyUserSettingsActionCreators = (require(1362) /* metro dependency 1362: UserSettingsProtoActionCreators */).FrecencyUserSettingsActionCreators;
FrecencyUserSettingsActionCreators.updateAsync('favoriteEmojis', _fun68094,
UserSettingsDelay.INFREQUENT_USER_ACTION);
}
}
function unfavoriteEmoji(a0) { // fn#68095, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:2907, offset: 0x01c3e70d, size: 91 bytes, params: 2, frame: 16
var FrecencyUserSettingsActionCreators;
if (getFavoriteEmojiNameOrId(a0) != null) {
FrecencyUserSettingsActionCreators = (require(1362) /* metro dependency 1362: UserSettingsProtoActionCreators */).FrecencyUserSettingsActionCreators;
FrecencyUserSettingsActionCreators.updateAsync('favoriteEmojis', _fun68096,
UserSettingsDelay.INFREQUENT_USER_ACTION);
}
}
async function _fun68078({guildId, emojiId, name, roles}) { // fn#68078, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:255, offset: 0x01c3df46, size: 209 bytes, params: 2, frame: 21
var binding;
var binding2;
var property;
var value4;
var HTTP;
var patch;
var object3;
var GUILD_EMOJI;
var value5;
var object4;
var value6;
var value7;
var value8;
var error;
var prototype;
var value9;
if (false) {
return undefined;
}
await undefined;
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
try {
binding = env2_0;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
binding2 = env2_2;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
property = binding2[9];
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
value4 = binding(property);
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
HTTP = value4.HTTP;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
patch = HTTP.patch;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
object3 = {};
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
binding = env2_7;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
GUILD_EMOJI = binding.GUILD_EMOJI;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
value5 = Reflect.apply(GUILD_EMOJI, binding, [guildId, emojiId]);
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
object3.url = value5;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
object4 = {};
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
object4.name = name;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
object4.roles = roles;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
object3.body = object4;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
object3.oldFormErrors = true;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
object3.rejectWithError = true;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
try {
value6 = Reflect.apply(patch, HTTP, [object3]);
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
await value6;
try {
value7 = undefined;
value8 = false;
} catch (error) {
binding = env2_1;
value = binding(env2_2[13]);
prototype = value.prototype;
value9 = Object.create(prototype, {constructor: {value: value}});
value = new value();
value = value instanceof Object ? value : value9;
throw value;
}
return value8 ? value7 : value7;
}
function _fun68080(a0) { // fn#68080, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:596, offset: 0x01c3e0ab, size: 62 bytes, params: 2, frame: 13
var r0;
let value = environment.__proto__;
const customEmojiById = EmojiStore.getCustomEmojiById(a0);
if (customEmojiById != null) {
r0 = customEmojiById;
} else {
value = importDefault(3797) /* metro dependency 3797: UnicodeEmojis */;
value = value.getByName(a0);
r0 = value;
}
return r0;
}
function _fun68083(a0) { // fn#68083, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:1097, offset: 0x01c3e192, size: 70 bytes, params: 2, frame: 12
const StringValue = (require(1345) /* metro dependency 1345: wrappers */).StringValue;
a0.diversitySurrogate = StringValue.create();
a0.diversitySurrogate.value = env0_0;
}
function _fun68085({body}) { // fn#68085, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:1377, offset: 0x01c3e26d, size: 73 bytes, params: 2, frame: 12
const value = environment.__proto__;
return (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'EMOJI_FETCH_SUCCESS',
guildId: env0_0, emojis: body});
}
function _fun68086() { // fn#68086, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:1453, offset: 0x01c3e2b6, size: 60 bytes, params: 1, frame: 12
const value = environment.__proto__;
return (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'EMOJI_FETCH_FAILURE',
guildId: env0_0});
}
function _fun68088(a0) { // fn#68088, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:1892, offset: 0x01c3e3f7, size: 68 bytes, params: 2, frame: 12
const value = environment.__proto__;
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'EMOJI_UPLOAD_STOP', guildId: guildId});
return a0.body;
}
function _fun68089(a0) { // fn#68089, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:1961, offset: 0x01c3e43b, size: 82 bytes, params: 2, frame: 12
const value = environment.__proto__;
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'EMOJI_UPLOAD_STOP', guildId: guildId});
const Promise = global.Promise;
return Promise.reject(a0);
}
function _fun68094(a0) { // fn#68094, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:2604, offset: 0x01c3e5f5, size: 280 bytes, params: 2, frame: 21
var r0;
var value4;
var defaultImport2;
var show;
var object2;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
const value = environment.__proto__;
const dedupeFavoriteEmojisBinding = dedupeFavoriteEmojis;
const emojis = a0.emojis;
const value2 = undefined;
a0.emojis = dedupeFavoriteEmojisBinding(emojis);
const defaultImport = importDefault(22) /* metro dependency 22 */;
if (defaultImport.size(a0.emojis) >= MAX_FAVORITES) {
defaultImport2 = importDefault(4647) /* metro dependency 4647: AlertActionCreators */;
show = defaultImport2.show;
object2 = {};
object2.title = intl.string(t['+XYXtZ']);
object2.body = intl.formatToPlainString(t.JaIyFi, {count: MAX_FAVORITES});
Reflect.apply(show, defaultImport2, [object2]);
r0 = false;
} else {
value4 = a0.emojis.includes(env0_0);
if (value4) {
r0 = !value4;
} else {
a0.emojis.push(env0_0);
r0 = value2;
}
}
return r0;
}
function _fun68096(a0) { // fn#68096, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8814:3051, offset: 0x01c3e768, size: 92 bytes, params: 2, frame: 13
const dedupeFavoriteEmojisBinding = dedupeFavoriteEmojis;
let emojis = a0.emojis;
a0.emojis = dedupeFavoriteEmojisBinding(emojis);
if (Reflect.apply(a0.emojis.includes, emojis, [env0_0])) {
emojis = a0.emojis;
a0.emojis = emojis.filter(_fun68097);
return undefined;
}
return false;
}