mirror of https://github.com/tooot-app/app
Fix poll input
This commit is contained in:
parent
471f3f3391
commit
79a488c84a
|
@ -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>",
|
||||||
|
|
|
@ -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,10 +98,8 @@ 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'),
|
sortedEmojis.push({ title: key, data: chunk(value, 5) })
|
||||||
(value, key) =>
|
|
||||||
sortedEmojis.push({ title: key, data: chunk(value, 5) })
|
|
||||||
)
|
)
|
||||||
if (frequentEmojis.length) {
|
if (frequentEmojis.length) {
|
||||||
sortedEmojis.unshift({
|
sortedEmojis.unshift({
|
||||||
|
@ -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}
|
||||||
|
|
|
@ -43,20 +43,17 @@ export type ComposeState = {
|
||||||
emoji: {
|
emoji: {
|
||||||
active: boolean
|
active: boolean
|
||||||
emojis:
|
emojis:
|
||||||
| {
|
| {
|
||||||
title: string
|
title: string
|
||||||
data: Pick<Mastodon.Emoji, 'shortcode' | 'url' | 'static_url'>[][]
|
data: Pick<Mastodon.Emoji, 'shortcode' | 'url' | 'static_url'>[][]
|
||||||
}[]
|
}[]
|
||||||
| undefined
|
| undefined
|
||||||
}
|
}
|
||||||
poll: {
|
poll: {
|
||||||
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'
|
||||||
|
@ -76,69 +73,69 @@ export type ComposeState = {
|
||||||
|
|
||||||
export type ComposeAction =
|
export type ComposeAction =
|
||||||
| {
|
| {
|
||||||
type: 'loadDraft'
|
type: 'loadDraft'
|
||||||
payload: ComposeStateDraft
|
payload: ComposeStateDraft
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'dirty'
|
type: 'dirty'
|
||||||
payload: ComposeState['dirty']
|
payload: ComposeState['dirty']
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'posting'
|
type: 'posting'
|
||||||
payload: ComposeState['posting']
|
payload: ComposeState['posting']
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'spoiler'
|
type: 'spoiler'
|
||||||
payload: Partial<ComposeState['spoiler']>
|
payload: Partial<ComposeState['spoiler']>
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'text'
|
type: 'text'
|
||||||
payload: Partial<ComposeState['text']>
|
payload: Partial<ComposeState['text']>
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'tag'
|
type: 'tag'
|
||||||
payload: ComposeState['tag']
|
payload: ComposeState['tag']
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'emoji'
|
type: 'emoji'
|
||||||
payload: ComposeState['emoji']
|
payload: ComposeState['emoji']
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'poll'
|
type: 'poll'
|
||||||
payload: Partial<ComposeState['poll']>
|
payload: Partial<ComposeState['poll']>
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'attachments/sensitive'
|
type: 'attachments/sensitive'
|
||||||
payload: Pick<ComposeState['attachments'], 'sensitive'>
|
payload: Pick<ComposeState['attachments'], 'sensitive'>
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'attachment/upload/start'
|
type: 'attachment/upload/start'
|
||||||
payload: Pick<ExtendedAttachment, 'local' | 'uploading'>
|
payload: Pick<ExtendedAttachment, 'local' | 'uploading'>
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'attachment/upload/end'
|
type: 'attachment/upload/end'
|
||||||
payload: { remote: Mastodon.Attachment; local: Asset }
|
payload: { remote: Mastodon.Attachment; local: Asset }
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'attachment/upload/fail'
|
type: 'attachment/upload/fail'
|
||||||
payload: ExtendedAttachment['local']['hash']
|
payload: ExtendedAttachment['local']['hash']
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'attachment/delete'
|
type: 'attachment/delete'
|
||||||
payload: NonNullable<ExtendedAttachment['remote']>['id']
|
payload: NonNullable<ExtendedAttachment['remote']>['id']
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'attachment/edit'
|
type: 'attachment/edit'
|
||||||
payload: ExtendedAttachment['remote']
|
payload: ExtendedAttachment['remote']
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'visibility'
|
type: 'visibility'
|
||||||
payload: ComposeState['visibility']
|
payload: ComposeState['visibility']
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'textInputFocus'
|
type: 'textInputFocus'
|
||||||
payload: Partial<ComposeState['textInputFocus']>
|
payload: Partial<ComposeState['textInputFocus']>
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'removeReply'
|
type: 'removeReply'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue