/* Metro module 9094; source: modules/guild_profile/GuildProfileActionCreators.tsx; dependencies: [5, 3970, 1945, 9092, 661, 694, 507, 6718, 4131, 683, 2] */ 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}); const env0_3 = importDefault(5) /* metro dependency 5 */; const userGuildJoinRequestStore = importDefault(3970) /* metro dependency 3970: UserGuildJoinRequestStore */; const guildMemberStore = importDefault(1945) /* metro dependency 1945: GuildMemberStore */; const guildProfileStore = importDefault(9092) /* metro dependency 9092: GuildProfileStore */; const env0_7 = (require(9092) /* metro dependency 9092: GuildProfileStore */).GuildProfileFetchStatus; const constantsModule = require(661) /* metro dependency 661: Constants */; const env0_8 = constantsModule.AnalyticEvents; const env0_9 = constantsModule.Endpoints; (require(2) /* metro dependency 2 */).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 env0_3(_fun71129).apply(this, arguments); } 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 object2; const HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP; var get; const env0_0 = a0; if (a0 == null) { return global.Promise.resolve(null); } var value; const fetchStatus = GuildProfileStore.getFetchStatus(a0); const FETCHING = GuildProfileFetchStatus.FETCHING; const lastSyncTimestamp = GuildProfileStore.getLastSyncTimestamp(a0); const profile = GuildProfileStore.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; object2 = {}; object2.url = Endpoints.GUILD_PROFILE(a0); object2.rejectWithError = false; value = Reflect.apply(get, HTTP, [object2]); 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; object2 = {}; object2.url = Endpoints.GUILD_PROFILE(a0); object2.rejectWithError = false; value = Reflect.apply(get, HTTP, [object2]); 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; object2 = {}; object2.url = Endpoints.GUILD_PROFILE(a0); object2.rejectWithError = false; value = Reflect.apply(get, HTTP, [object2]); 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; object2 = {}; object2.url = Endpoints.GUILD_PROFILE(a0); object2.rejectWithError = false; value = Reflect.apply(get, HTTP, [object2]); 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; object2 = {}; object2.url = Endpoints.GUILD_PROFILE(a0); object2.rejectWithError = false; value = Reflect.apply(get, HTTP, [object2]); 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; object2 = {}; object2.url = Endpoints.GUILD_PROFILE(a0); object2.rejectWithError = false; value = Reflect.apply(get, HTTP, [object2]); 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 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 object2; var HTTP; var patch; const env0_0 = a0; var value; const getIsUpdating = GuildProfileStore.getIsUpdating; if (Reflect.apply(getIsUpdating, GuildProfileStore, [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; object2 = {}; object2.url = Endpoints.GUILD_PROFILE(a0); value = require(6718) /* metro dependency 6718: GuildProfileBuilders */; object2.body = value.buildGuildProfileUpdateForServer(a1); object2.rejectWithError = false; value = Reflect.apply(patch, HTTP, [object2]); value = value.then(_fun71134); value = value.catch(_fun71135); r0 = value; } return r0; } 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 object2; var HTTP; var put; const env0_0 = a0; var value; const getIsUpdating = GuildProfileStore.getIsUpdating; if (Reflect.apply(getIsUpdating, GuildProfileStore, [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; object2 = {}; object2.url = Endpoints.GUILD_PROFILE_VISIBILITY(a0); object2.body = {visibility: a1}; object2.rejectWithError = false; value = Reflect.apply(put, HTTP, [object2]); value = value.then(_fun71137); value = value.catch(_fun71138); r0 = value; } return r0; } 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 object2 = {}; object2.url = env2_9.GUILD_TOP_GAMES(a0); object2.rejectWithError = false; yield Reflect.apply(get, HTTP, [object2]); const value3 = undefined; if (false) { return value3; } value = env2_0(env2_2[7]); return value.buildTopGamesFromServer(value3.body.top_games); } 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 = (require(6718) /* metro dependency 6718: GuildProfileBuilders */).buildGuildProfileFromServer(body); (importDefault(694) /* metro dependency 694: 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 = (require(4131) /* metro dependency 4131: errors */).APIError; (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_FETCH_FAILURE', guildId: env0_0, error: new APIError(a0)}); return null; } 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 = (require(6718) /* metro dependency 6718: GuildProfileBuilders */).buildGuildProfileFromServer(body); (importDefault(694) /* metro dependency 694: 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 = (require(4131) /* metro dependency 4131: errors */).APIError; (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_UPDATE_FAILURE', guildId: env0_0, error: new APIError(a0)}); return null; } 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__; (importDefault(694) /* metro dependency 694: 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 = (require(4131) /* metro dependency 4131: errors */).APIError; const aPIError = new APIError(a0); (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'GUILD_PROFILE_UPDATE_VISIBILITY_FAILURE', guildId: env0_0, error: aPIError}); throw aPIError; }