decord/beta/source/modules/applications/ApplicationFrecencyStore.tsx

136 lines
4.6 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 16:32:48 +00:00
// Module ID: 9249
// Function ID: 9250
// Name: ApplicationFrecencyStore
2026-10-12 16:32:48 +00:00
// Dependencies: [2064, 1244, 1373, 1095, 1998, 5129, 12, 504, 584, 2]
2026-10-12 16:32:48 +00:00
// Module 9249 (ApplicationFrecencyStore)
import _modDef12 from "module_12" /* 12 */;
2026-10-01 14:13:23 +00:00
import get_initializedDefault from "get initialized" /* 504 */;
2026-10-07 22:43:51 +00:00
import DispatcherDefault from "Dispatcher" /* 584 */;
import UserSettingsConstants from "UserSettingsConstants" /* 1095 */;
2026-10-12 16:32:48 +00:00
import ApplicationConstants from "ApplicationConstants" /* 1373 */;
import Server from "Server" /* 1998 */;
import FrecencyDefault from "Frecency" /* 5129 */;
import EmbeddedActivitiesStore from "EmbeddedActivitiesStore" /* 2064 */;
import UserSettingsProtoStore from "UserSettingsProtoStore" /* 1244 */;
2026-10-01 14:13:23 +00:00
import size from "module_2" /* 2 */;
let closure_6, recentUses;
function handleUserSettingsProtoStoreChange() {
const applicationFrecency = UserSettingsProtoStore.frecencyWithoutFetchingLatest.applicationFrecency;
let applications;
if (applicationFrecency != null) {
applications = applicationFrecency.applications;
}
if (applications == null) {
applications = {};
}
2026-10-01 14:13:23 +00:00
const overwriteHistory = closure_7.overwriteHistory;
const obj2 = _modDef12;
overwriteHistory(obj2.mapValues(applications, (recentUses) => {
let mapped;
const obj = { recentUses: mapped.filter((item) => item > 0) };
const merged = Object.assign(recentUses);
recentUses = recentUses.recentUses;
2026-10-01 14:13:23 +00:00
mapped = recentUses.map(Number);
return obj;
2026-10-01 14:13:23 +00:00
}), closure_6.pendingUsages);
}
2026-10-01 14:13:23 +00:00
const FREQUENCY_ITEM_LIMIT = ApplicationConstants.FREQUENCY_ITEM_LIMIT;
const UserSettingsTypes = UserSettingsConstants.UserSettingsTypes;
let items = [Server.ApplicationCommandType.CHAT, Server.ApplicationCommandType.PRIMARY_ENTRY_POINT];
const metroRequire = { pendingUsages: [] };
let obj = {
computeBonus() {
return 100;
},
lookupKey(arg0) {
return arg0;
},
afterCompute() {
},
2026-10-01 14:13:23 +00:00
numFrequentlyItems: FREQUENCY_ITEM_LIMIT
};
2026-10-01 14:13:23 +00:00
const metroImportDefault = new FrecencyDefault(obj);
const tmp2 = new FrecencyDefault(obj);
const PersistedStore = get_initializedDefault.PersistedStore;
class ApplicationFrecencyStore extends PersistedStore {
2026-10-01 14:13:23 +00:00
initialize(arg0) {
if (null != arg0) {
closure_6 = arg0;
}
this.waitFor(EmbeddedActivitiesStore, UserSettingsProtoStore);
items = [UserSettingsProtoStore];
this.syncWith(items, handleUserSettingsProtoStoreChange);
}
2026-10-01 14:13:23 +00:00
getState() {
return closure_6;
}
2026-10-01 14:13:23 +00:00
hasPendingUsage() {
return closure_6.pendingUsages.length > 0;
}
getApplicationFrecencyWithoutLoadingLatest() {
return closure_7;
}
getScoreWithoutLoadingLatest(id) {
let num = closure_7.getScore(id);
if (num == null) {
num = 0;
}
return num;
}
getTopApplicationsWithoutLoadingLatest() {
return closure_7.frequently;
}
}
const prototype = ApplicationFrecencyStore.prototype;
ApplicationFrecencyStore.displayName = "ApplicationFrecencyStore";
ApplicationFrecencyStore.persistKey = "ApplicationFrecency";
2026-10-01 14:13:23 +00:00
let obj2 = {
APPLICATION_COMMAND_USED: function handleApplicationCommandUsed(command) {
command = command.command;
let hasItem = items.includes(command.type);
if (hasItem) {
const launchState = EmbeddedActivitiesStore.getLaunchState(command.applicationId);
let isLaunching;
if (launchState != null) {
isLaunching = launchState.isLaunching;
}
if (!isLaunching) {
const applicationId = command.applicationId;
2026-10-01 14:13:23 +00:00
const pendingUsages = closure_6.pendingUsages;
const _Date = Date;
2026-10-01 14:13:23 +00:00
const push = pendingUsages.push;
const obj = { key: applicationId, timestamp: Date.now() };
push(obj);
closure_7.track(applicationId);
closure_7.compute();
}
2026-10-01 14:13:23 +00:00
hasItem = tmp6;
}
return hasItem;
},
EMBEDDED_ACTIVITY_OPEN: function handleEmbeddedActivityOpen(applicationId) {
applicationId = applicationId.applicationId;
2026-10-01 14:13:23 +00:00
const pendingUsages = closure_6.pendingUsages;
const obj = { key: applicationId, timestamp: Date.now() };
pendingUsages.push(obj);
closure_7.track(applicationId);
closure_7.compute();
},
USER_SETTINGS_PROTO_UPDATE: function handleUserSettingsProtoUpdate(settings) {
if (settings.settings.type === UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS) {
if (settings.wasSaved) {
2026-10-01 14:13:23 +00:00
closure_6.pendingUsages = [];
}
}
return false;
}
2026-10-01 14:13:23 +00:00
};
const applicationFrecencyStore = new ApplicationFrecencyStore(DispatcherDefault, obj2);
const result = size.fileFinishedImporting("modules/applications/ApplicationFrecencyStore.tsx");
export default applicationFrecencyStore;