159 lines
7.5 KiB
TypeScript
159 lines
7.5 KiB
TypeScript
/* Metro module 6582; source: modules/stickers/StickersPersistedStore.tsx; dependencies: [6, 7, 15, 17, 18, 1348, 6583, 670, 672, 4393, 22, 566, 694, 2] */
|
|
function _fun51717(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#51717, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:6, offset: 0x012e35e8, size: 498 bytes, params: 8, frame: 20
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_2 = importDefault(6) /* metro dependency 6 */;
|
|
const env0_3 = importDefault(7) /* metro dependency 7 */;
|
|
const env0_4 = importDefault(15) /* metro dependency 15 */;
|
|
const env0_5 = importDefault(17) /* metro dependency 17 */;
|
|
const env0_6 = importDefault(18) /* metro dependency 18 */;
|
|
const userSettingsProtoStore = importDefault(1348) /* metro dependency 1348: UserSettingsProtoStore */;
|
|
const stickersStore = importDefault(6583) /* metro dependency 6583: StickersStore */;
|
|
const env0_9 = (require(670) /* metro dependency 670: UserSettingsConstants */).UserSettingsTypes;
|
|
object = {pendingUsages: []};
|
|
const Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
const DAY = Millis.DAY;
|
|
let value = importDefault(4393) /* metro dependency 4393: Frecency */;
|
|
value = new value({computeBonus: function() {
|
|
return 100;
|
|
}, lookupKey: function(a0) {
|
|
return StickersStore.getStickerById(a0);
|
|
}, afterCompute: function() {
|
|
}, numFrequentlyItems: 20});
|
|
const handleStickersStoreUpdate = function() {
|
|
recomputeStickerFrecency();
|
|
};
|
|
const PersistedStore = (importDefault(566) /* metro dependency 566: flux */).PersistedStore;
|
|
value = _fun51729(PersistedStore);
|
|
value.displayName = 'StickersPersistedStore';
|
|
value.persistKey = 'StickersPersistedStoreV2';
|
|
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */,
|
|
{STICKER_TRACK_USAGE: function({stickerIds}) {
|
|
if (stickerIds != null) {
|
|
stickerIds.forEach(_fun51736);
|
|
}
|
|
recomputeStickerFrecency();
|
|
}, USER_SETTINGS_PROTO_UPDATE: USER_SETTINGS_PROTO_UPDATE_51737});
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/stickers/StickersPersistedStore.tsx');
|
|
exports.default = value;
|
|
exports.STICKER_PACK_NEW_TIMESTAMP_THRESHOLD = DAY;
|
|
}
|
|
|
|
function _isNativeReflectConstruct_51718() { // fn#51718, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:196, offset: 0x012e37da, 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_51718_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function handleUserSettingsProtoStoreChange_51721() { // fn#51721, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:663, offset: 0x012e3838, size: 113 bytes, params: 1, frame: 17
|
|
const stickerFrecency = UserSettingsProtoStore.frecencyWithoutFetchingLatest.stickerFrecency;
|
|
const value2 = undefined;
|
|
const stickers = stickerFrecency == null ? value2 : stickerFrecency.stickers;
|
|
if (stickers == null) {
|
|
return false;
|
|
}
|
|
const binding = env0_11;
|
|
binding.overwriteHistory((importDefault(22) /* metro dependency 22 */).mapValues(stickers, function(a0) {
|
|
var r3;
|
|
var object = {};
|
|
copyDataProperties(object, a0, r3);
|
|
var value = a0.recentUses.map(global.Number);
|
|
value = value.filter(_fun51723);
|
|
object['recentUses'] = value;
|
|
return object;
|
|
}), env0_10.pendingUsages);
|
|
return value2;
|
|
}
|
|
|
|
function recomputeStickerFrecency() { // fn#51727, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:574, offset: 0x012e3903, size: 34 bytes, params: 1, frame: 9
|
|
if (StickersStore.isLoaded) {
|
|
env0_11.compute();
|
|
}
|
|
}
|
|
|
|
function _fun51729(a0) { // fn#51729, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:944, offset: 0x012e3934, size: 137 bytes, params: 2, frame: 16
|
|
const closure = StickersPersistedStore;
|
|
env0_6(closure, a0);
|
|
return env0_3(closure, [{key: 'initialize', value: function(a0) {
|
|
this.waitFor(StickersStore, UserSettingsProtoStore);
|
|
if (a0 != null) {
|
|
env1_10 = a0;
|
|
}
|
|
this.syncWith([StickersStore], handleStickersStoreUpdate);
|
|
this.syncWith([UserSettingsProtoStore], handleUserSettingsProtoStoreChange_51721);
|
|
}}, {key: 'getState', value: value_51732}, {key: 'hasPendingUsage', value: value_51733},
|
|
{key: 'stickerFrecencyWithoutFetchingLatest', get: get_51734}]);
|
|
}
|
|
|
|
function STICKER_TRACK_USAGE({stickerIds}) { // fn#51735, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:1767, offset: 0x012e3a3a, size: 47 bytes, params: 2, frame: 11
|
|
if (stickerIds != null) {
|
|
stickerIds.forEach(_fun51736);
|
|
}
|
|
recomputeStickerFrecency();
|
|
}
|
|
|
|
function USER_SETTINGS_PROTO_UPDATE_51737({settings, wasSaved}) { // fn#51737, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:1930, offset: 0x012e3ab1, size: 62 bytes, params: 2, frame: 4
|
|
const type = settings.type;
|
|
const FRECENCY_AND_FAVORITES_SETTINGS = UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS;
|
|
if (type === FRECENCY_AND_FAVORITES_SETTINGS) {
|
|
if (wasSaved) {
|
|
env0_10.pendingUsages = [];
|
|
return undefined;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function _fun51722(a0) { // fn#51722, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:854, offset: 0x012e38a9, size: 67 bytes, params: 2, frame: 13
|
|
const object2 = {};
|
|
copyDataProperties(object2, a0, undefined);
|
|
const recentUses = a0.recentUses;
|
|
const map = recentUses.map;
|
|
const Number = global.Number;
|
|
let value = Reflect.apply(map, recentUses, [Number]);
|
|
value = value.filter(function(a0) {
|
|
return a0 > 0;
|
|
});
|
|
object2['recentUses'] = value;
|
|
return object2;
|
|
}
|
|
|
|
function value_51733() { // fn#51733, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:1503, offset: 0x012e3a20, size: 26 bytes, params: 1, frame: 2
|
|
return env1_10.pendingUsages.length > 0;
|
|
}
|
|
|
|
function _fun51736(a0) { // fn#51736, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6760:1806, offset: 0x012e3a69, size: 72 bytes, params: 2, frame: 13
|
|
env1_11.track(a0);
|
|
const pendingUsages = env1_10.pendingUsages;
|
|
const push = pendingUsages.push;
|
|
const object2 = {key: a0};
|
|
const Date = global.Date;
|
|
object2.timestamp = Date.now();
|
|
Reflect.apply(push, pendingUsages, [object2]);
|
|
}
|
|
|