/* Metro module 9094; source: modules/guild_profile/GuildProfileActionCreators.tsx; dependencies: [5, 3970, 1945, 9092, 661, 694, 507, 6718, 4131, 683, 2] */ import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */ import Dispatcher from '../../Dispatcher.tsx'; /* Metro dependency 694 */ import GuildMemberStore from '../../stores/GuildMemberStore.tsx'; /* Metro dependency 1945 */ import UserGuildJoinRequestStore from '../guild_member_verification/UserGuildJoinRequestStore.tsx'; /* Metro dependency 3970 */ import GuildProfileStore from './GuildProfileStore.tsx'; /* Metro dependency 9092 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as HTTPUtilsModule from '../../external/discord_common/js/packages/http-utils/HTTPUtils.tsx'; /* Metro dependency 507 */ import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */ import * as ErrorsModule from '../../errors/index.tsx'; /* Metro dependency 4131 */ import * as GuildProfileBuildersModule from './GuildProfileBuilders.tsx'; /* Metro dependency 6718 */ import * as GuildProfileStoreModule from './GuildProfileStore.tsx'; /* Metro dependency 9092 */ function _fun71126(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#71126, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:6, offset: 0x01d157d3, size: 286 bytes, params: 8, frame: 19 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); (FileImportTrackerModule).fileFinishedImporting('modules/guild_profile/GuildProfileActionCreators.tsx'); exports.getGuildProfile = getGuildProfile; exports.saveGuildProfile = saveGuildProfile; exports.setGuildProfileVisibility = setGuildProfileVisibility; exports.fetchGuildTopGames = function() { return _fetchGuildTopGames.apply(this, arguments); }; exports.trackGuildProfileViewed = function(a0, a1) { var value3 = GuildMemberStore.getSelfMember(a0) != null; var value4 = UserGuildJoinRequestStore.getRequest(a0) != null; var defaultImport = importDefault(dependencyMap[9]); var GUILD_PROFILE_VIEWED = AnalyticEvents.GUILD_PROFILE_VIEWED; defaultImport.track(GUILD_PROFILE_VIEWED, {guild_id: a0, location_stack: a1, is_member: value3, has_join_request: value4}); }; function _fetchGuildTopGames() { // fn#71127, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:213, offset: 0x01d158f1, size: 50 bytes, params: 1, frame: 14 return Module00005(_fun71129).apply(this, arguments); function* _fun71129(a0) { // fn#71129, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:274, offset: 0x01d1592e, size: 143 bytes, params: 2, frame: 17 if (false) { return undefined; } value = environment.__proto__.__proto__; const HTTP = env2_0(env2_2[6]).HTTP; const get = HTTP.get; const object = {}; object.url = env2_9.GUILD_TOP_GAMES(a0); object.rejectWithError = false; yield Reflect.apply(get, HTTP, [object]); const value3 = undefined; if (false) { return value3; } value = env2_0(env2_2[7]); return value.buildTopGamesFromServer(value3.body.top_games); } } function getGuildProfile(a0, a1) { // fn#71130, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:551, offset: 0x01d159bd, size: 338 bytes, params: 3, frame: 21 var r1; var r0; var object; const HTTP = (HTTPUtilsModule).HTTP; var get; const env0_0 = a0; if (a0 == null) { return global.Promise.resolve(null); } var value; const guildProfileStoreBinding = GuildProfileStore; const fetchStatus = guildProfileStoreBinding.getFetchStatus(a0); const FETCHING = GuildProfileFetchStatus.FETCHING; const lastSyncTimestamp = guildProfileStoreBinding.getLastSyncTimestamp(a0); const profile = guildProfileStoreBinding.getProfile(a0); const Date = global.Date; const value7 = Date.now() - (lastSyncTimestamp ?? 0); if (fetchStatus !== FETCHING) { if (profile == null) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_FETCH', guildId: a0}); get = HTTP.get; object = {}; object.url = Endpoints.GUILD_PROFILE(a0); object.rejectWithError = false; value = Reflect.apply(get, HTTP, [object]); value = value.then(_fun71131); value = value.catch(_fun71132); r1 = value; } else if (value7 > 60000) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_FETCH', guildId: a0}); get = HTTP.get; object = {}; object.url = Endpoints.GUILD_PROFILE(a0); object.rejectWithError = false; value = Reflect.apply(get, HTTP, [object]); value = value.then(_fun71131); value = value.catch(_fun71132); r1 = value; } else if (a1) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_FETCH', guildId: a0}); get = HTTP.get; object = {}; object.url = Endpoints.GUILD_PROFILE(a0); object.rejectWithError = false; value = Reflect.apply(get, HTTP, [object]); value = value.then(_fun71131); value = value.catch(_fun71132); r1 = value; } else { r1 = global.Promise.resolve(profile); } r0 = r1; } else if (a1) { if (profile == null) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_FETCH', guildId: a0}); get = HTTP.get; object = {}; object.url = Endpoints.GUILD_PROFILE(a0); object.rejectWithError = false; value = Reflect.apply(get, HTTP, [object]); value = value.then(_fun71131); value = value.catch(_fun71132); r1 = value; } else if (value7 > 60000) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_FETCH', guildId: a0}); get = HTTP.get; object = {}; object.url = Endpoints.GUILD_PROFILE(a0); object.rejectWithError = false; value = Reflect.apply(get, HTTP, [object]); value = value.then(_fun71131); value = value.catch(_fun71132); r1 = value; } else if (a1) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_FETCH', guildId: a0}); get = HTTP.get; object = {}; object.url = Endpoints.GUILD_PROFILE(a0); object.rejectWithError = false; value = Reflect.apply(get, HTTP, [object]); value = value.then(_fun71131); value = value.catch(_fun71132); r1 = value; } else { r1 = global.Promise.resolve(profile); } r0 = r1; } else { r0 = global.Promise.resolve(null); } return r0; function _fun71131({body}) { // fn#71131, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:950, offset: 0x01d15b0f, size: 98 bytes, params: 2, frame: 14 const value = environment.__proto__; const guildProfileFromServer = (GuildProfileBuildersModule).buildGuildProfileFromServer(body); (Dispatcher).dispatch({type: 'GUILD_PROFILE_FETCH_SUCCESS', guildId: env0_0, profile: guildProfileFromServer}); return guildProfileFromServer; } function _fun71132(a0) { // fn#71132, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:1098, offset: 0x01d15b71, size: 111 bytes, params: 2, frame: 14 const value = environment.__proto__; const APIError = (ErrorsModule).APIError; (Dispatcher).dispatch({type: 'GUILD_PROFILE_FETCH_FAILURE', guildId: env0_0, error: new APIError(a0)}); return null; } } function saveGuildProfile(a0, a1) { // fn#71133, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:1261, offset: 0x01d15be0, size: 232 bytes, params: 3, frame: 19 var r0; var object; var HTTP; var patch; const env0_0 = a0; var value; const guildProfileStoreBinding = GuildProfileStore; const getIsUpdating = guildProfileStoreBinding.getIsUpdating; if (Reflect.apply(getIsUpdating, guildProfileStoreBinding, [a0])) { r0 = global.Promise.resolve(null); } else { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_UPDATE', guildId: a0, updates: a1}); HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP; patch = HTTP.patch; object = {}; object.url = Endpoints.GUILD_PROFILE(a0); value = require(6718) /* metro dependency 6718: GuildProfileBuilders */; object.body = value.buildGuildProfileUpdateForServer(a1); object.rejectWithError = false; value = Reflect.apply(patch, HTTP, [object]); value = value.then(_fun71134); value = value.catch(_fun71135); r0 = value; } return r0; function _fun71134({body}) { // fn#71134, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:1528, offset: 0x01d15cc8, size: 98 bytes, params: 2, frame: 14 const value = environment.__proto__; const guildProfileFromServer = (GuildProfileBuildersModule).buildGuildProfileFromServer(body); (Dispatcher).dispatch({type: 'GUILD_PROFILE_UPDATE_SUCCESS', guildId: env0_0, profile: guildProfileFromServer}); return guildProfileFromServer; } function _fun71135(a0) { // fn#71135, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:1677, offset: 0x01d15d2a, size: 109 bytes, params: 2, frame: 14 const value = environment.__proto__; const APIError = (ErrorsModule).APIError; (Dispatcher).dispatch({type: 'GUILD_PROFILE_UPDATE_FAILURE', guildId: env0_0, error: new APIError(a0)}); return null; } } function setGuildProfileVisibility(a0, a1) { // fn#71136, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:1831, offset: 0x01d15d97, size: 216 bytes, params: 3, frame: 18 var r0; var object; var HTTP; var put; const env0_0 = a0; var value; const guildProfileStoreBinding = GuildProfileStore; const getIsUpdating = guildProfileStoreBinding.getIsUpdating; if (Reflect.apply(getIsUpdating, guildProfileStoreBinding, [a0])) { r0 = global.Promise.resolve(null); } else { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_UPDATE_VISIBILITY', guildId: a0, visibility: a1}); HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP; put = HTTP.put; object = {}; object.url = Endpoints.GUILD_PROFILE_VISIBILITY(a0); object.body = {visibility: a1}; object.rejectWithError = false; value = Reflect.apply(put, HTTP, [object]); value = value.then(_fun71137); value = value.catch(_fun71138); r0 = value; } return r0; function _fun71137({body}) { // fn#71137, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:2101, offset: 0x01d15e6f, size: 77 bytes, params: 2, frame: 13 const visibility = body.visibility; const value = environment.__proto__; (Dispatcher).dispatch({type: 'GUILD_PROFILE_UPDATE_VISIBILITY_SUCCESS', guildId: env0_0, visibility: visibility}); return visibility; } function _fun71138(a0) { // fn#71138, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9279:2238, offset: 0x01d15ebc, size: 107 bytes, params: 2, frame: 14 const value = environment.__proto__; const APIError = (ErrorsModule).APIError; const aPIError = new APIError(a0); (Dispatcher).dispatch({type: 'GUILD_PROFILE_UPDATE_VISIBILITY_FAILURE', guildId: env0_0, error: aPIError}); throw aPIError; } } } global.__d(_fun71126, 9094, [5, 3970, 1945, 9092, 661, 694, 507, 6718, 4131, 683, 2]) /* metro module 9094, dependencies: [5, 3970, 1945, 9092, 661, 694, 507, 6718, 4131, 683, 2] */;