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
|
@ -6,7 +6,6 @@ import {niceDate} from 'lib/strings/time'
|
|||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {TypographyVariant} from 'lib/ThemeContext'
|
||||
import {UserAvatar} from './UserAvatar'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
||||
import {sanitizeHandle} from 'lib/strings/handles'
|
||||
import {isAndroid} from 'platform/detection'
|
||||
|
@ -30,7 +29,7 @@ interface PostMetaOpts {
|
|||
style?: StyleProp<ViewStyle>
|
||||
}
|
||||
|
||||
export const PostMeta = observer(function PostMetaImpl(opts: PostMetaOpts) {
|
||||
export function PostMeta(opts: PostMetaOpts) {
|
||||
const pal = usePalette('default')
|
||||
const displayName = opts.author.displayName || opts.author.handle
|
||||
const handle = opts.author.handle
|
||||
|
@ -92,7 +91,7 @@ export const PostMeta = observer(function PostMetaImpl(opts: PostMetaOpts) {
|
|||
</TimeElapsed>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import React from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {
|
||||
StyleProp,
|
||||
StyleSheet,
|
||||
|
@ -18,7 +17,7 @@ import {useSetDrawerOpen} from '#/state/shell'
|
|||
|
||||
const BACK_HITSLOP = {left: 20, top: 20, right: 50, bottom: 20}
|
||||
|
||||
export const SimpleViewHeader = observer(function SimpleViewHeaderImpl({
|
||||
export function SimpleViewHeader({
|
||||
showBackButton = true,
|
||||
style,
|
||||
children,
|
||||
|
@ -76,7 +75,7 @@ export const SimpleViewHeader = observer(function SimpleViewHeaderImpl({
|
|||
{children}
|
||||
</Container>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
header: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import React from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {StyleSheet, TouchableOpacity, View} from 'react-native'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {useNavigation} from '@react-navigation/native'
|
||||
|
@ -15,7 +14,7 @@ import {useSetDrawerOpen} from '#/state/shell'
|
|||
|
||||
const BACK_HITSLOP = {left: 20, top: 20, right: 50, bottom: 20}
|
||||
|
||||
export const ViewHeader = observer(function ViewHeaderImpl({
|
||||
export function ViewHeader({
|
||||
title,
|
||||
canGoBack,
|
||||
showBackButton = true,
|
||||
|
@ -108,7 +107,7 @@ export const ViewHeader = observer(function ViewHeaderImpl({
|
|||
</Container>
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function DesktopWebHeader({
|
||||
title,
|
||||
|
@ -140,7 +139,7 @@ function DesktopWebHeader({
|
|||
)
|
||||
}
|
||||
|
||||
const Container = observer(function ContainerImpl({
|
||||
function Container({
|
||||
children,
|
||||
hideOnScroll,
|
||||
showBorder,
|
||||
|
@ -178,7 +177,7 @@ const Container = observer(function ContainerImpl({
|
|||
{children}
|
||||
</Animated.View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
header: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import React, {ComponentProps} from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {StyleSheet, TouchableWithoutFeedback} from 'react-native'
|
||||
import LinearGradient from 'react-native-linear-gradient'
|
||||
import {gradients} from 'lib/styles'
|
||||
|
@ -15,11 +14,7 @@ export interface FABProps
|
|||
icon: JSX.Element
|
||||
}
|
||||
|
||||
export const FABInner = observer(function FABInnerImpl({
|
||||
testID,
|
||||
icon,
|
||||
...props
|
||||
}: FABProps) {
|
||||
export function FABInner({testID, icon, ...props}: FABProps) {
|
||||
const insets = useSafeAreaInsets()
|
||||
const {isMobile, isTablet} = useWebMediaQueries()
|
||||
const {fabMinimalShellTransform} = useMinimalShellMode()
|
||||
|
@ -55,7 +50,7 @@ export const FABInner = observer(function FABInnerImpl({
|
|||
</Animated.View>
|
||||
</TouchableWithoutFeedback>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
sizeRegular: {
|
||||
|
|
|
@ -2,8 +2,8 @@ import React from 'react'
|
|||
import {StyleProp, StyleSheet, Pressable, View, ViewStyle} from 'react-native'
|
||||
import {Image} from 'expo-image'
|
||||
import {clamp} from 'lib/numbers'
|
||||
import {useStores} from 'state/index'
|
||||
import {Dimensions} from 'lib/media/types'
|
||||
import * as imageSizes from 'lib/media/image-sizes'
|
||||
|
||||
const MIN_ASPECT_RATIO = 0.33 // 1/3
|
||||
const MAX_ASPECT_RATIO = 5 // 5/1
|
||||
|
@ -29,9 +29,8 @@ export function AutoSizedImage({
|
|||
style,
|
||||
children = null,
|
||||
}: Props) {
|
||||
const store = useStores()
|
||||
const [dim, setDim] = React.useState<Dimensions | undefined>(
|
||||
dimensionsHint || store.imageSizes.get(uri),
|
||||
dimensionsHint || imageSizes.get(uri),
|
||||
)
|
||||
const [aspectRatio, setAspectRatio] = React.useState<number>(
|
||||
dim ? calc(dim) : 1,
|
||||
|
@ -41,14 +40,14 @@ export function AutoSizedImage({
|
|||
if (dim) {
|
||||
return
|
||||
}
|
||||
store.imageSizes.fetch(uri).then(newDim => {
|
||||
imageSizes.fetch(uri).then(newDim => {
|
||||
if (aborted) {
|
||||
return
|
||||
}
|
||||
setDim(newDim)
|
||||
setAspectRatio(calc(newDim))
|
||||
})
|
||||
}, [dim, setDim, setAspectRatio, store, uri])
|
||||
}, [dim, setDim, setAspectRatio, uri])
|
||||
|
||||
if (onPress || onLongPress || onPressIn) {
|
||||
return (
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import React from 'react'
|
||||
import {StyleSheet, TouchableOpacity, View} from 'react-native'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||
|
@ -12,7 +11,7 @@ const AnimatedTouchableOpacity =
|
|||
Animated.createAnimatedComponent(TouchableOpacity)
|
||||
import {isWeb} from 'platform/detection'
|
||||
|
||||
export const LoadLatestBtn = observer(function LoadLatestBtnImpl({
|
||||
export function LoadLatestBtn({
|
||||
onPress,
|
||||
label,
|
||||
showIndicator,
|
||||
|
@ -44,7 +43,7 @@ export const LoadLatestBtn = observer(function LoadLatestBtnImpl({
|
|||
{showIndicator && <View style={[styles.indicator, pal.borderDark]} />}
|
||||
</AnimatedTouchableOpacity>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
loadLatest: {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import React from 'react'
|
||||
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {ListCard} from 'view/com/lists/ListCard'
|
||||
import {AppBskyGraphDefs} from '@atproto/api'
|
||||
import {s} from 'lib/styles'
|
||||
|
||||
export const ListEmbed = observer(function ListEmbedImpl({
|
||||
export function ListEmbed({
|
||||
item,
|
||||
style,
|
||||
}: {
|
||||
|
@ -20,7 +19,7 @@ export const ListEmbed = observer(function ListEmbedImpl({
|
|||
<ListCard list={item} style={[style, styles.card]} />
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue