fix: duplicate files quota calls in preferences (#1006)
This commit is contained in:
@@ -1,22 +1,15 @@
|
|||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
import { AppState } from '@/UIModels/AppState'
|
|
||||||
import { formatSizeToReadableString } from '@standardnotes/filepicker'
|
import { formatSizeToReadableString } from '@standardnotes/filepicker'
|
||||||
import { SubscriptionSettingName } from '@standardnotes/snjs'
|
import { SubscriptionSettingName } from '@standardnotes/snjs'
|
||||||
import { observer } from 'mobx-react-lite'
|
|
||||||
import { FunctionComponent } from 'preact'
|
import { FunctionComponent } from 'preact'
|
||||||
import { useEffect, useState } from 'preact/hooks'
|
import { useEffect, useState } from 'preact/hooks'
|
||||||
import { PreferencesGroup, PreferencesSegment, Subtitle, Title } from '../../PreferencesComponents'
|
import { PreferencesGroup, PreferencesSegment, Subtitle, Title } from '../../PreferencesComponents'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
appState: AppState
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FilesSection: FunctionComponent<Props> = observer(({ application, appState }) => {
|
export const FilesSection: FunctionComponent<Props> = ({ application }) => {
|
||||||
if (!application.getUser() || !appState.features.isEntitledToFiles) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
const [filesQuotaUsed, setFilesQuotaUsed] = useState<number>(0)
|
const [filesQuotaUsed, setFilesQuotaUsed] = useState<number>(0)
|
||||||
const [filesQuotaTotal, setFilesQuotaTotal] = useState<number>(0)
|
const [filesQuotaTotal, setFilesQuotaTotal] = useState<number>(0)
|
||||||
@@ -41,7 +34,7 @@ export const FilesSection: FunctionComponent<Props> = observer(({ application, a
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFilesQuota().catch(console.error)
|
getFilesQuota().catch(console.error)
|
||||||
})
|
}, [application.settings])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PreferencesGroup>
|
<PreferencesGroup>
|
||||||
@@ -69,4 +62,4 @@ export const FilesSection: FunctionComponent<Props> = observer(({ application, a
|
|||||||
</PreferencesSegment>
|
</PreferencesSegment>
|
||||||
</PreferencesGroup>
|
</PreferencesGroup>
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ export const AccountPreferences = observer(({ application, appState }: Props) =>
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Subscription application={application} appState={appState} />
|
<Subscription application={application} appState={appState} />
|
||||||
<FilesSection application={application} appState={appState} />
|
{application.hasAccount() && appState.features.isEntitledToFiles && (
|
||||||
|
<FilesSection application={application} />
|
||||||
|
)}
|
||||||
<SignOutWrapper application={application} appState={appState} />
|
<SignOutWrapper application={application} appState={appState} />
|
||||||
</PreferencesPane>
|
</PreferencesPane>
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user