decord/source/modules/applications/ApplicationFrecencyStore.tsx

137 lines
4.5 KiB
TypeScript
Raw Normal View History

// Module ID: 9434
// Function ID: 9435
// Name: ApplicationFrecencyStore
// Dependencies: [1957, 1220, 1349, 1084, 1895, 4675, 12, 504, 573, 2]
2026-07-23 10:11:24 +00:00
// Module 9434 (ApplicationFrecencyStore)
import _modDef12 from "module_12" /* 12 */;
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import FrecencyDefault from "Frecency" /* 4675 */;
import EmbeddedActivitiesStore from "EmbeddedActivitiesStore" /* 1957 */;
import UserSettingsProtoStore from "UserSettingsProtoStore" /* 1220 */;
2026-07-20 16:05:17 +00:00
function handleUserSettingsProtoStoreChange() {
const applicationFrecency = UserSettingsProtoStore.frecencyWithoutFetchingLatest.applicationFrecency;
2026-07-20 16:05:17 +00:00
let applications;
2026-07-29 08:29:29 +00:00
if (applicationFrecency != null) {
2026-07-20 16:05:17 +00:00
applications = applicationFrecency.applications;
}
2026-07-29 08:29:29 +00:00
if (applications == null) {
2026-07-20 16:05:17 +00:00
applications = {};
}
closure_7.overwriteHistory(_modDef12.mapValues(applications, (recentUses) => {
2026-07-20 16:05:17 +00:00
const obj = {};
const merged = Object.assign(recentUses);
recentUses = recentUses.recentUses;
const mapped = recentUses.map(Number);
obj.recentUses = mapped.filter((item) => item > 0);
2026-07-20 16:05:17 +00:00
return obj;
}), global.pendingUsages);
2026-07-20 16:05:17 +00:00
}
const UserSettingsTypes = fn(1084).UserSettingsTypes;
let items = [fn(1895).ApplicationCommandType.CHAT, fn(1895).ApplicationCommandType.PRIMARY_ENTRY_POINT];
let global = { pendingUsages: [] };
2026-07-20 16:05:17 +00:00
let obj = {
computeBonus() {
return 100;
},
lookupKey(arg0) {
return arg0;
},
afterCompute() {
},
numFrequentlyItems: fn(1349).FREQUENCY_ITEM_LIMIT
2026-07-20 16:05:17 +00:00
};
let closure_7 = new FrecencyDefault({
computeBonus() {
return 100;
},
lookupKey(arg0) {
return arg0;
},
afterCompute() {
},
numFrequentlyItems: fn(1349).FREQUENCY_ITEM_LIMIT
});
2026-08-24 06:08:38 +00:00
const PersistedStore = initializeDefault.PersistedStore;
2026-07-29 08:29:29 +00:00
class ApplicationFrecencyStore extends PersistedStore {
}
const prototype = ApplicationFrecencyStore.prototype;
prototype["initialize"] = function initialize(arg0) {
if (null != arg0) {
global = arg0;
2026-07-20 16:05:17 +00:00
}
this.waitFor(EmbeddedActivitiesStore, UserSettingsProtoStore);
items = [UserSettingsProtoStore];
2026-07-29 08:29:29 +00:00
this.syncWith(items, handleUserSettingsProtoStoreChange);
};
prototype["getState"] = function getState() {
return global;
2026-07-29 08:29:29 +00:00
};
prototype["hasPendingUsage"] = function hasPendingUsage() {
return global.pendingUsages.length > 0;
2026-07-29 08:29:29 +00:00
};
prototype["getApplicationFrecencyWithoutLoadingLatest"] = function getApplicationFrecencyWithoutLoadingLatest() {
return closure_7;
};
prototype["getScoreWithoutLoadingLatest"] = function getScoreWithoutLoadingLatest(id) {
2026-08-24 06:08:38 +00:00
let num = closure_7.getScore(id);
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
}
return num;
};
prototype["getTopApplicationsWithoutLoadingLatest"] = function getTopApplicationsWithoutLoadingLatest() {
2026-08-24 06:08:38 +00:00
return closure_7.frequently;
2026-07-29 08:29:29 +00:00
};
ApplicationFrecencyStore.displayName = "ApplicationFrecencyStore";
ApplicationFrecencyStore.persistKey = "ApplicationFrecency";
const applicationFrecencyStore = new ApplicationFrecencyStore(DispatcherDefault, {
2026-07-20 16:05:17 +00:00
APPLICATION_COMMAND_USED: function handleApplicationCommandUsed(command) {
command = command.command;
2026-07-29 08:29:29 +00:00
let hasItem = items.includes(command.type);
if (hasItem) {
const launchState = EmbeddedActivitiesStore.getLaunchState(command.applicationId);
2026-07-29 08:29:29 +00:00
let isLaunching;
if (launchState != null) {
isLaunching = launchState.isLaunching;
}
if (!isLaunching) {
const applicationId = command.applicationId;
const pendingUsages = global.pendingUsages;
const obj = { key: applicationId, timestamp: null };
2026-07-29 08:29:29 +00:00
const _Date = Date;
obj.timestamp = Date.now();
2026-07-29 08:29:29 +00:00
pendingUsages.push(obj);
2026-08-24 06:08:38 +00:00
closure_7.track(applicationId);
closure_7.compute();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
hasItem = !isLaunching;
const tmp6 = !isLaunching;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return hasItem;
2026-07-20 16:05:17 +00:00
},
EMBEDDED_ACTIVITY_OPEN: function handleEmbeddedActivityOpen(applicationId) {
2026-07-29 08:29:29 +00:00
applicationId = applicationId.applicationId;
const pendingUsages = global.pendingUsages;
2026-07-29 08:29:29 +00:00
pendingUsages.push({ key: applicationId, timestamp: Date.now() });
2026-08-24 06:08:38 +00:00
closure_7.track(applicationId);
closure_7.compute();
2026-07-20 16:05:17 +00:00
},
USER_SETTINGS_PROTO_UPDATE: function handleUserSettingsProtoUpdate(settings) {
if (settings.settings.type === UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS) {
if (settings.wasSaved) {
global.pendingUsages = [];
2026-07-20 16:05:17 +00:00
}
}
return false;
}
});
const size = fn(2);
const result = size.fileFinishedImporting("modules/applications/ApplicationFrecencyStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default applicationFrecencyStore;