clean up
This commit is contained in:
parent
db817cecf1
commit
777d8fd9f9
|
@ -250,7 +250,9 @@ export default function Sidebar(props: Props) {
|
|||
isPartOfFamily() ? (
|
||||
constants.FAMILY_USAGE_INFO(
|
||||
usage,
|
||||
convertBytesToHumanReadable(getStorage())
|
||||
convertBytesToHumanReadable(
|
||||
getStorage(familyData)
|
||||
)
|
||||
)
|
||||
) : (
|
||||
constants.USAGE_INFO(
|
||||
|
|
|
@ -279,8 +279,7 @@ export const getFamilyPortalRedirectURL = async () => {
|
|||
window.location.origin
|
||||
}/gallery`;
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
logError(e, 'unable to redirect to family portal');
|
||||
logError(e, 'unable to generate to family portal URL');
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -103,28 +103,14 @@ export function getFamilyPlanAdmin(familyData?: FamilyData): FamilyMember {
|
|||
return familyData.members.find((x) => x.isAdmin);
|
||||
}
|
||||
|
||||
export function getStorage(): number {
|
||||
export function getStorage(familyData?: FamilyData): number {
|
||||
const subscription: Subscription = getUserSubscription();
|
||||
const familyData: FamilyData = getFamilyData();
|
||||
familyData = familyData ?? getFamilyData();
|
||||
return isPartOfFamily(familyData)
|
||||
? familyData.storage
|
||||
: subscription.storage;
|
||||
}
|
||||
|
||||
// getFamilyUsage will return total usage for family if user
|
||||
// belong to family group. Otherwise, it will return storage consumed by
|
||||
// current user
|
||||
export function getFamilyUsage(): number {
|
||||
const familyData: FamilyData = getFamilyData();
|
||||
if (isPartOfFamily(familyData)) {
|
||||
let usage = 0;
|
||||
familyData.members.forEach((f) => (usage += f.usage));
|
||||
return usage;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
export function getUserSubscription(): Subscription {
|
||||
return getData(LS_KEYS.SUBSCRIPTION);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue