Skip to content

Commit

Permalink
fix: duplicate files quota calls in preferences (#1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara authored Apr 27, 2022
1 parent d33e48e commit e7fb9b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import { WebApplication } from '@/UIModels/Application'
import { AppState } from '@/UIModels/AppState'
import { formatSizeToReadableString } from '@standardnotes/filepicker'
import { SubscriptionSettingName } from '@standardnotes/snjs'
import { observer } from 'mobx-react-lite'
import { FunctionComponent } from 'preact'
import { useEffect, useState } from 'preact/hooks'
import { PreferencesGroup, PreferencesSegment, Subtitle, Title } from '../../PreferencesComponents'

type Props = {
application: WebApplication
appState: AppState
}

export const FilesSection: FunctionComponent<Props> = observer(({ application, appState }) => {
if (!application.getUser() || !appState.features.isEntitledToFiles) {
return null
}

export const FilesSection: FunctionComponent<Props> = ({ application }) => {
const [isLoading, setIsLoading] = useState(true)
const [filesQuotaUsed, setFilesQuotaUsed] = useState<number>(0)
const [filesQuotaTotal, setFilesQuotaTotal] = useState<number>(0)
Expand All @@ -41,7 +34,7 @@ export const FilesSection: FunctionComponent<Props> = observer(({ application, a
}

getFilesQuota().catch(console.error)
})
}, [application.settings])

return (
<PreferencesGroup>
Expand Down Expand Up @@ -69,4 +62,4 @@ export const FilesSection: FunctionComponent<Props> = observer(({ application, a
</PreferencesSegment>
</PreferencesGroup>
)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export const AccountPreferences = observer(({ application, appState }: Props) =>
</>
)}
<Subscription application={application} appState={appState} />
<FilesSection application={application} appState={appState} />
{application.hasAccount() && appState.features.isEntitledToFiles && (
<FilesSection application={application} />
)}
<SignOutWrapper application={application} appState={appState} />
</PreferencesPane>
))

0 comments on commit e7fb9b6

Please sign in to comment.