Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: open and focus download limit preference on "Change limit" press
  • Loading branch information
amanharwara committed Apr 22, 2024
commit 1c5b2209b4c66b64d7843afbb3edb3f6f948b687
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ProtectedIllustration } from '@standardnotes/icons'
import { ImageZoomLevelProps } from './ImageZoomLevelProps'
import { useLocalPreference } from '../../Hooks/usePreference'
import { formatSizeToReadableString } from '@standardnotes/filepicker'
import { ElementIds } from '@/Constants/ElementIDs'

type Props = {
application: WebApplication
Expand Down Expand Up @@ -147,7 +148,35 @@ const FilePreview = ({ file, application, isEmbeddedInSuper = false, imageZoomLe
</Button>
<Button
onClick={() => {
/* open preferences */
const preferences = application.preferencesController
preferences.openPreferences('general')
setTimeout(() => {
const prefElement = document.getElementById(ElementIds.AutoDownloadLimitPreference)
if (prefElement) {
prefElement.scrollIntoView({
block: 'center',
})
prefElement.querySelector('button')?.focus()
setTimeout(() => {
prefElement.animate(
[
{
transform: 'scale(1)',
},
{
transform: 'scale(1.05)',
},
{
transform: 'scale(1)',
},
],
{
duration: 350,
},
)
}, 100)
}
}, 50)
}}
>
Change limit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action, makeAutoObservable, observable } from 'mobx'
import { action, autorun, makeAutoObservable, observable } from 'mobx'
import { WebApplication } from '@/Application/WebApplication'
import { PackageProvider } from '../Panes/Plugins/PackageProvider'
import { securityPrefsHasBubble } from '../Panes/Security/securityPrefsHasBubble'
Expand Down Expand Up @@ -59,6 +59,10 @@ export class PreferencesSessionController {
this.updateMenuBubbleCounts()
}
})

autorun(() => {
this.selectPane(application.preferencesController.currentPane)
})
}

private updateMenuBubbleCounts(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { WebApplication } from '../../../../Application/WebApplication'
import HorizontalSeparator from '../../../Shared/HorizontalSeparator'
import Dropdown from '../../../Dropdown/Dropdown'
import { useMemo } from 'react'
import { ElementIds } from '@/Constants/ElementIDs'

const SuperNotes = ({ application }: { application: WebApplication }) => {
const isMobile = useMediaQuery(MutuallyExclusiveMediaQueryBreakpoints.sm)
Expand Down Expand Up @@ -103,7 +104,7 @@ const SuperNotes = ({ application }: { application: WebApplication }) => {
/>
</div>
<HorizontalSeparator classes="my-4" />
<div>
<div id={ElementIds.AutoDownloadLimitPreference}>
<Subtitle>Auto-download limit for embedded files</Subtitle>
<Text>Only embedded files below the set limit be automatically downloaded</Text>
<div className="mt-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const PreferencesView: FunctionComponent<PreferencesProps> = ({ application, clo
[application],
)

useEffect(() => {
menu.selectPane(application.preferencesController.currentPane)
}, [menu, application.preferencesController.currentPane])

const isMobileScreen = useMediaQuery(MutuallyExclusiveMediaQueryBreakpoints.sm)

const addAndroidBackHandler = useAndroidBackHandler()
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/javascripts/Constants/ElementIDs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export const ElementIds = {
SearchBar: 'search-bar',
ConflictResolutionButton: 'conflict-resolution-button',
SuperEditor: 'super-editor',
AutoDownloadLimitPreference: 'auto-download-limit-pref',
} as const