mirror of
https://github.com/tooot-app/app
synced 2025-02-18 12:50:46 +01:00
commit
9fd7cf489f
@ -192,8 +192,8 @@ private_lane :build_android do
|
||||
task: 'assemble',
|
||||
build_type: 'release',
|
||||
project_dir: "./android",
|
||||
print_command: false,
|
||||
print_command_output: false,
|
||||
print_command: true,
|
||||
print_command_output: true,
|
||||
properties: {
|
||||
"expoSDK" => VERSIONS[:expo],
|
||||
"releaseChannel" => RELEASE_CHANNEL,
|
||||
|
@ -1,5 +1,2 @@
|
||||
Support editing toot
|
||||
Integrated into system's share menu
|
||||
Follow system's font weight setting (iOS)
|
||||
Upload gif from keyboard (Android)
|
||||
Added German and Italian
|
||||
Support selecting multiple images
|
||||
Long press toot to show options
|
@ -1,5 +1,2 @@
|
||||
支持编辑嘟文
|
||||
支持系统图片分享
|
||||
跟随系统字体粗细(苹果)
|
||||
键盘上传gif图片(安卓)
|
||||
新增德语和意大利语
|
||||
支持同时上传多张图片
|
||||
长按嘟文弹出嘟文选项
|
32
src/components/RelativeTime.tsx
Normal file
32
src/components/RelativeTime.tsx
Normal file
@ -0,0 +1,32 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { FormattedRelativeTime } from 'react-intl'
|
||||
import { AppState } from 'react-native'
|
||||
|
||||
export interface Props {
|
||||
type: 'past' | 'future'
|
||||
time: string | number
|
||||
}
|
||||
|
||||
const RelativeTime: React.FC<Props> = ({ type, time }) => {
|
||||
const [now, setNow] = useState(new Date().getTime())
|
||||
useEffect(() => {
|
||||
const appStateListener = AppState.addEventListener('change', state => {
|
||||
setNow(new Date().getTime())
|
||||
})
|
||||
|
||||
return () => {
|
||||
appStateListener.remove()
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<FormattedRelativeTime
|
||||
value={
|
||||
((type === 'past' ? -1 : 1) * (now - new Date(time).getTime())) / 1000
|
||||
}
|
||||
updateIntervalInSeconds={1}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default RelativeTime
|
@ -1,10 +1,11 @@
|
||||
import Icon from '@components/Icon'
|
||||
import RelativeTime from '@components/RelativeTime'
|
||||
import CustomText from '@components/Text'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FormattedDate, FormattedRelativeTime } from 'react-intl'
|
||||
import { FormattedDate } from 'react-intl'
|
||||
|
||||
export interface Props {
|
||||
created_at: Mastodon.Status['created_at'] | number
|
||||
@ -31,12 +32,7 @@ const HeaderSharedCreated = React.memo(
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<FormattedRelativeTime
|
||||
value={
|
||||
-(new Date().getTime() - new Date(actualTime).getTime()) / 1000
|
||||
}
|
||||
updateIntervalInSeconds={1}
|
||||
/>
|
||||
<RelativeTime type='past' time={actualTime} />
|
||||
)}
|
||||
</CustomText>
|
||||
{edited_at ? (
|
||||
|
@ -4,6 +4,7 @@ import haptics from '@components/haptics'
|
||||
import Icon from '@components/Icon'
|
||||
import { displayMessage } from '@components/Message'
|
||||
import { ParseEmojis } from '@components/Parse'
|
||||
import RelativeTime from '@components/RelativeTime'
|
||||
import CustomText from '@components/Text'
|
||||
import {
|
||||
MutationVarsTimelineUpdateStatusProperty,
|
||||
@ -16,8 +17,7 @@ import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import { maxBy } from 'lodash'
|
||||
import React, { useCallback, useMemo, useState } from 'react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { FormattedRelativeTime } from 'react-intl'
|
||||
import { Pressable, StyleSheet, Text, View } from 'react-native'
|
||||
import { Pressable, View } from 'react-native'
|
||||
import { useQueryClient } from 'react-query'
|
||||
|
||||
export interface Props {
|
||||
@ -289,15 +289,7 @@ const TimelinePoll: React.FC<Props> = ({
|
||||
return (
|
||||
<Trans
|
||||
i18nKey='componentTimeline:shared.poll.meta.expiration.until'
|
||||
components={[
|
||||
<FormattedRelativeTime
|
||||
value={
|
||||
(new Date(poll.expires_at).getTime() - new Date().getTime()) /
|
||||
1000
|
||||
}
|
||||
updateIntervalInSeconds={1}
|
||||
/>
|
||||
]}
|
||||
components={[<RelativeTime type='future' time={poll.expires_at} />]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -26,9 +26,6 @@ const TimelineTranslate = React.memo(
|
||||
if (!highlighted) {
|
||||
return null
|
||||
}
|
||||
if (!status.language) {
|
||||
return null
|
||||
}
|
||||
|
||||
const { t } = useTranslation('componentTimeline')
|
||||
const { colors } = useTheme()
|
||||
@ -45,10 +42,6 @@ const TimelineTranslate = React.memo(
|
||||
|
||||
const [detectedLanguage, setDetectedLanguage] = useState<string>('')
|
||||
useEffect(() => {
|
||||
if (!status.language) {
|
||||
return
|
||||
}
|
||||
|
||||
const detect = async () => {
|
||||
const result = await detectLanguage(text.join(`\n`))
|
||||
setDetectedLanguage(result.detected.slice(0, 2))
|
||||
@ -65,14 +58,14 @@ const TimelineTranslate = React.memo(
|
||||
text,
|
||||
options: { enabled }
|
||||
})
|
||||
|
||||
console.log('detectedLanguage', detectedLanguage)
|
||||
if (!detectedLanguage) {
|
||||
return null
|
||||
}
|
||||
if (Localization.locale.includes(detectedLanguage)) {
|
||||
if (Localization.locale.slice(0, 2).includes(detectedLanguage)) {
|
||||
return null
|
||||
}
|
||||
if (settingsLanguage?.includes(detectedLanguage)) {
|
||||
if (settingsLanguage?.slice(0, 2).includes(detectedLanguage)) {
|
||||
return null
|
||||
}
|
||||
|
||||
@ -89,13 +82,13 @@ const TimelineTranslate = React.memo(
|
||||
if (enabled) {
|
||||
if (!isSuccess) {
|
||||
analytics('timeline_shared_translate_retry', {
|
||||
language: status.language
|
||||
language: detectedLanguage
|
||||
})
|
||||
refetch()
|
||||
}
|
||||
} else {
|
||||
analytics('timeline_shared_translate', {
|
||||
language: status.language
|
||||
language: detectedLanguage
|
||||
})
|
||||
setEnabled(true)
|
||||
}
|
||||
@ -125,7 +118,7 @@ const TimelineTranslate = React.memo(
|
||||
</CustomText>
|
||||
<CustomText>
|
||||
{__DEV__
|
||||
? ` Source: ${status.language}; Target: ${
|
||||
? ` Source: ${detectedLanguage}; Target: ${
|
||||
Localization.locale || settingsLanguage || 'en'
|
||||
}`
|
||||
: undefined}
|
||||
@ -153,7 +146,6 @@ const TimelineTranslate = React.memo(
|
||||
)
|
||||
},
|
||||
(prev, next) =>
|
||||
prev.status.language === next.status.language &&
|
||||
prev.status.content === next.status.content &&
|
||||
prev.status.spoiler_text === next.status.spoiler_text
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ import analytics from '@components/analytics'
|
||||
import Button from '@components/Button'
|
||||
import haptics from '@components/haptics'
|
||||
import { ParseHTML } from '@components/Parse'
|
||||
import RelativeTime from '@components/RelativeTime'
|
||||
import CustomText from '@components/Text'
|
||||
import { BlurView } from '@react-native-community/blur'
|
||||
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
|
||||
@ -92,15 +93,7 @@ const ScreenAnnouncements: React.FC<
|
||||
<Trans
|
||||
i18nKey='screenAnnouncements:content.published'
|
||||
components={[
|
||||
<FormattedRelativeTime
|
||||
value={
|
||||
-(
|
||||
new Date().getTime() -
|
||||
new Date(item.published_at).getTime()
|
||||
) / 1000
|
||||
}
|
||||
updateIntervalInSeconds={1}
|
||||
/>
|
||||
<RelativeTime type='past' time={item.published_at} />
|
||||
]}
|
||||
/>
|
||||
</CustomText>
|
||||
|
Loading…
x
Reference in New Issue
Block a user