decord/source/utils/LibraryApplicationUtils.tsx
2026-08-04 08:36:32 +00:00

110 lines
3.5 KiB
TypeScript

// Module ID: 4329
// Function ID: 4330
// Name: getComboId
// Dependencies: [32, 1874, 4330, 676, 3958, 2]
// Exports: calculateProgressPercentage, convertComboId, convertToTransitionState, getCombinedProgress, getComboId, isUserEntitledToLibraryApplication, shouldShareApplicationActivity, shouldShowGameInLibrary
// Module 4329 (getComboId)
import _slicedToArray from "_slicedToArray";
import mergeGuildAvatar from "mergeGuildAvatar";
import addSku from "addSku";
import ME from "ME";
let c5;
let closure_6;
let error;
const require = arg1;
({ LibraryApplicationFlags: c5, LocalDispatchApplicationStates: closure_6, StatusTypes: error } = ME);
const result = require("addSku").fileFinishedImporting("utils/LibraryApplicationUtils.tsx");
export const getComboId = function getComboId(arg0, arg1) {
return "" + arg0 + ":" + arg1;
};
export const convertComboId = function convertComboId(str) {
const tmp = callback(str.split(":"), 2);
return { applicationId: tmp[0], branchId: tmp[1] };
};
export const shouldShareApplicationActivity = function shouldShareApplicationActivity(application_id, closure_7) {
const ShowCurrentGame = require(3958) /* explicitContentFromProto */.ShowCurrentGame;
if (ShowCurrentGame.getSetting()) {
const StatusSetting = require(3958) /* explicitContentFromProto */.StatusSetting;
if (StatusSetting.getSetting() !== constants3.INVISIBLE) {
const activeLibraryApplication = closure_7.getActiveLibraryApplication(application_id);
let tmp7 = null == activeLibraryApplication;
if (!tmp7) {
tmp7 = !activeLibraryApplication.hasFlag(constants.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(constants.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 !== constants2.INSTALLING) {
if (type.type !== tmp2.UPDATING) {
let 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) {
if (type.type !== tmp2.UPDATING) {
let tmp3 = null;
}
tmp = tmp3;
}
tmp3 = type;
}
let tmp4 = total;
if (null != tmp) {
tmp4 = total;
if (type.type !== constants.UP_TO_DATE) {
const obj = { total: null, progress: null };
const _Number = Number;
obj[0] = total.total + Number(tmp.total);
const _Number2 = Number;
obj[1] = total.progress + Number(tmp.progress);
tmp4 = obj;
}
}
return tmp4;
}, { total: 0, progress: 0 });
};
export const isUserEntitledToLibraryApplication = function isUserEntitledToLibraryApplication(libraryApplication) {
let isEntitledResult = libraryApplication.isDiscordApplication();
if (isEntitledResult) {
isEntitledResult = libraryApplication.isEntitled(currentUser.getCurrentUser(), addSku);
}
return isEntitledResult;
};