mirror of
https://github.com/tooot-app/app
synced 2025-03-13 01:50:08 +01:00
Editing can update media
This commit is contained in:
parent
d4f91a5756
commit
f93d6f7db8
@ -1,6 +1,6 @@
|
|||||||
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
|
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useCallback, useMemo, useState } from 'react'
|
import React, { useMemo, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
AccessibilityProps,
|
AccessibilityProps,
|
||||||
Image,
|
Image,
|
||||||
@ -39,8 +39,7 @@ export interface Props {
|
|||||||
>
|
>
|
||||||
}
|
}
|
||||||
|
|
||||||
const GracefullyImage = React.memo(
|
const GracefullyImage = ({
|
||||||
({
|
|
||||||
accessibilityLabel,
|
accessibilityLabel,
|
||||||
accessibilityHint,
|
accessibilityHint,
|
||||||
hidden = false,
|
hidden = false,
|
||||||
@ -57,56 +56,26 @@ const GracefullyImage = React.memo(
|
|||||||
const [originalFailed, setOriginalFailed] = useState(false)
|
const [originalFailed, setOriginalFailed] = useState(false)
|
||||||
const [imageLoaded, setImageLoaded] = useState(false)
|
const [imageLoaded, setImageLoaded] = useState(false)
|
||||||
|
|
||||||
const source = useMemo(() => {
|
const source = originalFailed
|
||||||
if (originalFailed) {
|
? { uri: uri.remote || undefined }
|
||||||
return { uri: uri.remote || undefined }
|
: {
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
|
uri: reduceMotionEnabled && uri.static ? uri.static : uri.original
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [originalFailed])
|
|
||||||
|
|
||||||
const onLoad = useCallback(() => {
|
const onLoad = () => {
|
||||||
setImageLoaded(true)
|
setImageLoaded(true)
|
||||||
if (setImageDimensions && source.uri) {
|
if (setImageDimensions && source.uri) {
|
||||||
Image.getSize(source.uri, (width, height) =>
|
Image.getSize(source.uri, (width, height) =>
|
||||||
setImageDimensions({ width, height })
|
setImageDimensions({ width, height })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}, [source.uri])
|
}
|
||||||
const onError = useCallback(() => {
|
const onError = () => {
|
||||||
if (!originalFailed) {
|
if (!originalFailed) {
|
||||||
setOriginalFailed(true)
|
setOriginalFailed(true)
|
||||||
}
|
}
|
||||||
}, [originalFailed])
|
}
|
||||||
|
|
||||||
const previewView = useMemo(
|
|
||||||
() =>
|
|
||||||
uri.preview && !imageLoaded ? (
|
|
||||||
<Image
|
|
||||||
fadeDuration={0}
|
|
||||||
source={{ uri: uri.preview }}
|
|
||||||
style={[
|
|
||||||
styles.placeholder,
|
|
||||||
{ backgroundColor: colors.shimmerDefault }
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
) : null,
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
const originalView = useMemo(
|
|
||||||
() => (
|
|
||||||
<Image
|
|
||||||
fadeDuration={0}
|
|
||||||
source={source}
|
|
||||||
style={[{ flex: 1 }, imageStyle]}
|
|
||||||
onLoad={onLoad}
|
|
||||||
onError={onError}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
[source]
|
|
||||||
)
|
|
||||||
const blurhashView = useMemo(() => {
|
const blurhashView = useMemo(() => {
|
||||||
if (hidden || !imageLoaded) {
|
if (hidden || !imageLoaded) {
|
||||||
if (blurhash) {
|
if (blurhash) {
|
||||||
@ -146,18 +115,27 @@ const GracefullyImage = React.memo(
|
|||||||
: { onPress }
|
: { onPress }
|
||||||
: { disabled: true })}
|
: { disabled: true })}
|
||||||
>
|
>
|
||||||
{previewView}
|
{uri.preview && !imageLoaded ? (
|
||||||
{originalView}
|
<Image
|
||||||
|
fadeDuration={0}
|
||||||
|
source={{ uri: uri.preview }}
|
||||||
|
style={[
|
||||||
|
styles.placeholder,
|
||||||
|
{ backgroundColor: colors.shimmerDefault }
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
<Image
|
||||||
|
fadeDuration={0}
|
||||||
|
source={source}
|
||||||
|
style={[{ flex: 1 }, imageStyle]}
|
||||||
|
onLoad={onLoad}
|
||||||
|
onError={onError}
|
||||||
|
/>
|
||||||
{blurhashView}
|
{blurhashView}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
(prev, next) =>
|
|
||||||
prev.hidden === next.hidden &&
|
|
||||||
prev.uri.preview === next.uri.preview &&
|
|
||||||
prev.uri.original === next.uri.original &&
|
|
||||||
prev.uri.remote === next.uri.remote
|
|
||||||
)
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
placeholder: {
|
placeholder: {
|
||||||
|
@ -10,10 +10,9 @@ import { StackNavigationProp } from '@react-navigation/stack'
|
|||||||
import { RootStackParamList } from '@utils/navigation/navigators'
|
import { RootStackParamList } from '@utils/navigation/navigators'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import layoutAnimation from '@utils/styles/layoutAnimation'
|
import layoutAnimation from '@utils/styles/layoutAnimation'
|
||||||
import React, { useCallback, useMemo, useRef, useState } from 'react'
|
import React, { useRef, useState } from 'react'
|
||||||
import { useEffect } from 'react'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Pressable, StyleSheet, View } from 'react-native'
|
import { Pressable, View } from 'react-native'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
status: Pick<Mastodon.Status, 'media_attachments' | 'sensitive'>
|
status: Pick<Mastodon.Status, 'media_attachments' | 'sensitive'>
|
||||||
@ -24,24 +23,13 @@ const TimelineAttachment = React.memo(
|
|||||||
const { t } = useTranslation('componentTimeline')
|
const { t } = useTranslation('componentTimeline')
|
||||||
|
|
||||||
const [sensitiveShown, setSensitiveShown] = useState(status.sensitive)
|
const [sensitiveShown, setSensitiveShown] = useState(status.sensitive)
|
||||||
const onPressBlurView = useCallback(() => {
|
|
||||||
analytics('timeline_shared_attachment_blurview_press_show')
|
|
||||||
layoutAnimation()
|
|
||||||
setSensitiveShown(false)
|
|
||||||
haptics('Light')
|
|
||||||
}, [])
|
|
||||||
const onPressShow = useCallback(() => {
|
|
||||||
analytics('timeline_shared_attachment_blurview_press_hide')
|
|
||||||
setSensitiveShown(true)
|
|
||||||
haptics('Light')
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const imageUrls = useRef<
|
const imageUrls = useRef<
|
||||||
RootStackParamList['Screen-ImagesViewer']['imageUrls']
|
RootStackParamList['Screen-ImagesViewer']['imageUrls']
|
||||||
>([])
|
>([])
|
||||||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
||||||
useEffect(() => {
|
const navigateToImagesViewer = (id: string) => {
|
||||||
status.media_attachments.forEach((attachment, index) => {
|
status.media_attachments.forEach(attachment => {
|
||||||
switch (attachment.type) {
|
switch (attachment.type) {
|
||||||
case 'image':
|
case 'image':
|
||||||
imageUrls.current.push({
|
imageUrls.current.push({
|
||||||
@ -55,15 +43,25 @@ const TimelineAttachment = React.memo(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [])
|
|
||||||
const navigateToImagesViewer = (id: string) =>
|
|
||||||
navigation.navigate('Screen-ImagesViewer', {
|
navigation.navigate('Screen-ImagesViewer', {
|
||||||
imageUrls: imageUrls.current,
|
imageUrls: imageUrls.current,
|
||||||
id
|
id
|
||||||
})
|
})
|
||||||
const attachments = useMemo(
|
}
|
||||||
() =>
|
|
||||||
status.media_attachments.map((attachment, index) => {
|
return (
|
||||||
|
<View>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
marginTop: StyleConstants.Spacing.S,
|
||||||
|
flex: 1,
|
||||||
|
flexDirection: 'row',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignContent: 'stretch'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{status.media_attachments.map((attachment, index) => {
|
||||||
switch (attachment.type) {
|
switch (attachment.type) {
|
||||||
case 'image':
|
case 'image':
|
||||||
return (
|
return (
|
||||||
@ -150,22 +148,31 @@ const TimelineAttachment = React.memo(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
})}
|
||||||
[sensitiveShown]
|
</View>
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<View style={styles.container} children={attachments} />
|
|
||||||
|
|
||||||
{status.sensitive &&
|
{status.sensitive &&
|
||||||
(sensitiveShown ? (
|
(sensitiveShown ? (
|
||||||
<Pressable style={styles.sensitiveBlur}>
|
<Pressable
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center'
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
type='text'
|
type='text'
|
||||||
content={t('shared.attachment.sensitive.button')}
|
content={t('shared.attachment.sensitive.button')}
|
||||||
overlay
|
overlay
|
||||||
onPress={onPressBlurView}
|
onPress={() => {
|
||||||
|
analytics('timeline_shared_attachment_blurview_press_show')
|
||||||
|
layoutAnimation()
|
||||||
|
setSensitiveShown(false)
|
||||||
|
haptics('Light')
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
) : (
|
) : (
|
||||||
@ -174,7 +181,11 @@ const TimelineAttachment = React.memo(
|
|||||||
content='EyeOff'
|
content='EyeOff'
|
||||||
round
|
round
|
||||||
overlay
|
overlay
|
||||||
onPress={onPressShow}
|
onPress={() => {
|
||||||
|
analytics('timeline_shared_attachment_blurview_press_hide')
|
||||||
|
setSensitiveShown(true)
|
||||||
|
haptics('Light')
|
||||||
|
}}
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: StyleConstants.Spacing.S * 2,
|
top: StyleConstants.Spacing.S * 2,
|
||||||
@ -185,33 +196,28 @@ const TimelineAttachment = React.memo(
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
() => true
|
(prev, next) => {
|
||||||
)
|
let isEqual = true
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
if (
|
||||||
container: {
|
prev.status.media_attachments.length !==
|
||||||
marginTop: StyleConstants.Spacing.S,
|
next.status.media_attachments.length
|
||||||
flex: 1,
|
) {
|
||||||
flexDirection: 'row',
|
isEqual = false
|
||||||
flexWrap: 'wrap',
|
return isEqual
|
||||||
justifyContent: 'center',
|
}
|
||||||
alignContent: 'stretch'
|
|
||||||
},
|
prev.status.media_attachments.forEach((attachment, index) => {
|
||||||
sensitiveBlur: {
|
if (
|
||||||
position: 'absolute',
|
attachment.preview_url !==
|
||||||
width: '100%',
|
next.status.media_attachments[index].preview_url
|
||||||
height: '100%',
|
) {
|
||||||
flex: 1,
|
isEqual = false
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center'
|
|
||||||
},
|
|
||||||
sensitiveBlurButton: {
|
|
||||||
padding: StyleConstants.Spacing.S,
|
|
||||||
borderRadius: 6
|
|
||||||
},
|
|
||||||
sensitiveText: {
|
|
||||||
...StyleConstants.FontStyle.M
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return isEqual
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
export default TimelineAttachment
|
export default TimelineAttachment
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import analytics from '@components/analytics'
|
import analytics from '@components/analytics'
|
||||||
import GracefullyImage from '@components/GracefullyImage'
|
import GracefullyImage from '@components/GracefullyImage'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import React, { useCallback } from 'react'
|
import React from 'react'
|
||||||
import { StyleSheet, View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import attachmentAspectRatio from './aspectRatio'
|
import attachmentAspectRatio from './aspectRatio'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
@ -13,21 +13,30 @@ export interface Props {
|
|||||||
navigateToImagesViewer: (imageIndex: string) => void
|
navigateToImagesViewer: (imageIndex: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const AttachmentImage = React.memo(
|
const AttachmentImage = ({
|
||||||
({ total, index, sensitiveShown, image, navigateToImagesViewer }: Props) => {
|
total,
|
||||||
const onPress = useCallback(() => {
|
index,
|
||||||
analytics('timeline_shared_attachment_image_press', { id: image.id })
|
sensitiveShown,
|
||||||
navigateToImagesViewer(image.id)
|
image,
|
||||||
}, [])
|
navigateToImagesViewer
|
||||||
|
}: Props) => {
|
||||||
return (
|
return (
|
||||||
<View style={styles.base}>
|
<View
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
flexBasis: '50%',
|
||||||
|
padding: StyleConstants.Spacing.XS / 2
|
||||||
|
}}
|
||||||
|
>
|
||||||
<GracefullyImage
|
<GracefullyImage
|
||||||
accessibilityLabel={image.description}
|
accessibilityLabel={image.description}
|
||||||
hidden={sensitiveShown}
|
hidden={sensitiveShown}
|
||||||
uri={{ original: image.preview_url, remote: image.remote_url }}
|
uri={{ original: image.preview_url, remote: image.remote_url }}
|
||||||
blurhash={image.blurhash}
|
blurhash={image.blurhash}
|
||||||
onPress={onPress}
|
onPress={() => {
|
||||||
|
analytics('timeline_shared_attachment_image_press', { id: image.id })
|
||||||
|
navigateToImagesViewer(image.id)
|
||||||
|
}}
|
||||||
style={{
|
style={{
|
||||||
aspectRatio:
|
aspectRatio:
|
||||||
total > 1 ||
|
total > 1 ||
|
||||||
@ -41,16 +50,6 @@ const AttachmentImage = React.memo(
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
},
|
|
||||||
(prev, next) => prev.sensitiveShown === next.sensitiveShown
|
|
||||||
)
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
base: {
|
|
||||||
flex: 1,
|
|
||||||
flexBasis: '50%',
|
|
||||||
padding: StyleConstants.Spacing.XS / 2
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
export default AttachmentImage
|
export default AttachmentImage
|
||||||
|
@ -10,20 +10,19 @@ import { StyleConstants } from '@utils/styles/constants'
|
|||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useCallback, useMemo } from 'react'
|
import React, { useCallback, useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Pressable, StyleSheet, Text, View } from 'react-native'
|
import { Pressable, Text, View } from 'react-native'
|
||||||
import { useQueryClient } from 'react-query'
|
import { useQueryClient } from 'react-query'
|
||||||
import HeaderSharedCreated from './HeaderShared/Created'
|
import HeaderSharedCreated from './HeaderShared/Created'
|
||||||
import HeaderSharedMuted from './HeaderShared/Muted'
|
import HeaderSharedMuted from './HeaderShared/Muted'
|
||||||
|
|
||||||
const Names = React.memo(
|
const Names = ({ accounts }: { accounts: Mastodon.Account[] }) => {
|
||||||
({ accounts }: { accounts: Mastodon.Account[] }) => {
|
|
||||||
const { t } = useTranslation('componentTimeline')
|
const { t } = useTranslation('componentTimeline')
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
style={[styles.namesLeading, { color: colors.secondary }]}
|
style={{ ...StyleConstants.FontStyle.M, color: colors.secondary }}
|
||||||
>
|
>
|
||||||
<Text>{t('shared.header.conversation.withAccounts')}</Text>
|
<Text>{t('shared.header.conversation.withAccounts')}</Text>
|
||||||
{accounts.map((account, index) => (
|
{accounts.map((account, index) => (
|
||||||
@ -38,17 +37,14 @@ const Names = React.memo(
|
|||||||
))}
|
))}
|
||||||
</Text>
|
</Text>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
() => true
|
|
||||||
)
|
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
queryKey: QueryKeyTimeline
|
queryKey: QueryKeyTimeline
|
||||||
conversation: Mastodon.Conversation
|
conversation: Mastodon.Conversation
|
||||||
}
|
}
|
||||||
|
|
||||||
const HeaderConversation = React.memo(
|
const HeaderConversation = ({ queryKey, conversation }: Props) => {
|
||||||
({ queryKey, conversation }: Props) => {
|
|
||||||
const { colors, theme } = useTheme()
|
const { colors, theme } = useTheme()
|
||||||
const { t } = useTranslation('componentTimeline')
|
const { t } = useTranslation('componentTimeline')
|
||||||
|
|
||||||
@ -96,10 +92,17 @@ const HeaderConversation = React.memo(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.base}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<View style={styles.nameAndMeta}>
|
<View style={{ flex: 3 }}>
|
||||||
<Names accounts={conversation.accounts} />
|
<Names accounts={conversation.accounts} />
|
||||||
<View style={styles.meta}>
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginTop: StyleConstants.Spacing.XS,
|
||||||
|
marginBottom: StyleConstants.Spacing.S
|
||||||
|
}}
|
||||||
|
>
|
||||||
{conversation.last_status?.created_at ? (
|
{conversation.last_status?.created_at ? (
|
||||||
<HeaderSharedCreated
|
<HeaderSharedCreated
|
||||||
created_at={conversation.last_status?.created_at}
|
created_at={conversation.last_status?.created_at}
|
||||||
@ -111,41 +114,12 @@ const HeaderConversation = React.memo(
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Pressable
|
<Pressable
|
||||||
style={styles.action}
|
style={{ flex: 1, flexDirection: 'row', justifyContent: 'center' }}
|
||||||
onPress={actionOnPress}
|
onPress={actionOnPress}
|
||||||
children={actionChildren}
|
children={actionChildren}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
},
|
|
||||||
() => true
|
|
||||||
)
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
base: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: 'row'
|
|
||||||
},
|
|
||||||
nameAndMeta: {
|
|
||||||
flex: 3
|
|
||||||
},
|
|
||||||
meta: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
marginTop: StyleConstants.Spacing.XS,
|
|
||||||
marginBottom: StyleConstants.Spacing.S
|
|
||||||
},
|
|
||||||
created_at: {
|
|
||||||
...StyleConstants.FontStyle.S
|
|
||||||
},
|
|
||||||
action: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'center'
|
|
||||||
},
|
|
||||||
namesLeading: {
|
|
||||||
...StyleConstants.FontStyle.M
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
export default HeaderConversation
|
export default HeaderConversation
|
||||||
|
@ -7,7 +7,7 @@ import { StyleConstants } from '@utils/styles/constants'
|
|||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Pressable, StyleSheet, View } from 'react-native'
|
import { Pressable, View } from 'react-native'
|
||||||
import HeaderSharedAccount from './HeaderShared/Account'
|
import HeaderSharedAccount from './HeaderShared/Account'
|
||||||
import HeaderSharedApplication from './HeaderShared/Application'
|
import HeaderSharedApplication from './HeaderShared/Application'
|
||||||
import HeaderSharedCreated from './HeaderShared/Created'
|
import HeaderSharedCreated from './HeaderShared/Created'
|
||||||
@ -20,17 +20,23 @@ export interface Props {
|
|||||||
status: Mastodon.Status
|
status: Mastodon.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
const TimelineHeaderDefault = React.memo(
|
const TimelineHeaderDefault = ({ queryKey, rootQueryKey, status }: Props) => {
|
||||||
({ queryKey, rootQueryKey, status }: Props) => {
|
|
||||||
const { t } = useTranslation('componentTimeline')
|
const { t } = useTranslation('componentTimeline')
|
||||||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.base}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<View style={styles.accountAndMeta}>
|
<View style={{ flex: 5 }}>
|
||||||
<HeaderSharedAccount account={status.account} />
|
<HeaderSharedAccount account={status.account} />
|
||||||
<View style={styles.meta}>
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginTop: StyleConstants.Spacing.XS,
|
||||||
|
marginBottom: StyleConstants.Spacing.S
|
||||||
|
}}
|
||||||
|
>
|
||||||
<HeaderSharedCreated
|
<HeaderSharedCreated
|
||||||
created_at={status.created_at}
|
created_at={status.created_at}
|
||||||
edited_at={status.edited_at}
|
edited_at={status.edited_at}
|
||||||
@ -44,7 +50,12 @@ const TimelineHeaderDefault = React.memo(
|
|||||||
{queryKey ? (
|
{queryKey ? (
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityHint={t('shared.header.actions.accessibilityHint')}
|
accessibilityHint={t('shared.header.actions.accessibilityHint')}
|
||||||
style={styles.action}
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'center',
|
||||||
|
paddingBottom: StyleConstants.Spacing.S
|
||||||
|
}}
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
navigation.navigate('Screen-Actions', {
|
navigation.navigate('Screen-Actions', {
|
||||||
queryKey,
|
queryKey,
|
||||||
@ -64,33 +75,6 @@ const TimelineHeaderDefault = React.memo(
|
|||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
},
|
|
||||||
() => true
|
|
||||||
)
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
base: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: 'row'
|
|
||||||
},
|
|
||||||
accountAndMeta: {
|
|
||||||
flex: 5
|
|
||||||
},
|
|
||||||
meta: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
marginTop: StyleConstants.Spacing.XS,
|
|
||||||
marginBottom: StyleConstants.Spacing.S
|
|
||||||
},
|
|
||||||
created_at: {
|
|
||||||
...StyleConstants.FontStyle.S
|
|
||||||
},
|
|
||||||
action: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'center',
|
|
||||||
paddingBottom: StyleConstants.Spacing.S
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
export default TimelineHeaderDefault
|
export default TimelineHeaderDefault
|
||||||
|
@ -10,7 +10,7 @@ import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
|||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
import React, { useMemo } from 'react'
|
import React, { useMemo } from 'react'
|
||||||
import { Pressable, StyleSheet, View } from 'react-native'
|
import { Pressable, View } from 'react-native'
|
||||||
import HeaderSharedAccount from './HeaderShared/Account'
|
import HeaderSharedAccount from './HeaderShared/Account'
|
||||||
import HeaderSharedApplication from './HeaderShared/Application'
|
import HeaderSharedApplication from './HeaderShared/Application'
|
||||||
import HeaderSharedCreated from './HeaderShared/Created'
|
import HeaderSharedCreated from './HeaderShared/Created'
|
||||||
@ -22,8 +22,7 @@ export interface Props {
|
|||||||
notification: Mastodon.Notification
|
notification: Mastodon.Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
const TimelineHeaderNotification = React.memo(
|
const TimelineHeaderNotification = ({ queryKey, notification }: Props) => {
|
||||||
({ queryKey, notification }: Props) => {
|
|
||||||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
|
|
||||||
@ -64,7 +63,7 @@ const TimelineHeaderNotification = React.memo(
|
|||||||
}, [notification.type])
|
}, [notification.type])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.base}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
flex:
|
flex:
|
||||||
@ -83,7 +82,14 @@ const TimelineHeaderNotification = React.memo(
|
|||||||
{...((notification.type === 'follow' ||
|
{...((notification.type === 'follow' ||
|
||||||
notification.type === 'follow_request') && { withoutName: true })}
|
notification.type === 'follow_request') && { withoutName: true })}
|
||||||
/>
|
/>
|
||||||
<View style={styles.meta}>
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginTop: StyleConstants.Spacing.XS,
|
||||||
|
marginBottom: StyleConstants.Spacing.S
|
||||||
|
}}
|
||||||
|
>
|
||||||
<HeaderSharedCreated
|
<HeaderSharedCreated
|
||||||
created_at={notification.created_at}
|
created_at={notification.created_at}
|
||||||
edited_at={notification.status?.edited_at}
|
edited_at={notification.status?.edited_at}
|
||||||
@ -102,7 +108,7 @@ const TimelineHeaderNotification = React.memo(
|
|||||||
|
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
styles.relationship,
|
{ marginLeft: StyleConstants.Spacing.M },
|
||||||
notification.type === 'follow' ||
|
notification.type === 'follow' ||
|
||||||
notification.type === 'follow_request'
|
notification.type === 'follow_request'
|
||||||
? { flexShrink: 1 }
|
? { flexShrink: 1 }
|
||||||
@ -113,24 +119,6 @@ const TimelineHeaderNotification = React.memo(
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
},
|
|
||||||
() => true
|
|
||||||
)
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
base: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: 'row'
|
|
||||||
},
|
|
||||||
meta: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
alignItems: 'center',
|
|
||||||
marginTop: StyleConstants.Spacing.XS,
|
|
||||||
marginBottom: StyleConstants.Spacing.S
|
|
||||||
},
|
|
||||||
relationship: {
|
|
||||||
marginLeft: StyleConstants.Spacing.M
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
export default TimelineHeaderNotification
|
export default TimelineHeaderNotification
|
||||||
|
@ -35,8 +35,7 @@ import ActionsNotificationsFilter from './Actions/NotificationsFilter'
|
|||||||
import ActionsShare from './Actions/Share'
|
import ActionsShare from './Actions/Share'
|
||||||
import ActionsStatus from './Actions/Status'
|
import ActionsStatus from './Actions/Status'
|
||||||
|
|
||||||
const ScreenActions = React.memo(
|
const ScreenActions = ({
|
||||||
({
|
|
||||||
route: { params },
|
route: { params },
|
||||||
navigation
|
navigation
|
||||||
}: RootStackScreenProps<'Screen-Actions'>) => {
|
}: RootStackScreenProps<'Screen-Actions'>) => {
|
||||||
@ -49,6 +48,7 @@ const ScreenActions = React.memo(
|
|||||||
let sameAccount = false
|
let sameAccount = false
|
||||||
switch (params.type) {
|
switch (params.type) {
|
||||||
case 'status':
|
case 'status':
|
||||||
|
console.log('media length', params.status.media_attachments.length)
|
||||||
sameAccount = instanceAccount?.id === params.status.account.id
|
sameAccount = instanceAccount?.id === params.status.account.id
|
||||||
break
|
break
|
||||||
case 'account':
|
case 'account':
|
||||||
@ -103,7 +103,7 @@ const ScreenActions = React.memo(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const actions = useMemo(() => {
|
const actions = () => {
|
||||||
switch (params.type) {
|
switch (params.type) {
|
||||||
case 'status':
|
case 'status':
|
||||||
return (
|
return (
|
||||||
@ -174,7 +174,7 @@ const ScreenActions = React.memo(
|
|||||||
case 'notifications_filter':
|
case 'notifications_filter':
|
||||||
return <ActionsNotificationsFilter />
|
return <ActionsNotificationsFilter />
|
||||||
}
|
}
|
||||||
}, [])
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaProvider>
|
<SafeAreaProvider>
|
||||||
@ -209,7 +209,7 @@ const ScreenActions = React.memo(
|
|||||||
{ backgroundColor: colors.primaryOverlay }
|
{ backgroundColor: colors.primaryOverlay }
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
{actions}
|
{actions()}
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
</PanGestureHandler>
|
</PanGestureHandler>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
@ -217,9 +217,7 @@ const ScreenActions = React.memo(
|
|||||||
</Animated.View>
|
</Animated.View>
|
||||||
</SafeAreaProvider>
|
</SafeAreaProvider>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
() => true
|
|
||||||
)
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
overlay: {
|
overlay: {
|
||||||
|
@ -305,7 +305,6 @@ const ScreenCompose: React.FC<RootStackScreenProps<'Screen-Compose'>> = ({
|
|||||||
|
|
||||||
switch (params?.type) {
|
switch (params?.type) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
console.log('firing mutation')
|
|
||||||
mutateTimeline.mutate({
|
mutateTimeline.mutate({
|
||||||
type: 'editItem',
|
type: 'editItem',
|
||||||
queryKey: params.queryKey,
|
queryKey: params.queryKey,
|
||||||
|
@ -7,15 +7,12 @@ const editItem = ({
|
|||||||
rootQueryKey,
|
rootQueryKey,
|
||||||
status
|
status
|
||||||
}: MutationVarsTimelineEditItem) => {
|
}: MutationVarsTimelineEditItem) => {
|
||||||
console.log('START')
|
|
||||||
queryKey &&
|
queryKey &&
|
||||||
queryClient.setQueryData<InfiniteData<any> | undefined>(queryKey, old => {
|
queryClient.setQueryData<InfiniteData<any> | undefined>(queryKey, old => {
|
||||||
if (old) {
|
if (old) {
|
||||||
old.pages = old.pages.map(page => {
|
old.pages = old.pages.map(page => {
|
||||||
page.body = page.body.map((item: Mastodon.Status) => {
|
page.body = page.body.map((item: Mastodon.Status) => {
|
||||||
if (item.id === status.id) {
|
if (item.id === status.id) {
|
||||||
console.log('found queryKey', queryKey)
|
|
||||||
console.log('new content', status.content)
|
|
||||||
item = status
|
item = status
|
||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
@ -34,8 +31,6 @@ const editItem = ({
|
|||||||
old.pages = old.pages.map(page => {
|
old.pages = old.pages.map(page => {
|
||||||
page.body = page.body.map((item: Mastodon.Status) => {
|
page.body = page.body.map((item: Mastodon.Status) => {
|
||||||
if (item.id === status.id) {
|
if (item.id === status.id) {
|
||||||
console.log('found rootQueryKey', queryKey)
|
|
||||||
console.log('new content', status.content)
|
|
||||||
item = status
|
item = status
|
||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
@ -46,7 +41,6 @@ const editItem = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
console.log('EDN')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default editItem
|
export default editItem
|
||||||
|
Loading…
x
Reference in New Issue
Block a user