This commit is contained in:
Neeraj Gupta 2022-04-21 22:34:26 +05:30
parent db817cecf1
commit 777d8fd9f9
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
3 changed files with 6 additions and 19 deletions

View file

@ -250,7 +250,9 @@ export default function Sidebar(props: Props) {
isPartOfFamily() ? (
constants.FAMILY_USAGE_INFO(
usage,
convertBytesToHumanReadable(getStorage())
convertBytesToHumanReadable(
getStorage(familyData)
)
)
) : (
constants.USAGE_INFO(

View file

@ -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;
}
};

View file

@ -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);
}