decord/alpha/source/utils/LibraryApplicationUtils.tsx

106 lines
3.7 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 06:59:38 +00:00
// Module ID: 7115
// Function ID: 7116
// Name: LibraryApplicationUtils
2026-10-12 06:59:38 +00:00
// Dependencies: [32, 1390, 6088, 1085, 2041, 2]
2026-07-29 08:29:29 +00:00
// Exports: calculateProgressPercentage, convertComboId, convertToTransitionState, getCombinedProgress, getComboId, isUserEntitledToLibraryApplication, shouldShareApplicationActivity, shouldShowGameInLibrary
2026-07-20 16:05:17 +00:00
2026-10-12 06:59:38 +00:00
// Module 7115 (LibraryApplicationUtils)
2026-10-09 10:00:15 +00:00
import UserSettings from "UserSettings" /* 2041 */;
2026-10-03 08:58:59 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
2026-10-09 10:00:15 +00:00
import UserStore from "UserStore" /* 1390 */;
2026-10-12 06:59:38 +00:00
import SKUStore from "SKUStore" /* 6088 */;
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let hasOwnProperty;
let metroImportDefault;
let metroRequire;
({ LibraryApplicationFlags: hasOwnProperty, LocalDispatchApplicationStates: metroRequire, StatusTypes: metroImportDefault } = Constants);
const result = size.fileFinishedImporting("utils/LibraryApplicationUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getComboId = function getComboId(arg0, arg1) {
return "" + arg0 + ":" + arg1;
};
export const convertComboId = function convertComboId(str) {
const tmp = _slicedToArray(str.split(":"), 2);
2026-07-20 16:05:17 +00:00
return { applicationId: tmp[0], branchId: tmp[1] };
};
2026-10-03 08:58:59 +00:00
export const shouldShareApplicationActivity = function shouldShareApplicationActivity(applicationId, LibraryApplicationStore) {
const ShowCurrentGame = UserSettings.ShowCurrentGame;
2026-07-20 16:05:17 +00:00
if (ShowCurrentGame.getSetting()) {
const StatusSetting = UserSettings.StatusSetting;
2026-10-03 08:58:59 +00:00
if (StatusSetting.getSetting() !== metroImportDefault.INVISIBLE) {
const activeLibraryApplication = LibraryApplicationStore.getActiveLibraryApplication(applicationId);
const tmp7 = null == activeLibraryApplication || !activeLibraryApplication.hasFlag(hasOwnProperty.PRIVATE);
2026-07-29 08:29:29 +00:00
return tmp7;
2026-07-20 16:05:17 +00:00
}
}
return false;
};
export const calculateProgressPercentage = function calculateProgressPercentage(arg0, arg1) {
let num = 100;
if (0 !== arg1) {
num = arg0 / arg1 * 100;
}
return num;
};
export const shouldShowGameInLibrary = function shouldShowGameInLibrary(arg0, hasFlag, enabled) {
let tmp = null != hasFlag;
if (tmp) {
2026-07-29 08:29:29 +00:00
enabled = enabled.enabled;
let tmp3 = !enabled;
if (enabled) {
2026-10-03 08:58:59 +00:00
tmp3 = !hasFlag.hasFlag(hasOwnProperty.PRIVATE);
2026-07-20 16:05:17 +00:00
}
if (tmp3) {
tmp3 = !hasFlag.isHidden();
}
tmp = tmp3;
}
return tmp;
};
2026-07-29 08:29:29 +00:00
export const convertToTransitionState = function convertToTransitionState(type) {
let tmp = null;
if (null != type) {
2026-10-03 08:58:59 +00:00
if (type.type !== metroRequire.INSTALLING) {
let tmp3;
if (type.type !== metroRequire.UPDATING) {
tmp3 = null;
2026-07-29 08:29:29 +00:00
}
tmp = tmp3;
}
tmp3 = type;
}
return tmp;
};
2026-07-20 16:05:17 +00:00
export const getCombinedProgress = function getCombinedProgress(arr) {
return arr.reduce((total, type) => {
2026-07-29 08:29:29 +00:00
let tmp = null;
if (null != type) {
if (type.type !== constants.INSTALLING) {
2026-10-03 08:58:59 +00:00
let tmp3;
if (type.type !== constants.UPDATING) {
tmp3 = null;
2026-07-29 08:29:29 +00:00
}
tmp = tmp3;
}
tmp3 = type;
}
let tmp4 = total;
2026-07-20 16:05:17 +00:00
if (null != tmp) {
2026-07-29 08:29:29 +00:00
tmp4 = total;
if (type.type !== constants.UP_TO_DATE) {
2026-07-20 16:05:17 +00:00
const _Number = Number;
const _Number2 = Number;
2026-10-03 08:58:59 +00:00
tmp4 = { total: total.total + Number(tmp.total), progress: total.progress + Number(tmp.progress) };
const obj = { total: total.total + Number(tmp.total), progress: total.progress + Number(tmp.progress) };
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return tmp4;
2026-07-23 10:11:24 +00:00
}, { total: 0, progress: 0 });
2026-07-20 16:05:17 +00:00
};
export const isUserEntitledToLibraryApplication = function isUserEntitledToLibraryApplication(libraryApplication) {
2026-10-03 08:58:59 +00:00
const isEntitledResult = libraryApplication.isDiscordApplication() && libraryApplication.isEntitled(UserStore.getCurrentUser(), SKUStore);
2026-07-20 16:05:17 +00:00
return isEntitledResult;
};