decord/source/modules/applications/ApplicationFrecencyStore.tsx

128 lines
4.5 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 8495
// Function ID: 8496
2026-07-29 08:29:29 +00:00
// Name: handleUserSettingsProtoStoreChange
2026-08-25 06:04:03 +00:00
// Dependencies: [1390, 1340, 4409, 685, 1955, 4466, 12, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-25 06:04:03 +00:00
// Module 8495 (handleUserSettingsProtoStoreChange)
2026-08-24 06:08:38 +00:00
import applyDefault from "apply" /* 12 */;
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
2026-08-25 06:04:03 +00:00
import DEFAULT_FRECENCYDefault from "DEFAULT_FRECENCY" /* 4466 */;
2026-08-24 06:08:38 +00:00
import closure_2 from "participantFromServer" /* 1390 */;
import closure_3 from "handleConnectionClosedOrResumed" /* 1340 */;
import { UserSettingsTypes } from "MAX_FAVORITES" /* 685 */;
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-08-24 06:08:38 +00:00
closure_7.overwriteHistory(applyDefault.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-08-24 06:08:38 +00:00
let closure_7 = new DEFAULT_FRECENCYDefault(obj);
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) {
2026-08-24 06:08:38 +00:00
closure_6 = arg0;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
this.waitFor(closure_2, closure_3);
items = [closure_3];
2026-07-29 08:29:29 +00:00
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) {
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";
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);
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 = closure_6.pendingUsages;
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) {
2026-07-29 08:29:29 +00:00
closure_6.pendingUsages = [];
2026-07-20 16:05:17 +00:00
}
}
return false;
}
};
2026-08-24 06:08:38 +00:00
const applicationFrecencyStore = new ApplicationFrecencyStore(dispatcherDefault, obj);
const tmp2 = new DEFAULT_FRECENCYDefault(obj);
const result = require("set").fileFinishedImporting("modules/applications/ApplicationFrecencyStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default applicationFrecencyStore;