decord/source/modules/app_launcher/hooks/useAppLauncherFrecents.tsx

177 lines
6.8 KiB
TypeScript
Raw Normal View History

2026-07-27 11:26:19 +00:00
// Module ID: 11230
// Function ID: 87352
2026-07-20 16:05:17 +00:00
// Name: useFrecentApps
2026-07-27 11:26:19 +00:00
// Dependencies: [31, 5067, 1850, 11231, 4156, 4567, 1882, 7962, 566, 5470, 8112, 11232, 7964, 7953, 11233, 2]
2026-07-20 16:05:17 +00:00
// Exports: default, useAppLauncherFrecentApps
2026-07-27 11:26:19 +00:00
// Module 11230 (useFrecentApps)
2026-07-23 10:11:24 +00:00
import result from "result";
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import { FetchState } from "_isNativeReflectConstruct";
import closure_7 from "_isNativeReflectConstruct";
import closure_8 from "_isNativeReflectConstruct";
import { WATCH_YOUTUBE_PROD_APP_ID } from "items3";
import TRUE_OPTION_NAME from "TRUE_OPTION_NAME";
const require = arg1;
2026-07-20 16:05:17 +00:00
function useFrecentApps(onlyActivityApps) {
let context;
let sectionDescriptors;
({ sectionDescriptors, context } = onlyActivityApps);
onlyActivityApps = onlyActivityApps.onlyActivityApps;
const includeAuthorizedAppsAndFetch = onlyActivityApps.includeAuthorizedAppsAndFetch;
2026-07-23 10:11:24 +00:00
let items = [memo];
stateFromStores = context(stateFromStores[8]).useStateFromStores(items, () => memo.getFetchState());
2026-07-20 16:05:17 +00:00
const items1 = [includeAuthorizedAppsAndFetch, stateFromStores];
const effect = React.useEffect(() => {
let tmp = includeAuthorizedAppsAndFetch;
if (includeAuthorizedAppsAndFetch) {
tmp = stateFromStores === sortApplicationsViaFrecency.NOT_FETCHED;
}
if (tmp) {
const response = onlyActivityApps(stateFromStores[9]).fetch();
const obj = onlyActivityApps(stateFromStores[9]);
}
}, items1);
2026-07-23 10:11:24 +00:00
let obj = context(stateFromStores[8]);
const items2 = [memo];
const stateFromStoresArray = context(stateFromStores[8]).useStateFromStoresArray(items2, () => {
2026-07-20 16:05:17 +00:00
if (includeAuthorizedAppsAndFetch) {
const newestTokens = memo.getNewestTokens();
let found = newestTokens.filter((scopes) => {
scopes = scopes.scopes;
2026-07-23 10:11:24 +00:00
return scopes.includes(context(stateFromStores[10]).OAuth2Scopes.APPLICATIONS_COMMANDS);
2026-07-20 16:05:17 +00:00
});
} else {
found = [];
}
return found;
});
2026-07-23 10:11:24 +00:00
React = tmp5;
2026-07-20 16:05:17 +00:00
const items3 = ["contextless" === context.type];
2026-07-23 10:11:24 +00:00
let found = sectionDescriptors.filter((id) => {
let tmp = id.id !== outer1_10.FRECENCY;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-07-23 10:11:24 +00:00
tmp = id.id !== outer1_10.BUILT_IN;
2026-07-20 16:05:17 +00:00
}
return tmp;
});
2026-07-23 10:11:24 +00:00
memo = React.useMemo(() => {
2026-07-20 16:05:17 +00:00
const items = [];
2026-07-23 10:11:24 +00:00
if (result) {
items.push(outer1_9);
2026-07-20 16:05:17 +00:00
}
return items;
}, items3);
2026-07-23 10:11:24 +00:00
let obj2 = context(stateFromStores[8]);
const sortApplicationsViaFrecency = context(stateFromStores[11]).useSortApplicationsViaFrecency(found, stateFromStoresArray);
const obj3 = context(stateFromStores[11]);
const items4 = [stateFromStores1];
stateFromStores1 = context(stateFromStores[8]).useStateFromStores(items4, () => {
2026-07-20 16:05:17 +00:00
const currentUser = stateFromStores1.getCurrentUser();
let nsfwAllowed;
if (null != currentUser) {
nsfwAllowed = currentUser.nsfwAllowed;
}
return nsfwAllowed;
});
const items5 = [onlyActivityApps, sortApplicationsViaFrecency, context, memo, stateFromStores1];
return React.useMemo(() => {
function hideAgeRestricted(id) {
2026-07-23 10:11:24 +00:00
let tmp = false === outer1_7;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-07-23 10:11:24 +00:00
tmp = onlyActivityApps(stateFromStores[12])(id.id);
2026-07-20 16:05:17 +00:00
}
return !tmp;
}
const filter = sortApplicationsViaFrecency.filter;
if (onlyActivityApps) {
const found = filter((application) => {
let isEmbeddedAppResult = null != application.application;
if (isEmbeddedAppResult) {
2026-07-23 10:11:24 +00:00
isEmbeddedAppResult = context(stateFromStores[13]).isEmbeddedApp(application.application);
const obj = context(stateFromStores[13]);
2026-07-20 16:05:17 +00:00
}
if (isEmbeddedAppResult) {
2026-07-23 10:11:24 +00:00
isEmbeddedAppResult = null != context(stateFromStores[14]).queryForPrimaryAppCommand(outer1_0, application.id);
const obj2 = context(stateFromStores[14]);
2026-07-20 16:05:17 +00:00
}
return isEmbeddedAppResult;
});
2026-07-23 10:11:24 +00:00
const found1 = found.filter((id) => !outer1_5.includes(id.id));
2026-07-20 16:05:17 +00:00
let found2 = found1.filter(hideAgeRestricted);
} else {
2026-07-23 10:11:24 +00:00
const found3 = filter((id) => !outer1_5.includes(id.id));
2026-07-20 16:05:17 +00:00
found2 = found3.filter(hideAgeRestricted);
}
return found2;
}, items5);
}
2026-07-23 10:11:24 +00:00
const BuiltInSectionId = TRUE_OPTION_NAME.BuiltInSectionId;
2026-07-21 22:01:30 +00:00
let obj = {};
2026-07-23 10:11:24 +00:00
let items = [require("PermissionOverwriteType").ApplicationCommandType.CHAT, require("PermissionOverwriteType").ApplicationCommandType.PRIMARY_ENTRY_POINT];
2026-07-20 16:05:17 +00:00
obj.commandTypes = items;
2026-07-23 10:11:24 +00:00
obj = { placeholderCount: 0, limit: TRUE_OPTION_NAME.DISCOVERY_COMMANDS_QUERY_LIMIT, includeFrecency: true };
const result = require("_isNativeReflectConstruct").fileFinishedImporting("modules/app_launcher/hooks/useAppLauncherFrecents.tsx");
2026-07-20 16:05:17 +00:00
export default function useAppLauncherFrecentCommandsAndApps(arg0) {
let context;
let filterSection;
let onlyActivityApps;
let sectionDescriptors;
({ context, onlyActivityApps } = arg0);
2026-07-23 10:11:24 +00:00
let obj = commandsByActiveSection(filterSection[7]);
2026-07-21 22:01:30 +00:00
obj = { context, filters: obj, options: obj, allowFetch: true };
2026-07-20 16:05:17 +00:00
const discovery = obj.useDiscovery(obj);
const commands = discovery.commands;
2026-07-23 10:11:24 +00:00
commandsByActiveSection = discovery.commandsByActiveSection;
2026-07-20 16:05:17 +00:00
({ sectionDescriptors, filterSection } = discovery);
2026-07-23 10:11:24 +00:00
let items = [filterSection];
const effect = stateFromStores.useEffect(() => {
filterSection(outer1_10.FRECENCY);
2026-07-20 16:05:17 +00:00
}, items);
const items1 = [closure_8];
2026-07-23 10:11:24 +00:00
stateFromStores = onlyActivityApps(filterSection[8]).useStateFromStores(items1, () => outer1_8.getLastUsedCommandId());
2026-07-20 16:05:17 +00:00
obj = {
loading: discovery.loading,
2026-07-23 10:11:24 +00:00
frecencyCommands: stateFromStores.useMemo(() => {
2026-07-20 16:05:17 +00:00
if (onlyActivityApps) {
return [];
} else {
const first = commandsByActiveSection[0];
let data;
if (null != first) {
data = first.data;
}
if (null == data) {
data = [];
}
2026-07-23 10:11:24 +00:00
const found = commands.find((id) => id.id === outer1_4);
2026-07-20 16:05:17 +00:00
let tmp6 = data;
if (null != found) {
const items = [found];
2026-07-23 10:11:24 +00:00
HermesBuiltin.arraySpread(data.filter((id) => id.id !== outer1_4), 1);
2026-07-20 16:05:17 +00:00
tmp6 = items;
}
return tmp6;
}
}, items2),
frecentApps: useFrecentApps({ sectionDescriptors, context, onlyActivityApps, includeAuthorizedAppsAndFetch: true }),
sectionDescriptors
};
2026-07-23 10:11:24 +00:00
items2 = [commands, commandsByActiveSection, stateFromStores, onlyActivityApps];
2026-07-20 16:05:17 +00:00
return obj;
};
export const useAppLauncherFrecentApps = function useAppLauncherFrecentApps(context) {
let allowCommandFetch;
let includeAuthorizedAppsAndFetch;
let onlyActivityApps;
context = context.context;
({ onlyActivityApps, allowCommandFetch, includeAuthorizedAppsAndFetch } = context);
2026-07-25 08:10:48 +00:00
let obj = importAll(7962);
2026-07-21 22:01:30 +00:00
obj = { context, filters: obj, options: obj, allowFetch: allowCommandFetch };
2026-07-20 16:05:17 +00:00
const discovery = obj.useDiscovery(obj);
obj = { loading: discovery.loading, frecentApps: useFrecentApps(obj1) };
return obj;
};