Remove deprecated models and mobx usage (react-query refactor) (#1934)
* Update login page to use service query * Update modal to use session instead of store * Move image sizes cache off store * Update settings to no longer use store * Update link-meta fetch to use agent instead of rootstore * Remove deprecated resolveName() * Delete deprecated link-metas cache * Delete deprecated posts cache * Delete all remaining mobx models, including the root store * Strip out unused mobx observer wrappers
This commit is contained in:
parent
e637798e05
commit
54faa7e176
81 changed files with 1084 additions and 1941 deletions
|
@ -1,6 +1,5 @@
|
|||
import React from 'react'
|
||||
import {Keyboard, StyleSheet} from 'react-native'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {Button} from 'view/com/util/forms/Button'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {ShieldExclamation} from 'lib/icons'
|
||||
|
@ -11,7 +10,7 @@ import {useLingui} from '@lingui/react'
|
|||
import {msg} from '@lingui/macro'
|
||||
import {useModalControls} from '#/state/modals'
|
||||
|
||||
export const LabelsBtn = observer(function LabelsBtn({
|
||||
export function LabelsBtn({
|
||||
labels,
|
||||
hasMedia,
|
||||
onChange,
|
||||
|
@ -49,7 +48,7 @@ export const LabelsBtn = observer(function LabelsBtn({
|
|||
) : null}
|
||||
</Button>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import React, {useCallback, useMemo} from 'react'
|
||||
import {StyleSheet, Keyboard} from 'react-native'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {
|
||||
FontAwesomeIcon,
|
||||
FontAwesomeIconStyle,
|
||||
|
@ -24,7 +23,7 @@ import {
|
|||
import {t, msg} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
|
||||
export const SelectLangBtn = observer(function SelectLangBtn() {
|
||||
export function SelectLangBtn() {
|
||||
const pal = usePalette('default')
|
||||
const {_} = useLingui()
|
||||
const {openModal} = useModalControls()
|
||||
|
@ -117,7 +116,7 @@ export const SelectLangBtn = observer(function SelectLangBtn() {
|
|||
)}
|
||||
</DropdownButton>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import React, {useEffect, useRef} from 'react'
|
||||
import {Animated, TouchableOpacity, StyleSheet, View} from 'react-native'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {useAnimatedValue} from 'lib/hooks/useAnimatedValue'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {Text} from 'view/com/util/text/Text'
|
||||
|
@ -10,7 +9,7 @@ import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete'
|
|||
import {Trans} from '@lingui/macro'
|
||||
import {AppBskyActorDefs} from '@atproto/api'
|
||||
|
||||
export const Autocomplete = observer(function AutocompleteImpl({
|
||||
export function Autocomplete({
|
||||
prefix,
|
||||
onSelect,
|
||||
}: {
|
||||
|
@ -103,7 +102,7 @@ export const Autocomplete = observer(function AutocompleteImpl({
|
|||
) : null}
|
||||
</Animated.View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {useState, useEffect} from 'react'
|
||||
import {useStores} from 'state/index'
|
||||
import {ImageModel} from 'state/models/media/image'
|
||||
import * as apilib from 'lib/api/index'
|
||||
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
||||
|
@ -17,6 +16,7 @@ import {
|
|||
import {ComposerOpts} from 'state/shell/composer'
|
||||
import {POST_IMG_MAX} from 'lib/constants'
|
||||
import {logger} from '#/logger'
|
||||
import {useSession} from '#/state/session'
|
||||
import {useGetPost} from '#/state/queries/post'
|
||||
|
||||
export function useExternalLinkFetch({
|
||||
|
@ -24,7 +24,7 @@ export function useExternalLinkFetch({
|
|||
}: {
|
||||
setQuote: (opts: ComposerOpts['quote']) => void
|
||||
}) {
|
||||
const store = useStores()
|
||||
const {agent} = useSession()
|
||||
const [extLink, setExtLink] = useState<apilib.ExternalEmbedDraft | undefined>(
|
||||
undefined,
|
||||
)
|
||||
|
@ -56,7 +56,7 @@ export function useExternalLinkFetch({
|
|||
},
|
||||
)
|
||||
} else if (isBskyCustomFeedUrl(extLink.uri)) {
|
||||
getFeedAsEmbed(store, extLink.uri).then(
|
||||
getFeedAsEmbed(agent, extLink.uri).then(
|
||||
({embed, meta}) => {
|
||||
if (aborted) {
|
||||
return
|
||||
|
@ -74,7 +74,7 @@ export function useExternalLinkFetch({
|
|||
},
|
||||
)
|
||||
} else if (isBskyListUrl(extLink.uri)) {
|
||||
getListAsEmbed(store, extLink.uri).then(
|
||||
getListAsEmbed(agent, extLink.uri).then(
|
||||
({embed, meta}) => {
|
||||
if (aborted) {
|
||||
return
|
||||
|
@ -92,7 +92,7 @@ export function useExternalLinkFetch({
|
|||
},
|
||||
)
|
||||
} else {
|
||||
getLinkMeta(store, extLink.uri).then(meta => {
|
||||
getLinkMeta(agent, extLink.uri).then(meta => {
|
||||
if (aborted) {
|
||||
return
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ export function useExternalLinkFetch({
|
|||
})
|
||||
}
|
||||
return cleanup
|
||||
}, [store, extLink, setQuote, getPost])
|
||||
}, [agent, extLink, setQuote, getPost])
|
||||
|
||||
return {extLink, setExtLink}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue