Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4791.js (118.4 MB)
164 lines
6.9 KiB
TypeScript
164 lines
6.9 KiB
TypeScript
// Module ID: 12212
|
|
// Function ID: 12213
|
|
// Name: useAppLauncherFrecents
|
|
// Dependencies: [19, 7180, 1371, 12213, 1920, 5050, 1894, 9507, 504, 7243, 8425, 12214, 9497, 9379, 9662, 2]
|
|
// Exports: default, useAppLauncherFrecentApps
|
|
|
|
// Module 12212 (useAppLauncherFrecents)
|
|
import AuthorizedAppsActionCreatorsDefault from "AuthorizedAppsActionCreators" /* 7243 */;
|
|
import ApplicationCommandQueryApiAll from "ApplicationCommandQueryApi" /* 9507 */;
|
|
import noop from "module_19" /* 19 */;
|
|
import AuthorizedAppsStore from "AuthorizedAppsStore" /* 7180 */;
|
|
import UserStore from "UserStore" /* 1371 */;
|
|
import AppLauncherLastUsedCommandStore from "AppLauncherLastUsedCommandStore" /* 12213 */;
|
|
|
|
const require = fn;
|
|
function useFrecentApps(onlyActivityApps) {
|
|
({ sectionDescriptors, context } = onlyActivityApps);
|
|
onlyActivityApps = onlyActivityApps.onlyActivityApps;
|
|
const includeAuthorizedAppsAndFetch = onlyActivityApps.includeAuthorizedAppsAndFetch;
|
|
let stateFromStores;
|
|
noop = undefined;
|
|
let memo;
|
|
let stateFromStores1;
|
|
let items = [memo];
|
|
stateFromStores = context(stateFromStores[8]).useStateFromStores(items, () => memo.getFetchState());
|
|
const items1 = [includeAuthorizedAppsAndFetch, stateFromStores];
|
|
const effect = noop.useEffect(() => {
|
|
let tmp = includeAuthorizedAppsAndFetch;
|
|
if (includeAuthorizedAppsAndFetch) {
|
|
tmp = stateFromStores === FetchState.NOT_FETCHED;
|
|
}
|
|
if (tmp) {
|
|
const response = AuthorizedAppsActionCreatorsDefault.fetch();
|
|
}
|
|
}, items1);
|
|
let obj = context(stateFromStores[8]);
|
|
const items2 = [memo];
|
|
const stateFromStoresArray = context(stateFromStores[8]).useStateFromStoresArray(items2, () => {
|
|
if (includeAuthorizedAppsAndFetch) {
|
|
const newestTokens = AuthorizedAppsStore.getNewestTokens();
|
|
let found = newestTokens.filter((scopes) => {
|
|
scopes = scopes.scopes;
|
|
return scopes.includes(context(stateFromStores[10]).OAuth2Scopes.APPLICATIONS_COMMANDS);
|
|
});
|
|
} else {
|
|
found = [];
|
|
}
|
|
return found;
|
|
});
|
|
noop = tmp5;
|
|
const items3 = ["contextless" === context.type];
|
|
let found = sectionDescriptors.filter((id) => id.id !== constants.FRECENCY && id.id !== tmp.BUILT_IN);
|
|
memo = noop.useMemo(() => {
|
|
const items = [];
|
|
if (closure_4) {
|
|
items.push(WATCH_YOUTUBE_PROD_APP_ID);
|
|
}
|
|
return items;
|
|
}, items3);
|
|
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, () => {
|
|
const currentUser = stateFromStores1.getCurrentUser();
|
|
let nsfwAllowed;
|
|
if (currentUser != null) {
|
|
nsfwAllowed = currentUser.nsfwAllowed;
|
|
}
|
|
return nsfwAllowed;
|
|
});
|
|
const items5 = [onlyActivityApps, sortApplicationsViaFrecency, context, memo, stateFromStores1];
|
|
return noop.useMemo(() => {
|
|
function hideAgeRestricted(id) {
|
|
let tmp = false === stateFromStores1;
|
|
if (tmp) {
|
|
tmp = onlyActivityApps(stateFromStores[12])(id.id);
|
|
}
|
|
return !tmp;
|
|
}
|
|
const filter = sortApplicationsViaFrecency.filter;
|
|
if (onlyActivityApps) {
|
|
const found = filter((application) => {
|
|
let isEmbeddedAppResult = null != application.application;
|
|
if (isEmbeddedAppResult) {
|
|
isEmbeddedAppResult = context(stateFromStores[13]).isEmbeddedApp(application.application);
|
|
const obj = context(stateFromStores[13]);
|
|
}
|
|
if (isEmbeddedAppResult) {
|
|
isEmbeddedAppResult = null != context(stateFromStores[14]).queryForPrimaryAppCommand(closure_1_0, application.id);
|
|
const obj2 = context(stateFromStores[14]);
|
|
}
|
|
return isEmbeddedAppResult;
|
|
});
|
|
const found1 = found.filter((id) => !memo.includes(id.id));
|
|
let found2 = found1.filter(hideAgeRestricted);
|
|
} else {
|
|
const found3 = filter((id) => !memo.includes(id.id));
|
|
found2 = found3.filter(hideAgeRestricted);
|
|
}
|
|
return found2;
|
|
}, items5);
|
|
}
|
|
const FetchState = fn(7180).FetchState;
|
|
const WATCH_YOUTUBE_PROD_APP_ID = fn(1920).WATCH_YOUTUBE_PROD_APP_ID;
|
|
const ApplicationCommandConstants = fn(5050);
|
|
const BuiltInSectionId = ApplicationCommandConstants.BuiltInSectionId;
|
|
let filters = { commandTypes: null };
|
|
let items = [fn(1894).ApplicationCommandType.CHAT, fn(1894).ApplicationCommandType.PRIMARY_ENTRY_POINT];
|
|
filters.commandTypes = items;
|
|
const options = { placeholderCount: 0, limit: ApplicationCommandConstants.DISCOVERY_COMMANDS_QUERY_LIMIT, includeFrecency: true };
|
|
const size = fn(2);
|
|
const result = size.fileFinishedImporting("modules/app_launcher/hooks/useAppLauncherFrecents.tsx");
|
|
|
|
export default function useAppLauncherFrecentCommandsAndApps(arg0) {
|
|
({ context, onlyActivityApps } = arg0);
|
|
let commandsByActiveSection;
|
|
filterSection = undefined;
|
|
let stateFromStores;
|
|
filters = commandsByActiveSection(filterSection[7]);
|
|
const discovery = filters.useDiscovery({ context, filters, options, allowFetch: true });
|
|
const commands = discovery.commands;
|
|
commandsByActiveSection = discovery.commandsByActiveSection;
|
|
({ sectionDescriptors, filterSection } = discovery);
|
|
let items = [filterSection];
|
|
const effect = stateFromStores.useEffect(() => {
|
|
filterSection(BuiltInSectionId.FRECENCY);
|
|
}, items);
|
|
const items1 = [AppLauncherLastUsedCommandStore];
|
|
stateFromStores = onlyActivityApps(filterSection[8]).useStateFromStores(items1, () => lastUsedCommandId.getLastUsedCommandId());
|
|
const obj4 = { loading: discovery.loading, frecencyCommands: null, frecentApps: useFrecentApps({ sectionDescriptors, context, onlyActivityApps, includeAuthorizedAppsAndFetch: true }), sectionDescriptors };
|
|
const items2 = [commands, commandsByActiveSection, stateFromStores, onlyActivityApps];
|
|
obj4.frecencyCommands = stateFromStores.useMemo(() => {
|
|
if (onlyActivityApps) {
|
|
return [];
|
|
} else {
|
|
const first = commandsByActiveSection[0];
|
|
let data;
|
|
if (first != null) {
|
|
data = first.data;
|
|
}
|
|
if (data == null) {
|
|
data = [];
|
|
}
|
|
const found = commands.find((id) => id.id === stateFromStores);
|
|
let tmp6 = data;
|
|
if (null != found) {
|
|
const items = [found];
|
|
HermesBuiltin.arraySpread(data.filter((id) => id.id !== stateFromStores), 1);
|
|
tmp6 = items;
|
|
}
|
|
return tmp6;
|
|
}
|
|
}, items2);
|
|
return obj4;
|
|
};
|
|
export const useAppLauncherFrecentApps = function useAppLauncherFrecentApps(context) {
|
|
context = context.context;
|
|
({ onlyActivityApps, allowCommandFetch, includeAuthorizedAppsAndFetch } = context);
|
|
filters = ApplicationCommandQueryApiAll;
|
|
const discovery = filters.useDiscovery({ context, filters, options, allowFetch: allowCommandFetch });
|
|
const obj3 = { loading: discovery.loading, frecentApps: useFrecentApps({ sectionDescriptors: discovery.sectionDescriptors, context, onlyActivityApps, includeAuthorizedAppsAndFetch }) };
|
|
return obj3;
|
|
};
|