Files
discord-decomp/sources/modules/app_launcher/hooks/useAppLauncherFrecents.tsx
T
2026-07-27 16:20:00 +03:00

219 lines
11 KiB
TypeScript

/* Metro module 11661; source: modules/app_launcher/hooks/useAppLauncherFrecents.tsx; dependencies: [31, 5109, 1878, 11662, 4237, 5066, 1909, 8060, 566, 6779, 4122, 11663, 8040, 8046, 10657, 2] */
function _fun89378(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#89378, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:6, offset: 0x0200c0da, size: 360 bytes, params: 8, frame: 20
var object2;
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_4 = importAll(31) /* metro dependency 31 */;
const authorizedAppsStore = importDefault(5109) /* metro dependency 5109: AuthorizedAppsStore */;
const env0_6 = (require(5109) /* metro dependency 5109: AuthorizedAppsStore */).FetchState;
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
const appLauncherLastUsedCommandStore = importDefault(11662) /* metro dependency 11662: AppLauncherLastUsedCommandStore */;
const env0_9 = (require(4237) /* metro dependency 4237: Constants */).WATCH_YOUTUBE_PROD_APP_ID;
const applicationCommandConstantsModule = require(5066) /* metro dependency 5066: ApplicationCommandConstants */;
const env0_10 = applicationCommandConstantsModule.BuiltInSectionId;
const DISCOVERY_COMMANDS_QUERY_LIMIT = applicationCommandConstantsModule.DISCOVERY_COMMANDS_QUERY_LIMIT;
object2 = {};
const {CHAT, PRIMARY_ENTRY_POINT} = (require(1909) /* metro dependency 1909: Server */).ApplicationCommandType;
object2.commandTypes = [CHAT, PRIMARY_ENTRY_POINT];
({'placeholderCount': 0, 'limit': null, 'includeFrecency': true}).limit = DISCOVERY_COMMANDS_QUERY_LIMIT;
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/app_launcher/hooks/useAppLauncherFrecents.tsx');
exports.default = useAppLauncherFrecentCommandsAndApps;
exports.useAppLauncherFrecentApps = useAppLauncherFrecentApps;
}
function useFrecentApps({sectionDescriptors, context, onlyActivityApps, includeAuthorizedAppsAndFetch}) { // fn#89379, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:415, offset: 0x0200c242, size: 362 bytes, params: 2, frame: 23
env0_4.useEffect(_fun89381, [includeAuthorizedAppsAndFetch,
(require(566) /* metro dependency 566: flux */).useStateFromStores([AuthorizedAppsStore], function() {
return AuthorizedAppsStore.getFetchState();
})]);
return env0_4.useMemo(_fun89387, [onlyActivityApps,
(require(11663) /* metro dependency 11663: ApplicationFrecencyHooks */).useSortApplicationsViaFrecency(sectionDescriptors.filter(_fun89384),
(require(566) /* metro dependency 566: flux */).useStateFromStoresArray([AuthorizedAppsStore], _fun89382)),
context, env0_4.useMemo(_fun89385, [context.type === 'contextless']),
(require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], _fun89386)]);
}
function useAppLauncherFrecentCommandsAndApps({context, onlyActivityApps}) { // fn#89392, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1524, offset: 0x0200c617, size: 304 bytes, params: 2, frame: 24
var object2;
const {commands, commandsByActiveSection, sectionDescriptors, filterSection,
loading} = (importAll(8060) /* metro dependency 8060: ApplicationCommandQueryApi */).useDiscovery({context: context,
filters: env0_11, options: env0_12, allowFetch: true});
env0_4.useEffect(function() {
filterSection(BuiltInSectionId.FRECENCY);
}, [filterSection]);
const lastUsedCommandId = (require(566) /* metro dependency 566: flux */).useStateFromStores([AppLauncherLastUsedCommandStore],
function() {
return AppLauncherLastUsedCommandStore.getLastUsedCommandId();
});
var env0_4 = lastUsedCommandId;
object2 = {loading: loading};
object2.frecencyCommands = env0_4.useMemo(_fun89395, [commands, commandsByActiveSection, lastUsedCommandId,
onlyActivityApps]);
object2.frecentApps = useFrecentApps({sectionDescriptors: sectionDescriptors, context: context,
onlyActivityApps: onlyActivityApps, includeAuthorizedAppsAndFetch: true});
object2.sectionDescriptors = sectionDescriptors;
return object2;
}
function useAppLauncherFrecentApps({context, onlyActivityApps, allowCommandFetch, includeAuthorizedAppsAndFetch}) { // fn#89398, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:2249, offset: 0x0200c81c, size: 148 bytes, params: 2, frame: 18
var object2;
const value2 = (importAll(8060) /* metro dependency 8060: ApplicationCommandQueryApi */).useDiscovery({context: context,
filters: env0_11, options: env0_12, allowFetch: allowCommandFetch});
const sectionDescriptors = value2.sectionDescriptors;
object2 = {};
object2.loading = value2.loading;
object2.frecentApps = useFrecentApps({sectionDescriptors: sectionDescriptors, context: context,
onlyActivityApps: onlyActivityApps, includeAuthorizedAppsAndFetch: includeAuthorizedAppsAndFetch});
return object2;
}
function _fun89381() { // fn#89381, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:599, offset: 0x0200c3bf, size: 73 bytes, params: 1, frame: 11
var r0;
var fetchStateBinding;
var value;
const includeAuthorizedAppsAndFetchBinding = includeAuthorizedAppsAndFetch;
if (includeAuthorizedAppsAndFetchBinding) {
fetchStateBinding = fetchState;
value = environment.__proto__;
value = fetchStateBinding === FetchState.NOT_FETCHED;
r0 = value;
} else {
r0 = includeAuthorizedAppsAndFetchBinding;
}
if (r0) {
value = environment.__proto__;
value = importDefault(6779) /* metro dependency 6779: AuthorizedAppsActionCreators */;
value.fetch();
}
}
function _fun89382() { // fn#89382, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:694, offset: 0x0200c408, size: 54 bytes, params: 1, frame: 12
var environment;
var r0;
var value;
if (includeAuthorizedAppsAndFetch) {
value = environment.__proto__;
value = AuthorizedAppsStore.getNewestTokens();
value = value.filter(function({scopes}) {
return scopes.includes(require(dependencyMap[10]).OAuth2Scopes.APPLICATIONS_COMMANDS);
});
r0 = value;
} else {
r0 = [];
}
return r0;
}
function _fun89384(a0) { // fn#89384, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:813, offset: 0x0200c478, size: 49 bytes, params: 2, frame: 4
const id = a0.id;
const value = environment.__proto__;
const FRECENCY = BuiltInSectionId.FRECENCY;
return id !== FRECENCY && a0.id !== BuiltInSectionId.BUILT_IN;
}
function _fun89385() { // fn#89385, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:893, offset: 0x0200c4a9, size: 33 bytes, params: 1, frame: 11
var push;
const items2 = [];
if (result) {
push = items2.push;
value = environment.__proto__;
Reflect.apply(push, items2, [WATCH_YOUTUBE_PROD_APP_ID]);
}
return items2;
}
function _fun89386() { // fn#89386, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1017, offset: 0x0200c4ca, size: 35 bytes, params: 1, frame: 10
const value = environment.__proto__;
return UserStore.getCurrentUser()?.nsfwAllowed;
}
function _fun89387() { // fn#89387, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1106, offset: 0x0200c4ed, size: 93 bytes, params: 1, frame: 14
var r0;
const closure = hideAgeRestricted;
var value;
const onlyActivityAppsBinding = onlyActivityApps;
const binding = env0_6;
const filter = binding.filter;
if (onlyActivityAppsBinding) {
value = Reflect.apply(filter, binding, [_fun89389]);
value = value.filter(_fun89390);
value = value.filter(closure);
r0 = value;
} else {
value = Reflect.apply(filter, binding, [_fun89391]);
value = value.filter(closure);
r0 = value;
}
return r0;
}
function _fun89395() { // fn#89395, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1923, offset: 0x0200c779, size: 121 bytes, params: 1, frame: 16
var r0;
var items2;
if (onlyActivityApps) {
return [];
}
const r4 = commandsByActiveSection[0]?.data ?? [];
const commandsBinding = commands;
let value = commandsBinding.find(function({id}) {
return id === lastUsedCommandId;
});
if (value == null) {
r0 = r4;
} else {
items2 = [value];
value = r4.filter(function({id}) {
return id !== lastUsedCommandId;
});
arraySpread(items2, value, 1, commandsBinding);
r0 = items2;
}
return r0;
}
function hideAgeRestricted(a0) { // fn#89388, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1133, offset: 0x0200c54a, size: 59 bytes, params: 2, frame: 12
var r0;
let value = environment.__proto__;
value = env1_7 === false;
if (value) {
value = environment.__proto__.__proto__;
value = importDefault(8040) /* metro dependency 8040: isApplicationAgeRestricted */;
value = value(a0.id);
r0 = value;
} else {
r0 = value;
}
return !r0;
}
function _fun89389(a0) { // fn#89389, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1181, offset: 0x0200c585, size: 116 bytes, params: 2, frame: 15
var r0;
var queryForPrimaryAppCommand;
var value2;
let value = a0.application != null;
if (value) {
value = environment.__proto__.__proto__;
value = require(8046) /* metro dependency 8046: AppLauncherUtils */;
value = value.isEmbeddedApp(a0.application);
r0 = value;
} else {
r0 = value;
}
if (r0) {
value = environment.__proto__.__proto__;
value = require(10657) /* metro dependency 10657: getPrimaryAppCommand */;
queryForPrimaryAppCommand = value.queryForPrimaryAppCommand;
value2 = environment.__proto__;
value = Reflect.apply(queryForPrimaryAppCommand, value, [context, a0.id]) != null;
r0 = value;
}
return r0;
}
function _fun89390({id}) { // fn#89390, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1303, offset: 0x0200c5f9, size: 30 bytes, params: 2, frame: 11
const binding = env1_5;
return !binding.includes(id);
}