refs #874 Post status with polls

This commit is contained in:
AkiraFukushima 2019-07-16 23:56:00 +09:00
parent d95ec64513
commit b887acc6f4
2 changed files with 18 additions and 5 deletions

View File

@ -224,7 +224,8 @@ export default {
async toot() { async toot() {
const form = { const form = {
status: this.status, status: this.status,
spoiler: this.spoiler spoiler: this.spoiler,
polls: this.polls
} }
try { try {

View File

@ -20,6 +20,12 @@ type MediaDescription = {
description: string description: string
} }
type TootForm = {
status: string
spoiler: string
polls: Array<string>
}
export type NewTootState = { export type NewTootState = {
modalOpen: boolean modalOpen: boolean
initialStatus: string initialStatus: string
@ -177,12 +183,12 @@ const actions: ActionTree<NewTootState, RootState> = {
throw err throw err
}) })
}, },
postToot: async ({ state, commit, rootState, dispatch }, { status, spoiler }): Promise<Status> => { postToot: async ({ state, commit, rootState, dispatch }, params: TootForm): Promise<Status> => {
if (!state.modalOpen) { if (!state.modalOpen) {
throw new NewTootModalOpen() throw new NewTootModalOpen()
} }
if (status.length < 1 || status.length > rootState.TimelineSpace.tootMax) { if (params.status.length < 1 || params.status.length > rootState.TimelineSpace.tootMax) {
throw new NewTootTootLength() throw new NewTootTootLength()
} }
@ -193,11 +199,17 @@ const actions: ActionTree<NewTootState, RootState> = {
if (visibilityKey !== undefined) { if (visibilityKey !== undefined) {
specifiedVisibility = Visibility[visibilityKey].key specifiedVisibility = Visibility[visibilityKey].key
} }
let form = { let form = {
status: status, status: params.status,
visibility: specifiedVisibility, visibility: specifiedVisibility,
sensitive: state.sensitive, sensitive: state.sensitive,
spoiler_text: spoiler spoiler_text: params.spoiler,
poll: {
expires_in: 86400,
multiple: false,
options: params.polls
}
} }
if (state.replyToMessage !== null) { if (state.replyToMessage !== null) {