Files
discord-decomp/sources/modules/user_profile/WidgetStore.tsx
T
2026-07-28 01:06:53 +03:00

461 lines
19 KiB
TypeScript

/* Metro module 5194; source: modules/user_profile/WidgetStore.tsx; dependencies: [57, 6, 7, 15, 17, 18, 1878, 5189, 22, 566, 694, 2] */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */
import UserProfileStore from './UserProfileStore.tsx'; /* Metro dependency 5189 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
function _fun45829(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#45829, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:6, offset: 0x011993f7, size: 469 bytes, params: 8, frame: 18
const _arrayLikeToArray_45832 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
object = {suggestedGamesIds: [], suggestedWishlistGamesIds: []};
const Store = (Flux).Store;
let value = _fun45836(Store);
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */,
{WIDGET_PENDING_SET: WIDGET_PENDING_SET, WIDGET_PENDING_SAVE_START: function() {
env0_12 = true;
}, WIDGET_PENDING_SAVE_SUCCESS: WIDGET_PENDING_SAVE_SUCCESS, WIDGET_PENDING_SAVE_FAILURE: function() {
env0_12 = false;
}, WIDGET_SUGGESTED_FETCH_SUCCESS: WIDGET_SUGGESTED_FETCH_SUCCESS, WIDGET_SUGGESTED_FETCH_FAILURE: function() {
env0_14 = true;
env0_15 = false;
}, WIDGET_SUGGESTED_FETCH_START: function() {
env0_15 = true;
env0_14 = false;
env0_16 = true;
}, WIDGET_PENDING_CLEAR: function() {
env0_10 = null;
env0_11 = null;
}, WIDGET_SUGGESTED_REMOVE_GAME: WIDGET_SUGGESTED_REMOVE_GAME});
(FileImportTrackerModule).fileFinishedImporting('modules/user_profile/WidgetStore.tsx');
exports.default = value;
function _createForOfIteratorHelperLoose_45830(a0, a1) { // fn#45830, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:189, offset: 0x011995cc, size: 370 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun45831;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_45832(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_45832(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_45832(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun45831;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
function _fun45831() { // fn#45831, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:760, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function _isNativeReflectConstruct_45833() { // fn#45833, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:1099, offset: 0x0119973e, size: 94 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_45833_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun45836(a0) { // fn#45836, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:1390, offset: 0x0119979c, size: 385 bytes, params: 2, frame: 16
const WidgetStore2 = WidgetStore;
Inherits(WidgetStore2, a0);
return CreateClass(WidgetStore2, [{key: 'initialize', value: function() {
this.waitFor(UserStore);
}}, {key: 'getPendingWidgets', value: value_45839}, {key: 'getSaveablePendingWidgets', value: value_45840},
{key: 'hasPendingChanges', value: value_45842}, {key: 'getWidgetUpdates', value: value_45843},
{key: 'getChangedWidgets', value: function() {
return this.getWidgetUpdates().changedWidgets;
}}, {key: 'getRemovedWidgets', value: function() {
return this.getWidgetUpdates().removedWidgets;
}}, {key: 'hasUnsavedChanges', value: function() {
var r0;
var {changedWidgets, removedWidgets, hasOrderChanges} = this.getWidgetUpdates();
r0 = changedWidgets.length > 0 || removedWidgets.length > 0;
r0 = !r0 ? hasOrderChanges : r0;
return r0;
}}, {key: 'canSaveChanges', value: function() {
var r0;
var value = this.getSaveablePendingWidgets();
var value2 = value != null;
if (value2) {
value = value.every(_fun45850);
r0 = value;
} else {
r0 = value2;
}
return r0;
}}, {key: 'isSubmitting', get: get_45851}, {key: 'suggestedFetchError', get: get_45852},
{key: 'suggestedFetchIsLoading', get: get_45853}, {key: 'suggestedFetchAttempted', get: get_45854},
{key: 'suggestedGameIds', get: get_45855}]);
function WidgetStore() { // fn#45837, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:1402, offset: 0x00e07435, size: 113 bytes, params: 1, frame: 20
const value = environment.__proto__;
env1_3(this, WidgetStore);
const value3 = env1_6(WidgetStore);
return env1_5(this, _isNativeReflectConstruct_45833() ? global.Reflect.construct(value3, arguments,
env1_6(this).constructor) : value3.apply(this, arguments));
}
function value_45839() { // fn#45839, offset: 0x00fbd9ec, size: 9 bytes, params: 1, frame: 1
return env1_10;
}
function value_45840() { // fn#45840, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:1796, offset: 0x0119991d, size: 39 bytes, params: 1, frame: 12
var environment;
const value = environment.__proto__;
const value2 = null;
return value2 == env1_10 ? value2 : env1_10.filter(function(a0) {
return !a0.isDiscardable();
});
}
function value_45842() { // fn#45842, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:1894, offset: 0x01199958, size: 77 bytes, params: 1, frame: 15
var r1;
var r0;
var value3;
var defaultImport;
const value = environment.__proto__;
const value2 = env1_10 !== null;
if (value2) {
value3 = env1_11 === null;
if (value3) {
r1 = value3;
} else {
defaultImport = importDefault(22) /* metro dependency 22 */;
r1 = !defaultImport.isEqual(env1_10, env1_11);
}
r0 = r1;
} else {
r0 = value2;
}
return r0;
}
function value_45843() { // fn#45843, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:1989, offset: 0x011999a5, size: 457 bytes, params: 1, frame: 26
var r6;
var r0;
var r3;
var r8;
var id;
var id2;
var value13;
var value14;
var property;
var property2;
var value15;
var value16;
var isEqual2;
var value17;
var value20;
var value21;
var property3;
var has;
var value22;
var id3;
var value24;
var value25;
const saveablePendingWidgets = this.getSaveablePendingWidgets();
if (saveablePendingWidgets == null) {
return {changedWidgets: saveablePendingWidgets ?? [], removedWidgets: [], hasOrderChanges: false};
}
if (env1_11 == null) {
return {changedWidgets: saveablePendingWidgets ?? [], removedWidgets: [], hasOrderChanges: false};
}
let Map = global.Map;
const binding = env1_11;
let map = binding.map;
map = new Map(Reflect.apply(map, binding, [function(a0) {
return [a0.id, a0];
}]));
Map = global.Map;
map = new Map(saveablePendingWidgets.map(function(a0) {
return [a0.id, a0];
}));
const items2 = [];
const items3 = [];
const _createForOfIteratorHelperLoose_45830Binding = _createForOfIteratorHelperLoose_45830;
const value9 = undefined;
const value10 = _createForOfIteratorHelperLoose_45830Binding(map);
const value11 = value10();
let done = value11.done;
const value12 = 0;
if (!done) {
r6 = value11;
while (true) {
value13 = r6.value;
value14 = env1_2(value13, 2);
property = value14[value12];
property2 = value14[1];
value15 = map.get(property);
value16 = value15 != null;
if (value16) {
isEqual2 = property2.isEqual(value15);
r0 = isEqual2;
} else {
r0 = value16;
}
if (r0) {
continue;
}
items2.push(property2);
value17 = value10();
done = value17.done;
if (done) {
break;
}
r6 = value17;
continue;
}
}
const value18 = _createForOfIteratorHelperLoose_45830(map);
const value19 = value18();
done = value19.done;
if (!done) {
r3 = value19;
while (true) {
value20 = r3.value;
value21 = env1_2(value20, 2);
property = value21[value12];
property3 = value21[1];
has = map.has;
if (!Reflect.apply(has, map, [property])) {
items3.push(property3);
}
value22 = value18();
done = value22.done;
if (done) {
break;
}
r3 = value22;
continue;
}
}
let length = saveablePendingWidgets.length;
const value23 = false;
if (value12 < length) {
r8 = value12;
while (true) {
property = saveablePendingWidgets[r8];
id = property == null ? value9 : property.id;
property = env1_11[r8];
if (property == null) {
id2 = value9;
continue;
}
id3 = property.id;
id2 = id3;
value24 = true;
if (id !== id2) {
r3 = value24;
break;
}
value25 = typeof r8 === 'bigint' ? r8 + 1n : +r8 + 1;
length = saveablePendingWidgets.length;
if (value25 < length) {
r8 = value25;
continue;
}
r3 = value23;
break;
}
} else {
r3 = value23;
}
return {changedWidgets: items2, removedWidgets: items3, hasOrderChanges: r3};
}
function value_45849() { // fn#45849, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:3022, offset: 0x01199bd6, size: 42 bytes, params: 1, frame: 12
var r0;
let value = this.getSaveablePendingWidgets();
const value2 = value != null;
if (value2) {
value = value.every(function(a0) {
return a0.isValid();
});
r0 = value;
} else {
r0 = value2;
}
return r0;
}
function get_45851() { // fn#45851, offset: 0x00e2f9de, size: 9 bytes, params: 1, frame: 1
return env1_12;
}
function get_45852() { // fn#45852, offset: 0x00df0f5a, size: 9 bytes, params: 1, frame: 1
return env1_14;
}
function get_45853() { // fn#45853, offset: 0x00df0e8b, size: 9 bytes, params: 1, frame: 1
return env1_15;
}
function get_45854() { // fn#45854, offset: 0x00df0e94, size: 9 bytes, params: 1, frame: 1
return env1_16;
}
function get_45855() { // fn#45855, offset: 0x00e2f9d5, size: 9 bytes, params: 1, frame: 1
return env1_13;
}
}
function WIDGET_PENDING_SET({widgets}) { // fn#45856, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:3436, offset: 0x01199c0f, size: 94 bytes, params: 2, frame: 13
var r0;
var currentUser;
var userProfileStoreBinding;
if (env0_11 === null) {
currentUser = UserStore.getCurrentUser();
if (currentUser != null) {
userProfileStoreBinding = UserProfileStore;
r0 = userProfileStoreBinding.getUserProfile(currentUser.id)?.widgets ?? [];
}
}
}
function WIDGET_PENDING_SAVE_SUCCESS() { // fn#45858, offset: 0x01199c6d, size: 31 bytes, params: 1, frame: 3
if (env0_10 === null) {
}
}
function WIDGET_SUGGESTED_FETCH_SUCCESS({suggestedGamesIds, suggestedWishlistGamesIds}) { // fn#45860, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:3896, offset: 0x01199c8c, size: 48 bytes, params: 2, frame: 4
const binding = env0_13;
binding.suggestedGamesIds = suggestedGamesIds;
binding.suggestedWishlistGamesIds = suggestedWishlistGamesIds;
}
function WIDGET_SUGGESTED_REMOVE_GAME({applicationId}) { // fn#45864, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:4316, offset: 0x01199cf7, size: 79 bytes, params: 2, frame: 13
const binding = env0_13;
binding.suggestedGamesIds = binding.suggestedGamesIds.filter(function(a0) {
return a0 !== applicationId;
});
binding.suggestedWishlistGamesIds = binding.suggestedWishlistGamesIds.filter(function(a0) {
return a0 !== applicationId;
});
}
}
function _fun45850(a0) { // fn#45850, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5372:3097, offset: 0x01199c00, size: 15 bytes, params: 2, frame: 9
return a0.isValid();
}
global.__d(_fun45829, 5194, [57, 6, 7, 15, 17, 18, 1878, 5189, 22, 566, 694,
2]) /* metro module 5194, dependencies: [57, 6, 7, 15, 17, 18, 1878, 5189, 22, 566, 694, 2] */;