tooot/src/screens/Compose/utils/types.d.ts

131 lines
2.8 KiB
TypeScript
Raw Normal View History

2022-09-23 00:21:41 +02:00
import { RefObject } from 'react';
2022-08-07 01:18:10 +02:00
import { Asset } from 'react-native-image-picker'
2022-06-05 17:58:18 +02:00
2020-12-30 00:56:25 +01:00
export type ExtendedAttachment = {
remote?: Mastodon.Attachment
2022-08-07 01:18:10 +02:00
local?: Asset & { thumbnail?: string; hash: string }
2020-12-30 00:56:25 +01:00
uploading?: boolean
}
2021-02-07 00:39:11 +01:00
export type ComposeStateDraft = {
timestamp: number
spoiler?: string
text?: string
poll?: ComposeState['poll']
attachments?: ComposeState['attachments']
visibility: ComposeState['visibility']
visibilityLock: ComposeState['visibilityLock']
replyToStatus?: ComposeState['replyToStatus']
}
2020-12-30 00:56:25 +01:00
export type ComposeState = {
2021-02-07 00:39:11 +01:00
dirty: boolean
timestamp: number
2021-01-14 22:53:01 +01:00
posting: boolean
2020-12-30 00:56:25 +01:00
spoiler: {
active: boolean
count: number
raw: string
formatted: ReactNode
selection: { start: number; end?: number }
2020-12-30 00:56:25 +01:00
}
text: {
count: number
raw: string
formatted: ReactNode
selection: { start: number; end?: number }
2020-12-30 00:56:25 +01:00
}
tag?: {
2022-09-20 22:23:01 +02:00
schema: '@' | '#' | ':' | string
index: number
lastIndex: number
raw: string
2020-12-30 00:56:25 +01:00
}
poll: {
active: boolean
total: number
options: {
2022-09-13 21:53:44 +02:00
[key: string]: string | undefined
2020-12-30 00:56:25 +01:00
}
multiple: boolean
2021-01-19 01:13:45 +01:00
expire: '300' | '1800' | '3600' | '21600' | '86400' | '259200' | '604800'
2020-12-30 00:56:25 +01:00
}
attachments: {
sensitive: boolean
uploads: ExtendedAttachment[]
}
visibility: 'public' | 'unlisted' | 'private' | 'direct'
visibilityLock: boolean
replyToStatus?: Mastodon.Status
textInputFocus: {
current: 'text' | 'spoiler'
2022-09-23 00:21:41 +02:00
refs: { text: RefObject<TextInput>, spoiler: RefObject<TextInput> }
2022-09-19 22:01:13 +02:00
isFocused: { text: MutableRefObject<boolean>, spoiler: MutableRefObject<boolean> }
2020-12-30 00:56:25 +01:00
}
}
export type ComposeAction =
2021-02-07 00:39:11 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'loadDraft'
payload: ComposeStateDraft
}
2021-02-07 00:39:11 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'dirty'
payload: ComposeState['dirty']
}
2021-01-14 22:53:01 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'posting'
payload: ComposeState['posting']
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'spoiler'
payload: Partial<ComposeState['spoiler']>
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'text'
payload: Partial<ComposeState['text']>
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'tag'
payload: ComposeState['tag']
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'poll'
payload: Partial<ComposeState['poll']>
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'attachments/sensitive'
payload: Pick<ComposeState['attachments'], 'sensitive'>
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'attachment/upload/start'
payload: Pick<ExtendedAttachment, 'local' | 'uploading'>
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'attachment/upload/end'
payload: { remote: Mastodon.Attachment; local: Asset }
}
2021-01-04 14:55:34 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'attachment/upload/fail'
payload: ExtendedAttachment['local']['hash']
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'attachment/delete'
payload: NonNullable<ExtendedAttachment['remote']>['id']
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'attachment/edit'
payload: ExtendedAttachment['remote']
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'visibility'
payload: ComposeState['visibility']
}
2020-12-30 00:56:25 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'textInputFocus'
payload: Partial<ComposeState['textInputFocus']>
}
2021-03-09 00:47:40 +01:00
| {
2022-09-13 21:53:44 +02:00
type: 'removeReply'
}