diff --git a/src/components/Instance/index.tsx b/src/components/Instance/index.tsx index 05b79c2c..5aad3b7b 100644 --- a/src/components/Instance/index.tsx +++ b/src/components/Instance/index.tsx @@ -235,12 +235,7 @@ const ComponentInstance: React.FC = ({ /> ) : null} - + ) => { + const headerHeight = useHeaderHeight() + + return ( + + + + {children} + + + + ) + } +) diff --git a/src/components/Parse/HTML.tsx b/src/components/Parse/HTML.tsx index 17c0afa2..449fbc09 100644 --- a/src/components/Parse/HTML.tsx +++ b/src/components/Parse/HTML.tsx @@ -309,7 +309,11 @@ const ParseHTML: React.FC = ({ height: numberOfLines === 1 && !expanded ? 0 : undefined }} numberOfLines={ - typeof totalLines === 'number' ? (expanded ? 999 : numberOfLines) : MAX_ALLOWED_LINES + typeof totalLines === 'number' + ? expanded + ? 999 + : numberOfLines + : Math.max(MAX_ALLOWED_LINES, numberOfLines) } selectable={selectable} /> diff --git a/src/i18n/en/screens/tabs.json b/src/i18n/en/screens/tabs.json index e1b3130c..124aa8b4 100644 --- a/src/i18n/en/screens/tabs.json +++ b/src/i18n/en/screens/tabs.json @@ -210,7 +210,8 @@ "hide": "Hidden completely" }, "keywords": "Matches for these keywords", - "keyword": "Keyword" + "keyword": "Keyword", + "statuses": "Matches these toots" }, "profile": { "feedback": { diff --git a/src/screens/Compose/EditAttachment.tsx b/src/screens/Compose/EditAttachment.tsx index 8e6d4656..6e10574a 100644 --- a/src/screens/Compose/EditAttachment.tsx +++ b/src/screens/Compose/EditAttachment.tsx @@ -1,5 +1,6 @@ import haptics from '@components/haptics' import { HeaderLeft, HeaderRight } from '@components/Header' +import { ModalScrollView } from '@components/ModalScrollView' import CustomText from '@components/Text' import apiInstance from '@utils/api/instance' import { ScreenComposeStackScreenProps } from '@utils/navigation/navigators' @@ -7,8 +8,7 @@ import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useContext, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' -import { Alert, KeyboardAvoidingView, Platform, ScrollView, TextInput } from 'react-native' -import { SafeAreaView } from 'react-native-safe-area-context' +import { Alert, TextInput } from 'react-native' import ComposeContext from './utils/createContext' const ComposeEditAttachment: React.FC< @@ -34,9 +34,7 @@ const ComposeEditAttachment: React.FC< useEffect(() => { navigation.setOptions({ title: t('content.editAttachment.header.title'), - headerLeft: () => ( - navigation.goBack()} /> - ), + headerLeft: () => navigation.goBack()} />, headerRight: () => ( - - - - {t('content.editAttachment.content.altText.heading')} - - - composeDispatch({ - type: 'attachment/edit', - payload: { - ...theAttachment, - description: e - } - }) + + + {t('content.editAttachment.content.altText.heading')} + + + composeDispatch({ + type: 'attachment/edit', + payload: { + ...theAttachment, + description: e } - placeholder={t('content.editAttachment.content.altText.placeholder')} - placeholderTextColor={colors.secondary} - value={theAttachment.description} - /> - - {theAttachment.description?.length || 0} / 1500 - - - - + }) + } + placeholder={t('content.editAttachment.content.altText.placeholder')} + placeholderTextColor={colors.secondary} + value={theAttachment.description} + /> + + {theAttachment.description?.length || 0} / 1500 + + ) } diff --git a/src/screens/Tabs/Me/Preferences/Filter.tsx b/src/screens/Tabs/Me/Preferences/Filter.tsx index 7f3088ab..cf98bee7 100644 --- a/src/screens/Tabs/Me/Preferences/Filter.tsx +++ b/src/screens/Tabs/Me/Preferences/Filter.tsx @@ -4,22 +4,24 @@ import { HeaderLeft, HeaderRight } from '@components/Header' import Hr from '@components/Hr' import ComponentInput from '@components/Input' import { MenuRow } from '@components/Menu' +import { ModalScrollView } from '@components/ModalScrollView' import Selections from '@components/Selections' import CustomText from '@components/Text' import { useActionSheet } from '@expo/react-native-action-sheet' import apiInstance from '@utils/api/instance' import { androidActionSheetStyles } from '@utils/helpers/androidActionSheetStyles' +import browserPackage from '@utils/helpers/browserPackage' import { TabMePreferencesStackScreenProps } from '@utils/navigation/navigators' import { queryClient } from '@utils/queryHooks' import { QueryKeyFilters } from '@utils/queryHooks/filters' +import { getAccountStorage } from '@utils/storage/actions' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' -import React, { RefObject, useEffect, useState } from 'react' +import * as WebBrowser from 'expo-web-browser' +import React, { RefObject, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { KeyboardAvoidingView, Platform, View } from 'react-native' +import { ScrollView, View } from 'react-native' import FlashMessage from 'react-native-flash-message' -import { ScrollView } from 'react-native-gesture-handler' -import { SafeAreaView } from 'react-native-safe-area-context' const TabMePreferencesFilter: React.FC< TabMePreferencesStackScreenProps<'Tab-Me-Preferences-Filter'> & { @@ -101,7 +103,11 @@ const TabMePreferencesFilter: React.FC< ]) const [keywords, setKeywords] = useState( - params.type === 'edit' ? params.filter.keywords.map(({ keyword }) => keyword) : [] + params.type === 'edit' + ? params.filter.keywords.length + ? params.filter.keywords.map(({ keyword }) => keyword) + : [''] + : [''] ) useEffect(() => { @@ -152,6 +158,48 @@ const TabMePreferencesFilter: React.FC< }) break case 'edit': + isLoading = true + await apiInstance({ + method: 'put', + version: 'v2', + url: `filters/${params.filter.id}`, + body: { + title: titleState[0], + context: contexts + .filter(context => context.selected) + .map(context => context.type), + filter_action: actions.filter( + action => action.type === 'hide' && action.selected + ).length + ? 'hide' + : 'warn', + ...(parseInt(expiration) && { + expires_in: parseInt(expiration) + }), + ...(keywords.filter(keyword => keyword.length).length + ? { + keywords_attributes: keywords + .filter(keyword => keyword.length) + .map(keyword => ({ keyword, whole_word: true })) + } + : params.filter.keywords.length && { + keywords_attributes: params.filter.keywords.map(keyword => ({ + ...keyword, + _destroy: true + })) + }) + } + }) + .then(() => { + isLoading = false + const queryKey: QueryKeyFilters = ['Filters', { version: 'v2' }] + queryClient.refetchQueries(queryKey) + navigation.navigate('Tab-Me-Preferences-Filters') + }) + .catch(() => { + isLoading = false + haptics('Error') + }) break } }} @@ -160,105 +208,132 @@ const TabMePreferencesFilter: React.FC< }) }, [titleState[0], expiration, contexts, actions, keywords]) + const scrollViewRef = useRef(null) + return ( - - - - + + + + showActionSheetWithOptions( + { + title: t('screenTabs:me.preferencesFilter.expiration'), + options: [ + ...expirations.map(opt => + t(`screenTabs:me.preferencesFilter.expirationOptions.${opt}`) + ), + t('common:buttons.cancel') + ], + cancelButtonIndex: expirations.length, + ...androidActionSheetStyles(colors) + }, + (selectedIndex: number) => { + selectedIndex < expirations.length && setExpiration(expirations[selectedIndex]) + } + ) + } + /> +
+ + context.selected).length} + options={contexts} + setOptions={setContexts} + /> + +
+ + + + + + + {[...Array(keywords.length)].map((_, i) => ( + setKeywords(keywords.map((curr, ii) => (i === ii ? k : curr))) + ]} + /> + ))} + + +