decord/source/modules/applications/ApplicationFrecencyStore.tsx

124 lines
4.3 KiB
TypeScript
Raw Normal View History

2026-08-08 06:10:11 +00:00
// Module ID: 8340
// Function ID: 8341
2026-07-29 08:29:29 +00:00
// Name: handleUserSettingsProtoStoreChange
2026-08-08 06:10:11 +00:00
// Dependencies: [1371, 1340, 4329, 685, 1935, 4387, 12, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-08 06:10:11 +00:00
// Module 8340 (handleUserSettingsProtoStoreChange)
2026-07-29 08:29:29 +00:00
import participantFromServer from "participantFromServer";
import handleConnectionClosedOrResumed from "handleConnectionClosedOrResumed";
2026-07-23 10:11:24 +00:00
import { UserSettingsTypes } from "MAX_FAVORITES";
2026-07-29 08:29:29 +00:00
import { PersistedStore } from "initialize";
2026-07-20 16:05:17 +00:00
function handleUserSettingsProtoStoreChange() {
const applicationFrecency = obj.frecencyWithoutFetchingLatest.applicationFrecency;
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 = {};
}
2026-07-29 08:29:29 +00:00
tmp2.overwriteHistory(importDefault(12).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);
2026-07-29 08:29:29 +00:00
obj.recentUses = mapped.filter((arg0) => arg0 > 0);
2026-07-20 16:05:17 +00:00
return obj;
2026-07-29 08:29:29 +00:00
}), closure_6.pendingUsages);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let items = [require("PermissionOverwriteType").ApplicationCommandType.CHAT, require("PermissionOverwriteType").ApplicationCommandType.PRIMARY_ENTRY_POINT];
2026-07-29 08:29:29 +00:00
let closure_6 = { pendingUsages: [] };
2026-07-20 16:05:17 +00:00
let obj = {
computeBonus() {
return 100;
},
lookupKey(arg0) {
return arg0;
},
afterCompute() {
},
2026-07-23 10:11:24 +00:00
numFrequentlyItems: require("ApplicationTypes").FREQUENCY_ITEM_LIMIT
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
const error = new require("DEFAULT_FRECENCY")(obj);
class ApplicationFrecencyStore extends PersistedStore {
}
const prototype = ApplicationFrecencyStore.prototype;
prototype["initialize"] = function initialize(arg0) {
if (null != arg0) {
let closure_6 = arg0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
this.waitFor(participantFromServer, handleConnectionClosedOrResumed);
const items = [handleConnectionClosedOrResumed];
this.syncWith(items, handleUserSettingsProtoStoreChange);
};
prototype["getState"] = function getState() {
return closure_6;
};
prototype["hasPendingUsage"] = function hasPendingUsage() {
return closure_6.pendingUsages.length > 0;
};
prototype["getApplicationFrecencyWithoutLoadingLatest"] = function getApplicationFrecencyWithoutLoadingLatest() {
return closure_7;
};
prototype["getScoreWithoutLoadingLatest"] = function getScoreWithoutLoadingLatest(id) {
let num = tmp2.getScore(id);
if (num == null) {
num = 0;
}
return num;
};
prototype["getTopApplicationsWithoutLoadingLatest"] = function getTopApplicationsWithoutLoadingLatest() {
return tmp2.frequently;
};
ApplicationFrecencyStore.displayName = "ApplicationFrecencyStore";
ApplicationFrecencyStore.persistKey = "ApplicationFrecency";
2026-07-20 16:05:17 +00:00
obj = {
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) {
2026-07-23 10:11:24 +00:00
launchState = launchState.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 = closure_6.pendingUsages;
const obj = { key: null, timestamp: null };
obj[0] = applicationId;
const _Date = Date;
obj[1] = Date.now();
pendingUsages.push(obj);
tmp2.track(applicationId);
tmp2.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 = closure_6.pendingUsages;
pendingUsages.push({ key: applicationId, timestamp: Date.now() });
tmp2.track(applicationId);
tmp2.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) {
2026-07-29 08:29:29 +00:00
closure_6.pendingUsages = [];
2026-07-20 16:05:17 +00:00
}
}
return false;
}
};
2026-07-29 08:29:29 +00:00
const applicationFrecencyStore = new ApplicationFrecencyStore(require("dispatcher"), obj);
const tmp2 = new require("DEFAULT_FRECENCY")(obj);
const result = require("ApplicationTypes").fileFinishedImporting("modules/applications/ApplicationFrecencyStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default applicationFrecencyStore;