1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Fix poll input

This commit is contained in:
xmflsct
2022-09-13 21:53:44 +02:00
parent 471f3f3391
commit 79a488c84a
3 changed files with 74 additions and 85 deletions

View File

@ -3,7 +3,7 @@
"versions": { "versions": {
"major": 4, "major": 4,
"minor": 3, "minor": 3,
"patch": 0 "patch": 1
}, },
"description": "tooot app for Mastodon", "description": "tooot app for Mastodon",
"author": "xmflsct <me@xmflsct.com>", "author": "xmflsct <me@xmflsct.com>",

View File

@ -5,13 +5,7 @@ import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import { chunk, forEach, groupBy, sortBy } from 'lodash' import { chunk, forEach, groupBy, sortBy } from 'lodash'
import React, { useContext, useEffect, useMemo, useRef } from 'react' import React, { useContext, useEffect, useMemo, useRef } from 'react'
import { import { AccessibilityInfo, findNodeHandle, FlatList, StyleSheet, View } from 'react-native'
AccessibilityInfo,
findNodeHandle,
FlatList,
StyleSheet,
View
} from 'react-native'
import { Circle } from 'react-native-animated-spinkit' import { Circle } from 'react-native-animated-spinkit'
import ComposeActions from './Root/Actions' import ComposeActions from './Root/Actions'
import ComposePosting from './Posting' import ComposePosting from './Posting'
@ -79,8 +73,7 @@ const ComposeRoot = React.memo(
const { isFetching, data, refetch } = useSearchQuery({ const { isFetching, data, refetch } = useSearchQuery({
type: type:
composeState.tag?.type === 'accounts' || composeState.tag?.type === 'accounts' || composeState.tag?.type === 'hashtags'
composeState.tag?.type === 'hashtags'
? composeState.tag.type ? composeState.tag.type
: undefined, : undefined,
term: composeState.tag?.text.substring(1), term: composeState.tag?.text.substring(1),
@ -89,8 +82,7 @@ const ComposeRoot = React.memo(
useEffect(() => { useEffect(() => {
if ( if (
(composeState.tag?.type === 'accounts' || (composeState.tag?.type === 'accounts' || composeState.tag?.type === 'hashtags') &&
composeState.tag?.type === 'hashtags') &&
composeState.tag?.text composeState.tag?.text
) { ) {
refetch() refetch()
@ -106,9 +98,7 @@ const ComposeRoot = React.memo(
title: string title: string
data: Pick<Mastodon.Emoji, 'shortcode' | 'url' | 'static_url'>[][] data: Pick<Mastodon.Emoji, 'shortcode' | 'url' | 'static_url'>[][]
}[] = [] }[] = []
forEach( forEach(groupBy(sortBy(emojisData, ['category', 'shortcode']), 'category'), (value, key) =>
groupBy(sortBy(emojisData, ['category', 'shortcode']), 'category'),
(value, key) =>
sortedEmojis.push({ title: key, data: chunk(value, 5) }) sortedEmojis.push({ title: key, data: chunk(value, 5) })
) )
if (frequentEmojis.length) { if (frequentEmojis.length) {
@ -132,15 +122,22 @@ const ComposeRoot = React.memo(
if (isFetching) { if (isFetching) {
return ( return (
<View key='listEmpty' style={styles.loading}> <View key='listEmpty' style={styles.loading}>
<Circle <Circle size={StyleConstants.Font.Size.M * 1.25} color={colors.secondary} />
size={StyleConstants.Font.Size.M * 1.25}
color={colors.secondary}
/>
</View> </View>
) )
} }
}, [isFetching]) }, [isFetching])
const Footer = useMemo(
() => (
<ComposeRootFooter
accessibleRefAttachments={accessibleRefAttachments}
accessibleRefEmojis={accessibleRefEmojis}
/>
),
[accessibleRefAttachments.current, accessibleRefEmojis.current]
)
return ( return (
<View style={styles.base}> <View style={styles.base}>
<FlatList <FlatList
@ -154,12 +151,7 @@ const ComposeRoot = React.memo(
ListEmptyComponent={listEmpty} ListEmptyComponent={listEmpty}
keyboardShouldPersistTaps='always' keyboardShouldPersistTaps='always'
ListHeaderComponent={ComposeRootHeader} ListHeaderComponent={ComposeRootHeader}
ListFooterComponent={() => ( ListFooterComponent={Footer}
<ComposeRootFooter
accessibleRefAttachments={accessibleRefAttachments}
accessibleRefEmojis={accessibleRefEmojis}
/>
)}
ItemSeparatorComponent={ComponentSeparator} ItemSeparatorComponent={ComponentSeparator}
// @ts-ignore // @ts-ignore
data={data ? data[composeState.tag?.type] : undefined} data={data ? data[composeState.tag?.type] : undefined}

View File

@ -53,10 +53,7 @@ export type ComposeState = {
active: boolean active: boolean
total: number total: number
options: { options: {
'0': string | undefined [key: string]: string | undefined
'1': string | undefined
'2': string | undefined
'3': string | undefined
} }
multiple: boolean multiple: boolean
expire: '300' | '1800' | '3600' | '21600' | '86400' | '259200' | '604800' expire: '300' | '1800' | '3600' | '21600' | '86400' | '259200' | '604800'