// Module ID: 9547 // Function ID: 9548 // Name: EmojiActionCreators // Dependencies: [5, 5987, 5757, 5965, 1085, 1095, 2046, 1240, 584, 1295, 6672, 4969, 1126, 5636, 4764, 1388, 5994, 12, 5299, 2] // Exports: deleteEmoji, favoriteEmoji, fetchEmoji, setDiversityColor, unfavoriteEmoji, updateEmoji, uploadEmoji // Module 9547 (EmojiActionCreators) import _modDef12 from "module_12" /* 12 */; import DispatcherDefault from "Dispatcher" /* 584 */; import Constants from "Constants" /* 1085 */; import intl3 from "intl" /* 1126 */; import wrappers from "wrappers" /* 1240 */; import HTTPUtils from "HTTPUtils" /* 1295 */; import GlobalUtils from "GlobalUtils" /* 1388 */; import UnicodeEmojisDefault from "UnicodeEmojis" /* 4764 */; import AlertActionCreatorsDefault from "AlertActionCreators" /* 5299 */; import dedupeEmojisByNameOrIdDefault from "dedupeEmojisByNameOrId" /* 5994 */; import InlineUploaderDefault from "InlineUploader" /* 6672 */; import _asyncToGenerator from "_asyncToGenerator" /* 5 */; import EmojiStore from "EmojiStore" /* 5987 */; import GatewayConnectionStore from "GatewayConnectionStore" /* 5757 */; import GuildAvailabilityStore from "GuildAvailabilityStore" /* 5965 */; import UserSettingsConstants from "UserSettingsConstants" /* 1095 */; import size from "module_2" /* 2 */; const require = globalThis.__r; let _require, c5, c6, closure_3, customEmojiById, emojis; let c9; let metroImportAll; const f101869 = (item) => { customEmojiById = customEmojiById.getCustomEmojiById(item); if (customEmojiById == null) { obj = closure_1_1(closure_1_2[14]); customEmojiById = obj.getByName(item); } return customEmojiById; }; let obj = function _updateEmoji() { obj = _asyncToGenerator(async function(arg0, value) { let c0; let c1; let c2; let c3; let obj5; let closure_0 = arg0; if (c6 === 2) { c6 = 3; throw new TypeError("Generator functions may not be called on executing generators"); } else if (tmp3 === 3) { if (arg0 === 1) { throw value; } else if (arg0 === 2) { const obj2 = { value, done: true }; return obj2; } else { return { value: "IconComponent", done: null }; } } else { let c4; try { let name; let roles; c6 = 2; if (0 === c5) { if (arg0 === 1) { c6 = 3; throw value; } else if (arg0 === 2) { c6 = 3; const obj3 = { value, done: true }; return obj3; } else { let closure_2 = tmp; c0 = undefined; c1 = undefined; name = undefined; roles = undefined; ({ guildId: c0, emojiId: c1, name: c2, roles: c3 } = closure_0); c5 = 1; c6 = 1; return { value: "Set", done: true }; } } else if (1 === c5) { if (arg0 === 1) { c6 = 3; throw value; } else if (arg0 === 2) { c6 = 3; const obj4 = { value, done: true }; return obj4; } else { c4 = 1; const HTTP = closure_130_0(closure_130_2[9]).HTTP; const request = { url: closure_130_7.GUILD_EMOJI(c0, c1), body: obj5, oldFormErrors: true, rejectWithError: true }; const patch = HTTP.patch; obj5 = { name, roles }; c5 = 3; c6 = 1; const obj6 = { value: patch(request), done: false }; return obj6; } } else if (2 === c5) { c4 = 0; let closure_4 = closure_3; const self2 = this; const self = this; const tmp12 = new closure_130_1(closure_130_2[13])(closure_4); throw tmp12; } else if (arg0 === 1) { c6 = 3; throw value; } else if (arg0 === 2) { c4 = 0; c6 = 3; const obj7 = { value, done: true }; return obj7; } else { c4 = 0; c6 = 3; obj = { value, done: true }; return obj; } } catch (tmp15) { closure_3 = tmp15; if (0 === c4) { c6 = 3; throw tmp15; } else { c5 = 2; } } } }); return obj(...arguments); }; const Endpoints = Constants.Endpoints; ({ MAX_FAVORITES: metroImportAll, UserSettingsDelay: c9 } = UserSettingsConstants); let result = size.fileFinishedImporting("actions/EmojiActionCreators.tsx"); export const setDiversityColor = function setDiversityColor(value) { _require = value; const PreloadedUserSettingsActionCreators = require("UserSettingsProtoActionCreators").PreloadedUserSettingsActionCreators; PreloadedUserSettingsActionCreators.updateAsync("textAndImages", async (diversitySurrogate) => { const StringValue = wrappers.StringValue; diversitySurrogate.diversitySurrogate = StringValue.create(); diversitySurrogate.diversitySurrogate.value = value; }, constants.FREQUENT_USER_ACTION); }; export const fetchEmoji = function fetchEmoji(guildId) { _require = guildId; obj = DispatcherDefault; let obj2 = { type: "EMOJI_FETCH", guildId }; obj.dispatch(obj2); const HTTP = require("HTTPUtils").HTTP; const obj3 = { url: Endpoints.GUILD_EMOJIS(guildId), oldFormErrors: true, rejectWithError: true }; const value = HTTP.get(obj3); value.then((body) => { obj = DispatcherDefault; const obj2 = { type: "EMOJI_FETCH_SUCCESS", guildId, emojis: body.body }; return obj.dispatch(obj2); }, () => { obj = DispatcherDefault; const obj2 = { type: "EMOJI_FETCH_FAILURE", guildId }; return obj.dispatch(obj2); }); }; export const uploadEmoji = function uploadEmoji(guildId) { let image; let name; let obj3; let originalMd5; let page; let roles; let tmp3Result; guildId = guildId.guildId; const analyticsLocation = guildId.analyticsLocation; ({ image, name, roles, originalMd5 } = guildId); obj = DispatcherDefault; obj.dispatch({ type: "EMOJI_UPLOAD_START", guildId }); const HTTP = guildId(1295).HTTP; const request = { url: Endpoints.GUILD_EMOJIS(guildId), body: { image, name, roles }, headers: obj3.buildHeadersForMd5(originalMd5), context: { client_event_source: page }, oldFormErrors: true, rejectWithError: tmp3Result.rejectWithMigratedError() }; const post = HTTP.post; page = undefined; obj3 = InlineUploaderDefault; const tmp3 = guildId; if (analyticsLocation != null) { page = analyticsLocation.page; } tmp3Result = tmp3(1295); const postResult = post(request); return postResult.then((body) => { obj = DispatcherDefault; const obj2 = { type: "EMOJI_UPLOAD_STOP", guildId }; obj.dispatch(obj2); return body.body; }, (arg0) => { obj = DispatcherDefault; const obj2 = { type: "EMOJI_UPLOAD_STOP", guildId }; obj.dispatch(obj2); return Promise.reject(arg0); }); }; export const deleteEmoji = function deleteEmoji(guildId, id, replaced_by) { let tmp3Result; let tmp4; obj = DispatcherDefault; const obj2 = { type: "EMOJI_DELETE", guildId, emojiId: id }; obj.dispatch(obj2); const HTTP = HTTPUtils.HTTP; const request = { url: Endpoints.GUILD_EMOJI(guildId, id), body: tmp4, oldFormErrors: true, rejectWithError: tmp3Result.rejectWithMigratedError() }; const del = HTTP.del; tmp4 = undefined; if (null != replaced_by) { tmp4 = { replaced_by }; const obj3 = { replaced_by }; } tmp3Result = HTTPUtils; const delResult = del(request); return delResult.then(() => { const AccessibilityAnnouncer = require("shared").AccessibilityAnnouncer; const announce = AccessibilityAnnouncer.announce; const intl = require("intl").intl; announce(intl.string(require("intl").t.L3UUha)); }); }; export const updateEmoji = function updateEmoji() { return obj(...arguments); }; export const favoriteEmoji = function favoriteEmoji(stateFromStores1) { let name; let tmp = null; if (null != stateFromStores1) { name = stateFromStores1.id; if (name == null) { let tmp2 = importDefault; obj = UnicodeEmojisDefault; const result = obj.convertSurrogateToBase(stateFromStores1.surrogates); let name1; if (result != null) { name1 = result.name; } name = name1; } if (name == null) { name = stateFromStores1.name; } tmp = name; } name = tmp; if (null != tmp) { const FrecencyUserSettingsActionCreators = name(2046).FrecencyUserSettingsActionCreators; FrecencyUserSettingsActionCreators.updateAsync("favoriteEmojis", async (emojis) => { let flag; let intl; let intl2; let obj4; const emojis1 = emojis.emojis; let tmp2 = emojis1; if (GuildAvailabilityStore.totalUnavailableGuilds <= 0) { tmp2 = emojis1; if (GatewayConnectionStore.isConnected()) { const mapped = emojis1.map(f101869); const found = mapped.filter(GlobalUtils.isNotNullish); const items = []; obj = dedupeEmojisByNameOrIdDefault(found); HermesBuiltin.arraySpread(items, obj.keys(), 0); tmp2 = items; } } emojis.emojis = tmp2; const obj2 = _modDef12; if (obj2.size(emojis.emojis) >= metroImportAll) { const obj3 = { title: intl.string(intl3.t["+XYXtZ"]), body: intl2.formatToPlainString(intl3.t.JaIyFi, obj4) }; const show = tmp10(5299).show; AlertActionCreatorsDefault; intl = intl3.intl; intl2 = intl3.intl; obj4 = { count: tmp12 }; show(obj3); flag = false; } else { emojis = emojis.emojis; const hasItem = emojis.includes(name); flag = !hasItem; const tmp13 = name; if (flag) { const emojis2 = emojis.emojis; emojis2.push(tmp13); } } return flag; }, constants.INFREQUENT_USER_ACTION); } }; export const unfavoriteEmoji = function unfavoriteEmoji(stateFromStores1) { let name; let tmp = null; if (null != stateFromStores1) { name = stateFromStores1.id; if (name == null) { let tmp2 = importDefault; obj = UnicodeEmojisDefault; const result = obj.convertSurrogateToBase(stateFromStores1.surrogates); let name1; if (result != null) { name1 = result.name; } name = name1; } if (name == null) { name = stateFromStores1.name; } tmp = name; } name = tmp; if (null != tmp) { const FrecencyUserSettingsActionCreators = name(2046).FrecencyUserSettingsActionCreators; FrecencyUserSettingsActionCreators.updateAsync("favoriteEmojis", async (emojis) => { const emojis1 = emojis.emojis; let tmp2 = emojis1; if (GuildAvailabilityStore.totalUnavailableGuilds <= 0) { tmp2 = emojis1; if (GatewayConnectionStore.isConnected()) { const mapped = emojis1.map(f101869); const found = mapped.filter(GlobalUtils.isNotNullish); obj = dedupeEmojisByNameOrIdDefault(found); const items = []; HermesBuiltin.arraySpread(items, obj.keys(), 0); tmp2 = items; } } emojis.emojis = tmp2; emojis = emojis.emojis; if (emojis.includes(name)) { const emojis2 = emojis.emojis; emojis.emojis = emojis2.filter((item) => name !== item); } else { return false; } }, constants.INFREQUENT_USER_ACTION); } };