Skip to content

Commit

Permalink
Merge branch 'main' into candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
xmflsct committed Jul 13, 2023
2 parents 3e7a026 + 09bc6c3 commit 3750236
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 50 deletions.
3 changes: 3 additions & 0 deletions fastlane/metadata/en-US/release_notes.txt
@@ -1 +1,4 @@
Enjoy toooting! This version includes following improvements and fixes:
- Supports mute duration
- Long press to copy toot
- Button to fetch latest on load
5 changes: 4 additions & 1 deletion fastlane/metadata/zh-Hans/release_notes.txt
@@ -1,2 +1,5 @@
tooot-ing愉快!此版本包括以下改进和修复:
- 新增neodb.social演出卡片
- 新增neodb.social演出卡片
- 支持选择隐藏用户时限
- 长按复制嘟文
- 新增获取最新嘟文按钮
4 changes: 3 additions & 1 deletion src/components/Header/Right.tsx
Expand Up @@ -17,6 +17,7 @@ export type Props = {
loading?: boolean
disabled?: boolean
destructive?: boolean
destructiveColor?: string

onPress: () => void
} & ({ type?: undefined; content: IconName } | { type: 'text'; content: string })
Expand All @@ -34,6 +35,7 @@ const HeaderRight: React.FC<Props> = ({
loading,
disabled,
destructive = false,
destructiveColor,
onPress
}) => {
const { colors } = useTheme()
Expand All @@ -57,7 +59,7 @@ const HeaderRight: React.FC<Props> = ({
color: disabled
? colors.secondary
: destructive
? colors.red
? destructiveColor || colors.red
: colors.primaryDefault,
opacity: loading ? 0 : 1
}}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Timeline/Shared/Content.tsx
Expand Up @@ -36,6 +36,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
adaptiveSize
numberOfLines={999}
color={suppressSpoiler ? colors.disabled : undefined}
selectable
/>
{inThread ? (
<CustomText
Expand All @@ -62,6 +63,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
}
expandHint={t('shared.content.expandHint')}
setSpoilerExpanded={setSpoilerExpanded}
selectable
/>
</>
) : (
Expand All @@ -70,6 +72,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
size={highlighted ? 'L' : 'M'}
adaptiveSize
numberOfLines={highlighted || inThread ? 999 : notificationOwnToot ? 2 : undefined}
selectable
/>
)}
</View>
Expand Down
150 changes: 110 additions & 40 deletions src/components/Timeline/index.tsx
@@ -1,3 +1,4 @@
import Icon from '@components/Icon'
import ComponentSeparator from '@components/Separator'
import CustomText from '@components/Text'
import TimelineDefault from '@components/Timeline/Default'
Expand All @@ -10,12 +11,20 @@ import {
setAccountStorage,
useGlobalStorageListener
} from '@utils/storage/actions'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import { StyleConstants } from '@utils/styles/constants'
import { throttle } from 'lodash'
import React, { RefObject, useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { FlatList, FlatListProps, Platform, RefreshControl } from 'react-native'
import {
FlatList,
FlatListProps,
Platform,
Pressable,
RefreshControl,
StyleProp,
ViewStyle
} from 'react-native'
import Animated, {
Easing,
runOnJS,
Expand Down Expand Up @@ -127,6 +136,20 @@ const Timeline: React.FC<Props> = ({
transform: [{ translateY: fetchedNoticeTop.value }]
}))

const refetchedNoticeAnimate = useAnimatedStyle(() => ({
transform: [
{
translateY: withSequence(
withTiming(0),
withDelay(
3000,
withTiming(fetchedNoticeHeight.value + 32, { easing: Easing.out(Easing.ease) })
)
)
}
]
}))

const scrollY = useSharedValue(0)
const fetchingType = useSharedValue<0 | 1 | 2>(0)

Expand Down Expand Up @@ -169,10 +192,9 @@ const Timeline: React.FC<Props> = ({
throttle(() => {
if (readMarker) {
const currentMarker = getAccountStorage.string(readMarker) || '0'
// setAccountStorage([{ key: readMarker, value: '108425743226508521' }])
if (latestMarker.current > currentMarker) {
setAccountStorage([{ key: readMarker, value: latestMarker.current }])
} else {
// setAccountStorage([{ key: readMarker, value: '105250709762254246' }])
}
}
}, 1000 * 15),
Expand Down Expand Up @@ -242,6 +264,18 @@ const Timeline: React.FC<Props> = ({
flRef.current?.scrollToOffset({ offset: 0, animated: false })
)

const noticeDefaults: StyleProp<Animated.AnimateStyle<StyleProp<ViewStyle>>> = {
position: 'absolute',
alignSelf: 'center',
borderRadius: 99,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: colors.backgroundDefault,
shadowColor: colors.primaryDefault,
shadowOffset: { width: 0, height: 0 },
shadowOpacity: theme === 'light' ? 0.16 : 0.24
}

return (
<>
<TimelineRefresh
Expand Down Expand Up @@ -286,42 +320,78 @@ const Timeline: React.FC<Props> = ({
{...customProps}
/>
{!disableRefresh ? (
<Animated.View
style={[
{
position: 'absolute',
alignSelf: 'center',
top: -fetchedNoticeHeight.value - 16,
paddingVertical: StyleConstants.Spacing.S,
paddingHorizontal: StyleConstants.Spacing.M,
backgroundColor: colors.backgroundDefault,
shadowColor: colors.primaryDefault,
shadowOffset: { width: 0, height: 0 },
shadowOpacity: theme === 'light' ? 0.16 : 0.24,
borderRadius: 99,
justifyContent: 'center',
alignItems: 'center'
},
fetchedNoticeAnimate
]}
onLayout={({
nativeEvent: {
layout: { height }
}
}) => (fetchedNoticeHeight.value = height)}
>
<CustomText
fontStyle='S'
style={{ color: colors.primaryDefault }}
children={
fetchedCount !== null
? fetchedCount > 0
? t('refresh.fetched.found', { count: fetchedCount })
: t('refresh.fetched.none')
: t('refresh.fetching')
}
/>
</Animated.View>
<>
<Animated.View
style={[
{
top: -fetchedNoticeHeight.value - 16,
paddingVertical: StyleConstants.Spacing.S,
paddingHorizontal: StyleConstants.Spacing.M,
...noticeDefaults
},
fetchedNoticeAnimate
]}
onLayout={({
nativeEvent: {
layout: { height }
}
}) => (fetchedNoticeHeight.value = height)}
>
<CustomText
fontStyle='S'
style={{ color: colors.primaryDefault }}
children={
fetchedCount !== null
? fetchedCount > 0
? t('refresh.fetched.found', { count: fetchedCount })
: t('refresh.fetched.none')
: t('refresh.fetching')
}
/>
</Animated.View>
{readMarker ? (
<Animated.View
style={[
{
bottom: 16,
borderColor: colors.primaryDefault,
borderWidth: 0.5,
...noticeDefaults
},
refetchedNoticeAnimate
]}
>
<Pressable
style={{
flexDirection: 'row',
alignItems: 'center',
gap: StyleConstants.Spacing.S,
paddingVertical: StyleConstants.Spacing.S,
paddingHorizontal: StyleConstants.Spacing.M
}}
onPress={async () => {
if (readMarker) {
setAccountStorage([{ key: readMarker, value: undefined }])
}
await refetch()
setTimeout(() => flRef.current?.scrollToOffset({ offset: 0 }), 50)
}}
>
<CustomText
fontStyle='M'
style={{ color: colors.primaryDefault }}
children={t('refresh.refetch')}
/>
<Icon
name='log-in'
color={colors.primaryDefault}
size={StyleConstants.Font.Size.M}
style={{ transform: [{ rotate: '-90deg' }] }}
/>
</Pressable>
</Animated.View>
) : null}
</>
) : null}
</>
)
Expand Down
23 changes: 16 additions & 7 deletions src/components/contextMenu/account.ts
Expand Up @@ -4,6 +4,7 @@ import { useNavigation } from '@react-navigation/native'
import { NativeStackNavigationProp } from '@react-navigation/native-stack'
import { useQueryClient } from '@tanstack/react-query'
import apiInstance from '@utils/api/instance'
import { featureCheck } from '@utils/helpers/featureCheck'
import { checkIsMyAccount } from '@utils/helpers/isMyAccount'
import { TabSharedStackParamList, useNavState } from '@utils/navigation/navigators'
import { useAccountQuery } from '@utils/queryHooks/account'
Expand Down Expand Up @@ -203,13 +204,21 @@ const menuAccount = ({
type: 'item',
key: 'account-mute',
props: {
onSelect: () =>
actualAccount &&
timelineMutation.mutate({
type: 'updateAccountProperty',
id: actualAccount.id,
payload: { property: 'mute', currentValue: data?.muting }
}),
onSelect: () => {
if (actualAccount) {
if (data?.muting !== true) {
if (featureCheck('mute_duration')) {
navigation.navigate('Tab-Shared-Mute', { account: actualAccount })
}
}

timelineMutation.mutate({
type: 'updateAccountProperty',
id: actualAccount.id,
payload: { property: 'mute', currentValue: data?.muting }
})
}
},
disabled: Platform.OS !== 'android' ? !data || !isFetched : false,
destructive: false,
hidden: false
Expand Down
14 changes: 14 additions & 0 deletions src/i18n/en/screens/tabs.json
Expand Up @@ -417,6 +417,20 @@
"history": {
"name": "Edit History"
},
"mute": {
"name": "Mute {{acct}}",
"mute": "Mute",
"description": "Hide posts from this user and posts mentioning them, but it will still allow them to see your posts and follow you.",
"notification": "Also hide notifications from this user",
"duration": {
"heading": "For duration",
"0": "Indefinitely",
"1800": "30 minutes",
"3600": "1 hour",
"86400": "1 day",
"604800": "1 week"
}
},
"report": {
"name": "Report {{acct}}",
"report": "Report",
Expand Down

0 comments on commit 3750236

Please sign in to comment.