place self at top of edit list
This commit is contained in:
@@ -7,6 +7,7 @@ import {BottomSheetFlatListMethods} from '@discord/bottom-sheet'
|
|||||||
import {Trans} from '@lingui/macro'
|
import {Trans} from '@lingui/macro'
|
||||||
|
|
||||||
import {isWeb} from 'platform/detection'
|
import {isWeb} from 'platform/detection'
|
||||||
|
import {useSession} from 'state/session'
|
||||||
import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State'
|
import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State'
|
||||||
import {atoms as a, native, useTheme, web} from '#/alf'
|
import {atoms as a, native, useTheme, web} from '#/alf'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
@@ -30,11 +31,24 @@ export function WizardEditListDialog({
|
|||||||
state: WizardState
|
state: WizardState
|
||||||
dispatch: (action: WizardAction) => void
|
dispatch: (action: WizardAction) => void
|
||||||
}) {
|
}) {
|
||||||
|
const {currentAccount} = useSession()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|
||||||
const listRef = useRef<BottomSheetFlatListMethods>(null)
|
const listRef = useRef<BottomSheetFlatListMethods>(null)
|
||||||
const inputRef = useRef<RNTextInput>(null)
|
const inputRef = useRef<RNTextInput>(null)
|
||||||
|
|
||||||
|
const getData = () => {
|
||||||
|
if (state.currentStep === 'Feeds') return state.feeds
|
||||||
|
|
||||||
|
const myIndex = state.profiles.findIndex(p => p.did === currentAccount?.did)
|
||||||
|
|
||||||
|
return [
|
||||||
|
state.profiles[myIndex],
|
||||||
|
...state.profiles.slice(0, myIndex),
|
||||||
|
...state.profiles.slice(myIndex + 1),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
@@ -58,7 +72,7 @@ export function WizardEditListDialog({
|
|||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<Dialog.InnerFlatList
|
<Dialog.InnerFlatList
|
||||||
ref={listRef}
|
ref={listRef}
|
||||||
data={state.currentStep === 'Profiles' ? state.profiles : state.feeds}
|
data={getData()}
|
||||||
renderItem={renderItem}
|
renderItem={renderItem}
|
||||||
keyExtractor={keyExtractor}
|
keyExtractor={keyExtractor}
|
||||||
ListHeaderComponent={
|
ListHeaderComponent={
|
||||||
|
|||||||
Reference in New Issue
Block a user