105 lines
3.7 KiB
TypeScript
105 lines
3.7 KiB
TypeScript
// Module ID: 6904
|
|
// Function ID: 6905
|
|
// Name: LibraryApplicationUtils
|
|
// Dependencies: [32, 1377, 5695, 1085, 2028, 2]
|
|
// Exports: calculateProgressPercentage, convertComboId, convertToTransitionState, getCombinedProgress, getComboId, isUserEntitledToLibraryApplication, shouldShareApplicationActivity, shouldShowGameInLibrary
|
|
|
|
// Module 6904 (LibraryApplicationUtils)
|
|
import UserSettings from "UserSettings" /* 2028 */;
|
|
import _slicedToArray from "_slicedToArray" /* 32 */;
|
|
import UserStore from "UserStore" /* 1377 */;
|
|
import SKUStore from "SKUStore" /* 5695 */;
|
|
import Constants from "Constants" /* 1085 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
let hasOwnProperty;
|
|
let metroImportDefault;
|
|
let metroRequire;
|
|
({ LibraryApplicationFlags: hasOwnProperty, LocalDispatchApplicationStates: metroRequire, StatusTypes: metroImportDefault } = Constants);
|
|
const result = size.fileFinishedImporting("utils/LibraryApplicationUtils.tsx");
|
|
|
|
export const getComboId = function getComboId(arg0, arg1) {
|
|
return "" + arg0 + ":" + arg1;
|
|
};
|
|
export const convertComboId = function convertComboId(str) {
|
|
const tmp = _slicedToArray(str.split(":"), 2);
|
|
return { applicationId: tmp[0], branchId: tmp[1] };
|
|
};
|
|
export const shouldShareApplicationActivity = function shouldShareApplicationActivity(applicationId, LibraryApplicationStore) {
|
|
const ShowCurrentGame = UserSettings.ShowCurrentGame;
|
|
if (ShowCurrentGame.getSetting()) {
|
|
const StatusSetting = UserSettings.StatusSetting;
|
|
if (StatusSetting.getSetting() !== metroImportDefault.INVISIBLE) {
|
|
const activeLibraryApplication = LibraryApplicationStore.getActiveLibraryApplication(applicationId);
|
|
const tmp7 = null == activeLibraryApplication || !activeLibraryApplication.hasFlag(hasOwnProperty.PRIVATE);
|
|
return tmp7;
|
|
}
|
|
}
|
|
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) {
|
|
enabled = enabled.enabled;
|
|
let tmp3 = !enabled;
|
|
if (enabled) {
|
|
tmp3 = !hasFlag.hasFlag(hasOwnProperty.PRIVATE);
|
|
}
|
|
if (tmp3) {
|
|
tmp3 = !hasFlag.isHidden();
|
|
}
|
|
tmp = tmp3;
|
|
}
|
|
return tmp;
|
|
};
|
|
export const convertToTransitionState = function convertToTransitionState(type) {
|
|
let tmp = null;
|
|
if (null != type) {
|
|
if (type.type !== metroRequire.INSTALLING) {
|
|
let tmp3;
|
|
if (type.type !== metroRequire.UPDATING) {
|
|
tmp3 = null;
|
|
}
|
|
tmp = tmp3;
|
|
}
|
|
tmp3 = type;
|
|
}
|
|
return tmp;
|
|
};
|
|
export const getCombinedProgress = function getCombinedProgress(arr) {
|
|
return arr.reduce((total, type) => {
|
|
let tmp = null;
|
|
if (null != type) {
|
|
if (type.type !== constants.INSTALLING) {
|
|
let tmp3;
|
|
if (type.type !== constants.UPDATING) {
|
|
tmp3 = null;
|
|
}
|
|
tmp = tmp3;
|
|
}
|
|
tmp3 = type;
|
|
}
|
|
let tmp4 = total;
|
|
if (null != tmp) {
|
|
tmp4 = total;
|
|
if (type.type !== constants.UP_TO_DATE) {
|
|
const _Number = Number;
|
|
const _Number2 = Number;
|
|
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) };
|
|
}
|
|
}
|
|
return tmp4;
|
|
}, { total: 0, progress: 0 });
|
|
};
|
|
export const isUserEntitledToLibraryApplication = function isUserEntitledToLibraryApplication(libraryApplication) {
|
|
const isEntitledResult = libraryApplication.isDiscordApplication() && libraryApplication.isEntitled(UserStore.getCurrentUser(), SKUStore);
|
|
return isEntitledResult;
|
|
};
|