53 lines
2.2 KiB
TypeScript
53 lines
2.2 KiB
TypeScript
// Metro module 4233 (f4234).
|
|
import _slicedToArray from "../_bundle/_slicedToArray";
|
|
import UserStore from "../stores/UserStore";
|
|
import SKUStore from "../stores/game_store/SKUStore";
|
|
import { LibraryApplicationFlags, LocalDispatchApplicationStates, StatusTypes } from "../Constants";
|
|
import { ShowCurrentGame, StatusSetting } from "../modules/user_settings/UserSettings";
|
|
export function getComboId(a0, a1) {
|
|
return `${a0}:${a1}`;
|
|
}
|
|
export function convertComboId(a0) {
|
|
const r8 = _slicedToArray(a0.split(":"), 2);
|
|
return {
|
|
applicationId: r8[0],
|
|
branchId: r8[1]
|
|
};
|
|
}
|
|
export function shouldShareApplicationActivity(a0, a1) {
|
|
if (ShowCurrentGame.getSetting() && StatusSetting.getSetting() !== StatusTypes.INVISIBLE) {
|
|
const activeLibraryApplication = a1.getActiveLibraryApplication(a0);
|
|
return activeLibraryApplication == null || !activeLibraryApplication.hasFlag(LibraryApplicationFlags.PRIVATE);
|
|
}
|
|
return false;
|
|
}
|
|
export function calculateProgressPercentage(a0, a1) {
|
|
return a1 !== 0 ? a0 / a1 * 100 : 100;
|
|
}
|
|
export function shouldShowGameInLibrary(a0, a1, a2) {
|
|
let r6 = a1 != null;
|
|
if (r6) {
|
|
const enabled = a2.enabled;
|
|
r6 = (enabled ? !a1.hasFlag(LibraryApplicationFlags.PRIVATE) : !enabled) && !a1.isHidden();
|
|
}
|
|
return r6;
|
|
}
|
|
export function convertToTransitionState(a0) {
|
|
return a0 == null ? null : a0.type !== LocalDispatchApplicationStates.INSTALLING && a0.type !== LocalDispatchApplicationStates.UPDATING ? a0.type === LocalDispatchApplicationStates.UNINSTALLING ? a0 : null : a0;
|
|
}
|
|
export function getCombinedProgress(a0) {
|
|
return a0.reduce((acc, item) => {
|
|
const r4 = item == null ? null : item.type !== LocalDispatchApplicationStates.INSTALLING && item.type !== LocalDispatchApplicationStates.UPDATING ? item.type === LocalDispatchApplicationStates.UNINSTALLING ? item : null : item;
|
|
return r4 != null ? item.type !== LocalDispatchApplicationStates.UP_TO_DATE ? {
|
|
total: acc.total + Number(r4.total),
|
|
progress: acc.progress + Number(r4.progress)
|
|
} : acc : acc;
|
|
}, {
|
|
total: 0,
|
|
progress: 0
|
|
});
|
|
}
|
|
export function isUserEntitledToLibraryApplication(a0) {
|
|
return !!a0.isDiscordApplication() && a0.isEntitled(UserStore.getCurrentUser(), SKUStore);
|
|
}
|