Files
discord-decomp/sources/lib/NetworkTtlCache.tsx
T
2026-07-28 01:06:53 +03:00

158 lines
8.2 KiB
TypeScript

/* Metro module 12569; source: lib/NetworkTtlCache.tsx; dependencies: [6, 7, 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 * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
function _fun96300(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#96300, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:6, offset: 0x0215a2d5, size: 224 bytes, params: 8, frame: 19
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
object = {IDLE: 'idle', LOADING: 'loading', SUCCESS: 'success', ERROR: 'error'};
const value = _fun96301();
(FileImportTrackerModule).fileFinishedImporting('lib/NetworkTtlCache.tsx');
exports.NetworkTtlCacheStatus = {IDLE: 'idle', LOADING: 'loading', VALID: 'valid', STALE: 'stale', ERROR: 'error'};
exports.NetworkTtlCache = value;
function _fun96301() { // fn#96301, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:329, offset: 0x0215a3b5, size: 492 bytes, params: 1, frame: 15
return CreateClass(NetworkTtlCache, [{key: 'setTtl', value: function(a0) {
this.ttlMs = a0;
}}, {key: 'setLoading', value: value_96304}, {key: 'setValue', value: value_96305}, {key: 'setError',
value: value_96306}, {key: 'clear', value: value_96307}, {key: 'getValue', value: function() {
return this.value;
}}, {key: 'getFetchState', value: function() {
return this.fetchState;
}}, {key: 'getFetchedAt', value: function() {
return this.fetchedAt;
}}, {key: 'forceExpire', value: function() {
this.fetchedAt = null;
}}, {key: 'isExpired', value: function() {
var r1;
var r0;
var value = this.ttlMs != null;
if (value) {
value = this.fetchedAt == null;
if (value) {
r1 = value;
} else {
value = global.Date.now();
value -= this.fetchedAt;
value = value >= this.ttlMs;
r1 = value;
}
r0 = r1;
} else {
r0 = value;
}
return r0;
}}, {key: 'shouldFetch', value: value_96313}, {key: 'isLoading', value: value_96314}, {key: 'isValid',
value: value_96315}, {key: 'isError', value: value_96316}, {key: 'getStatus', value: value_96317},
{key: 'getValueWithStatus', value: function() {
return {value: this.value, status: this.getStatus()};
}}, {key: 'serialize', value: function() {
var value = null;
return value == this.value || value == this.fetchedAt ? value : {value: this.value, fetchedAt: this.fetchedAt};
}}, {key: 'restore', value: value_96320}]);
function NetworkTtlCache() { // fn#96302, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:350, offset: 0x0215a5a1, size: 88 bytes, params: 1, frame: 15
let value = a0;
const r3 = value !== undefined ? value : {};
value = environment.__proto__;
env1_0(this, NetworkTtlCache);
const value3 = null;
this.value = value3;
const IDLE = env1_2.IDLE;
this.fetchState = IDLE;
this.fetchedAt = value3;
const ttlMs = r3.ttlMs;
this.ttlMs = value3 != ttlMs ? ttlMs : value3;
}
function value_96304() { // fn#96304, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:580, offset: 0x0215a609, size: 26 bytes, params: 1, frame: 2
const LOADING = env1_2.LOADING;
this.fetchState = LOADING;
}
function value_96305(a0) { // fn#96305, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:641, offset: 0x0215a623, size: 58 bytes, params: 2, frame: 10
this.value = a0;
const SUCCESS = env1_2.SUCCESS;
this.fetchState = SUCCESS;
const Date = global.Date;
this.fetchedAt = Date.now();
}
function value_96306() { // fn#96306, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:742, offset: 0x0215a65d, size: 26 bytes, params: 1, frame: 2
const ERROR = env1_2.ERROR;
this.fetchState = ERROR;
}
function value_96307() { // fn#96307, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:798, offset: 0x0215a677, size: 40 bytes, params: 1, frame: 3
this.value = null;
const IDLE = env1_2.IDLE;
this.fetchState = IDLE;
this.fetchedAt = null;
}
function value_96313() { // fn#96313, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:1253, offset: 0x0215a70d, size: 67 bytes, params: 1, frame: 11
const fetchState = this.fetchState;
const value = environment.__proto__;
const LOADING = env1_2.LOADING;
return fetchState !== LOADING && (this.fetchState === env1_2.IDLE || this.isExpired());
}
function value_96314() { // fn#96314, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:1370, offset: 0x0215a750, size: 28 bytes, params: 1, frame: 2
const fetchState = this.fetchState;
const LOADING = env1_2.LOADING;
return fetchState === LOADING;
}
function value_96315() { // fn#96315, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:1439, offset: 0x0215a76c, size: 44 bytes, params: 1, frame: 10
const fetchState = this.fetchState;
const value = environment.__proto__;
const SUCCESS = env1_2.SUCCESS;
return fetchState === SUCCESS && !this.isExpired();
}
function value_96316() { // fn#96316, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:1527, offset: 0x0215a798, size: 28 bytes, params: 1, frame: 2
const fetchState = this.fetchState;
const ERROR = env1_2.ERROR;
return fetchState === ERROR;
}
function value_96317() { // fn#96317, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:1596, offset: 0x0215a7b4, size: 141 bytes, params: 1, frame: 11
var isExpired2;
var binding;
const fetchState = this.fetchState;
const IDLE = env1_2.IDLE;
if (IDLE === fetchState) {
return env1_3.IDLE;
}
const LOADING = env1_2.LOADING;
if (LOADING === fetchState) {
return env1_3.LOADING;
}
const ERROR = env1_2.ERROR;
if (ERROR === fetchState) {
return env1_3.ERROR;
}
const SUCCESS = env1_2.SUCCESS;
if (SUCCESS === fetchState) {
isExpired2 = this.isExpired();
binding = env1_3;
return isExpired2 ? binding.STALE : binding.VALID;
}
}
function value_96320(a0) { // fn#96320, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12759:2021, offset: 0x0215a89c, size: 58 bytes, params: 2, frame: 3
var value;
if (a0 != null) {
value = a0.value;
this.value = value;
this.fetchedAt = a0.fetchedAt;
value = environment.__proto__;
this.fetchState = env1_2.SUCCESS;
}
}
}
}
global.__d(_fun96300, 12569, [6, 7, 2]) /* metro module 12569, dependencies: [6, 7, 2] */;