diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 0a8d136a3..9041b3dd4 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -250,7 +250,9 @@ export default function Sidebar(props: Props) { isPartOfFamily() ? ( constants.FAMILY_USAGE_INFO( usage, - convertBytesToHumanReadable(getStorage()) + convertBytesToHumanReadable( + getStorage(familyData) + ) ) ) : ( constants.USAGE_INFO( diff --git a/src/services/userService.ts b/src/services/userService.ts index 07b9e41c9..15a43c0fa 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -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; } }; diff --git a/src/utils/billing/index.ts b/src/utils/billing/index.ts index aa2c738b1..74fb5cd92 100644 --- a/src/utils/billing/index.ts +++ b/src/utils/billing/index.ts @@ -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); }