123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750 |
- import axios from 'axios';
- import { throttle } from 'lodash';
- import { defineMessages } from 'react-intl';
- import api from 'mastodon/api';
- import { search as emojiSearch } from 'mastodon/features/emoji/emoji_mart_search_light';
- import { tagHistory } from 'mastodon/settings';
- import resizeImage from 'mastodon/utils/resize_image';
- import { showAlert, showAlertForError } from './alerts';
- import { useEmoji } from './emojis';
- import { importFetchedAccounts, importFetchedStatus } from './importer';
- import { openModal } from './modal';
- import { updateTimeline } from './timelines';
- /** @type {AbortController | undefined} */
- let fetchComposeSuggestionsAccountsController;
- /** @type {AbortController | undefined} */
- let fetchComposeSuggestionsTagsController;
- export const COMPOSE_CHANGE = 'COMPOSE_CHANGE';
- export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST';
- export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS';
- export const COMPOSE_SUBMIT_FAIL = 'COMPOSE_SUBMIT_FAIL';
- export const COMPOSE_REPLY = 'COMPOSE_REPLY';
- export const COMPOSE_REPLY_CANCEL = 'COMPOSE_REPLY_CANCEL';
- export const COMPOSE_DIRECT = 'COMPOSE_DIRECT';
- export const COMPOSE_MENTION = 'COMPOSE_MENTION';
- export const COMPOSE_RESET = 'COMPOSE_RESET';
- export const COMPOSE_UPLOAD_REQUEST = 'COMPOSE_UPLOAD_REQUEST';
- export const COMPOSE_UPLOAD_SUCCESS = 'COMPOSE_UPLOAD_SUCCESS';
- export const COMPOSE_UPLOAD_FAIL = 'COMPOSE_UPLOAD_FAIL';
- export const COMPOSE_UPLOAD_PROGRESS = 'COMPOSE_UPLOAD_PROGRESS';
- export const COMPOSE_UPLOAD_PROCESSING = 'COMPOSE_UPLOAD_PROCESSING';
- export const COMPOSE_UPLOAD_UNDO = 'COMPOSE_UPLOAD_UNDO';
- export const THUMBNAIL_UPLOAD_REQUEST = 'THUMBNAIL_UPLOAD_REQUEST';
- export const THUMBNAIL_UPLOAD_SUCCESS = 'THUMBNAIL_UPLOAD_SUCCESS';
- export const THUMBNAIL_UPLOAD_FAIL = 'THUMBNAIL_UPLOAD_FAIL';
- export const THUMBNAIL_UPLOAD_PROGRESS = 'THUMBNAIL_UPLOAD_PROGRESS';
- export const COMPOSE_SUGGESTIONS_CLEAR = 'COMPOSE_SUGGESTIONS_CLEAR';
- export const COMPOSE_SUGGESTIONS_READY = 'COMPOSE_SUGGESTIONS_READY';
- export const COMPOSE_SUGGESTION_SELECT = 'COMPOSE_SUGGESTION_SELECT';
- export const COMPOSE_SUGGESTION_IGNORE = 'COMPOSE_SUGGESTION_IGNORE';
- export const COMPOSE_SUGGESTION_TAGS_UPDATE = 'COMPOSE_SUGGESTION_TAGS_UPDATE';
- export const COMPOSE_TAG_HISTORY_UPDATE = 'COMPOSE_TAG_HISTORY_UPDATE';
- export const COMPOSE_MOUNT = 'COMPOSE_MOUNT';
- export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT';
- export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE';
- export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
- export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
- export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE';
- export const COMPOSE_COMPOSING_CHANGE = 'COMPOSE_COMPOSING_CHANGE';
- export const COMPOSE_LANGUAGE_CHANGE = 'COMPOSE_LANGUAGE_CHANGE';
- export const COMPOSE_EMOJI_INSERT = 'COMPOSE_EMOJI_INSERT';
- export const COMPOSE_UPLOAD_CHANGE_REQUEST = 'COMPOSE_UPLOAD_UPDATE_REQUEST';
- export const COMPOSE_UPLOAD_CHANGE_SUCCESS = 'COMPOSE_UPLOAD_UPDATE_SUCCESS';
- export const COMPOSE_UPLOAD_CHANGE_FAIL = 'COMPOSE_UPLOAD_UPDATE_FAIL';
- export const COMPOSE_POLL_ADD = 'COMPOSE_POLL_ADD';
- export const COMPOSE_POLL_REMOVE = 'COMPOSE_POLL_REMOVE';
- export const COMPOSE_POLL_OPTION_ADD = 'COMPOSE_POLL_OPTION_ADD';
- export const COMPOSE_POLL_OPTION_CHANGE = 'COMPOSE_POLL_OPTION_CHANGE';
- export const COMPOSE_POLL_OPTION_REMOVE = 'COMPOSE_POLL_OPTION_REMOVE';
- export const COMPOSE_POLL_SETTINGS_CHANGE = 'COMPOSE_POLL_SETTINGS_CHANGE';
- export const INIT_MEDIA_EDIT_MODAL = 'INIT_MEDIA_EDIT_MODAL';
- export const COMPOSE_CHANGE_MEDIA_DESCRIPTION = 'COMPOSE_CHANGE_MEDIA_DESCRIPTION';
- export const COMPOSE_CHANGE_MEDIA_FOCUS = 'COMPOSE_CHANGE_MEDIA_FOCUS';
- export const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS';
- const messages = defineMessages({
- uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' },
- uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' },
- });
- export const ensureComposeIsVisible = (getState, routerHistory) => {
- if (!getState().getIn(['compose', 'mounted'])) {
- routerHistory.push('/publish');
- }
- };
- export function setComposeToStatus(status, text, spoiler_text) {
- return{
- type: COMPOSE_SET_STATUS,
- status,
- text,
- spoiler_text,
- };
- };
- export function changeCompose(text) {
- return {
- type: COMPOSE_CHANGE,
- text: text,
- };
- };
- export function replyCompose(status, routerHistory) {
- return (dispatch, getState) => {
- dispatch({
- type: COMPOSE_REPLY,
- status: status,
- });
- ensureComposeIsVisible(getState, routerHistory);
- };
- };
- export function cancelReplyCompose() {
- return {
- type: COMPOSE_REPLY_CANCEL,
- };
- };
- export function resetCompose() {
- return {
- type: COMPOSE_RESET,
- };
- };
- export function mentionCompose(account, routerHistory) {
- return (dispatch, getState) => {
- dispatch({
- type: COMPOSE_MENTION,
- account: account,
- });
- ensureComposeIsVisible(getState, routerHistory);
- };
- };
- export function directCompose(account, routerHistory) {
- return (dispatch, getState) => {
- dispatch({
- type: COMPOSE_DIRECT,
- account: account,
- });
- ensureComposeIsVisible(getState, routerHistory);
- };
- };
- export function submitCompose(routerHistory) {
- return function (dispatch, getState) {
- const status = getState().getIn(['compose', 'text'], '');
- const media = getState().getIn(['compose', 'media_attachments']);
- const statusId = getState().getIn(['compose', 'id'], null);
- if ((!status || !status.length) && media.size === 0) {
- return;
- }
- dispatch(submitComposeRequest());
- api(getState).request({
- url: statusId === null ? '/api/v1/statuses' : `/api/v1/statuses/${statusId}`,
- method: statusId === null ? 'post' : 'put',
- data: {
- status,
- in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null),
- media_ids: media.map(item => item.get('id')),
- sensitive: getState().getIn(['compose', 'sensitive']),
- spoiler_text: getState().getIn(['compose', 'spoiler']) ? getState().getIn(['compose', 'spoiler_text'], '') : '',
- visibility: getState().getIn(['compose', 'privacy']),
- poll: getState().getIn(['compose', 'poll'], null),
- language: getState().getIn(['compose', 'language']),
- },
- headers: {
- 'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']),
- },
- }).then(function (response) {
- if (routerHistory && (routerHistory.location.pathname === '/publish' || routerHistory.location.pathname === '/statuses/new') && window.history.state) {
- routerHistory.goBack();
- }
- dispatch(insertIntoTagHistory(response.data.tags, status));
- dispatch(submitComposeSuccess({ ...response.data }));
- // To make the app more responsive, immediately push the status
- // into the columns
- const insertIfOnline = timelineId => {
- const timeline = getState().getIn(['timelines', timelineId]);
- if (timeline && timeline.get('items').size > 0 && timeline.getIn(['items', 0]) !== null && timeline.get('online')) {
- dispatch(updateTimeline(timelineId, { ...response.data }));
- }
- };
- if (statusId) {
- dispatch(importFetchedStatus({ ...response.data }));
- }
- if (statusId === null && response.data.visibility !== 'direct') {
- insertIfOnline('home');
- }
- if (statusId === null && response.data.in_reply_to_id === null && response.data.visibility === 'public') {
- insertIfOnline('community');
- insertIfOnline('public');
- insertIfOnline(`account:${response.data.account.id}`);
- }
- }).catch(function (error) {
- dispatch(submitComposeFail(error));
- });
- };
- };
- export function submitComposeRequest() {
- return {
- type: COMPOSE_SUBMIT_REQUEST,
- };
- };
- export function submitComposeSuccess(status) {
- return {
- type: COMPOSE_SUBMIT_SUCCESS,
- status: status,
- };
- };
- export function submitComposeFail(error) {
- return {
- type: COMPOSE_SUBMIT_FAIL,
- error: error,
- };
- };
- export function uploadCompose(files) {
- return function (dispatch, getState) {
- const uploadLimit = 4;
- const media = getState().getIn(['compose', 'media_attachments']);
- const pending = getState().getIn(['compose', 'pending_media_attachments']);
- const progress = new Array(files.length).fill(0);
- let total = Array.from(files).reduce((a, v) => a + v.size, 0);
- if (files.length + media.size + pending > uploadLimit) {
- dispatch(showAlert(undefined, messages.uploadErrorLimit));
- return;
- }
- if (getState().getIn(['compose', 'poll'])) {
- dispatch(showAlert(undefined, messages.uploadErrorPoll));
- return;
- }
- dispatch(uploadComposeRequest());
- for (const [i, f] of Array.from(files).entries()) {
- if (media.size + i > 3) break;
- resizeImage(f).then(file => {
- const data = new FormData();
- data.append('file', file);
- // Account for disparity in size of original image and resized data
- total += file.size - f.size;
- return api(getState).post('/api/v2/media', data, {
- onUploadProgress: function({ loaded }){
- progress[i] = loaded;
- dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total));
- },
- }).then(({ status, data }) => {
- // If server-side processing of the media attachment has not completed yet,
- // poll the server until it is, before showing the media attachment as uploaded
- if (status === 200) {
- dispatch(uploadComposeSuccess(data, f));
- } else if (status === 202) {
- dispatch(uploadComposeProcessing());
- let tryCount = 1;
- const poll = () => {
- api(getState).get(`/api/v1/media/${data.id}`).then(response => {
- if (response.status === 200) {
- dispatch(uploadComposeSuccess(response.data, f));
- } else if (response.status === 206) {
- const retryAfter = (Math.log2(tryCount) || 1) * 1000;
- tryCount += 1;
- setTimeout(() => poll(), retryAfter);
- }
- }).catch(error => dispatch(uploadComposeFail(error)));
- };
- poll();
- }
- });
- }).catch(error => dispatch(uploadComposeFail(error)));
- };
- };
- };
- export const uploadComposeProcessing = () => ({
- type: COMPOSE_UPLOAD_PROCESSING,
- });
- export const uploadThumbnail = (id, file) => (dispatch, getState) => {
- dispatch(uploadThumbnailRequest());
- const total = file.size;
- const data = new FormData();
- data.append('thumbnail', file);
- api(getState).put(`/api/v1/media/${id}`, data, {
- onUploadProgress: ({ loaded }) => {
- dispatch(uploadThumbnailProgress(loaded, total));
- },
- }).then(({ data }) => {
- dispatch(uploadThumbnailSuccess(data));
- }).catch(error => {
- dispatch(uploadThumbnailFail(id, error));
- });
- };
- export const uploadThumbnailRequest = () => ({
- type: THUMBNAIL_UPLOAD_REQUEST,
- skipLoading: true,
- });
- export const uploadThumbnailProgress = (loaded, total) => ({
- type: THUMBNAIL_UPLOAD_PROGRESS,
- loaded,
- total,
- skipLoading: true,
- });
- export const uploadThumbnailSuccess = media => ({
- type: THUMBNAIL_UPLOAD_SUCCESS,
- media,
- skipLoading: true,
- });
- export const uploadThumbnailFail = error => ({
- type: THUMBNAIL_UPLOAD_FAIL,
- error,
- skipLoading: true,
- });
- export function initMediaEditModal(id) {
- return dispatch => {
- dispatch({
- type: INIT_MEDIA_EDIT_MODAL,
- id,
- });
- dispatch(openModal('FOCAL_POINT', { id }));
- };
- };
- export function onChangeMediaDescription(description) {
- return {
- type: COMPOSE_CHANGE_MEDIA_DESCRIPTION,
- description,
- };
- };
- export function onChangeMediaFocus(focusX, focusY) {
- return {
- type: COMPOSE_CHANGE_MEDIA_FOCUS,
- focusX,
- focusY,
- };
- };
- export function changeUploadCompose(id, params) {
- return (dispatch, getState) => {
- dispatch(changeUploadComposeRequest());
- api(getState).put(`/api/v1/media/${id}`, params).then(response => {
- dispatch(changeUploadComposeSuccess(response.data));
- }).catch(error => {
- dispatch(changeUploadComposeFail(id, error));
- });
- };
- };
- export function changeUploadComposeRequest() {
- return {
- type: COMPOSE_UPLOAD_CHANGE_REQUEST,
- skipLoading: true,
- };
- };
- export function changeUploadComposeSuccess(media) {
- return {
- type: COMPOSE_UPLOAD_CHANGE_SUCCESS,
- media: media,
- skipLoading: true,
- };
- };
- export function changeUploadComposeFail(error) {
- return {
- type: COMPOSE_UPLOAD_CHANGE_FAIL,
- error: error,
- skipLoading: true,
- };
- };
- export function uploadComposeRequest() {
- return {
- type: COMPOSE_UPLOAD_REQUEST,
- skipLoading: true,
- };
- };
- export function uploadComposeProgress(loaded, total) {
- return {
- type: COMPOSE_UPLOAD_PROGRESS,
- loaded: loaded,
- total: total,
- };
- };
- export function uploadComposeSuccess(media, file) {
- return {
- type: COMPOSE_UPLOAD_SUCCESS,
- media: media,
- file: file,
- skipLoading: true,
- };
- };
- export function uploadComposeFail(error) {
- return {
- type: COMPOSE_UPLOAD_FAIL,
- error: error,
- skipLoading: true,
- };
- };
- export function undoUploadCompose(media_id) {
- return {
- type: COMPOSE_UPLOAD_UNDO,
- media_id: media_id,
- };
- };
- export function clearComposeSuggestions() {
- if (fetchComposeSuggestionsAccountsController) {
- fetchComposeSuggestionsAccountsController.abort();
- }
- return {
- type: COMPOSE_SUGGESTIONS_CLEAR,
- };
- };
- const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => {
- if (fetchComposeSuggestionsAccountsController) {
- fetchComposeSuggestionsAccountsController.abort();
- }
- fetchComposeSuggestionsAccountsController = new AbortController();
- api(getState).get('/api/v1/accounts/search', {
- signal: fetchComposeSuggestionsAccountsController.signal,
- params: {
- q: token.slice(1),
- resolve: false,
- limit: 4,
- },
- }).then(response => {
- dispatch(importFetchedAccounts(response.data));
- dispatch(readyComposeSuggestionsAccounts(token, response.data));
- }).catch(error => {
- if (!axios.isCancel(error)) {
- dispatch(showAlertForError(error));
- }
- }).finally(() => {
- fetchComposeSuggestionsAccountsController = undefined;
- });
- }, 200, { leading: true, trailing: true });
- const fetchComposeSuggestionsEmojis = (dispatch, getState, token) => {
- const results = emojiSearch(token.replace(':', ''), { maxResults: 5 });
- dispatch(readyComposeSuggestionsEmojis(token, results));
- };
- const fetchComposeSuggestionsTags = throttle((dispatch, getState, token) => {
- if (fetchComposeSuggestionsTagsController) {
- fetchComposeSuggestionsTagsController.abort();
- }
- dispatch(updateSuggestionTags(token));
- fetchComposeSuggestionsTagsController = new AbortController();
- api(getState).get('/api/v2/search', {
- signal: fetchComposeSuggestionsTagsController.signal,
- params: {
- type: 'hashtags',
- q: token.slice(1),
- resolve: false,
- limit: 4,
- exclude_unreviewed: true,
- },
- }).then(({ data }) => {
- dispatch(readyComposeSuggestionsTags(token, data.hashtags));
- }).catch(error => {
- if (!axios.isCancel(error)) {
- dispatch(showAlertForError(error));
- }
- }).finally(() => {
- fetchComposeSuggestionsTagsController = undefined;
- });
- }, 200, { leading: true, trailing: true });
- export function fetchComposeSuggestions(token) {
- return (dispatch, getState) => {
- switch (token[0]) {
- case ':':
- fetchComposeSuggestionsEmojis(dispatch, getState, token);
- break;
- case '#':
- fetchComposeSuggestionsTags(dispatch, getState, token);
- break;
- default:
- fetchComposeSuggestionsAccounts(dispatch, getState, token);
- break;
- }
- };
- };
- export function readyComposeSuggestionsEmojis(token, emojis) {
- return {
- type: COMPOSE_SUGGESTIONS_READY,
- token,
- emojis,
- };
- };
- export function readyComposeSuggestionsAccounts(token, accounts) {
- return {
- type: COMPOSE_SUGGESTIONS_READY,
- token,
- accounts,
- };
- };
- export const readyComposeSuggestionsTags = (token, tags) => ({
- type: COMPOSE_SUGGESTIONS_READY,
- token,
- tags,
- });
- export function selectComposeSuggestion(position, token, suggestion, path) {
- return (dispatch, getState) => {
- let completion, startPosition;
- if (suggestion.type === 'emoji') {
- completion = suggestion.native || suggestion.colons;
- startPosition = position - 1;
- dispatch(useEmoji(suggestion));
- } else if (suggestion.type === 'hashtag') {
- completion = `#${suggestion.name}`;
- startPosition = position - 1;
- } else if (suggestion.type === 'account') {
- completion = getState().getIn(['accounts', suggestion.id, 'acct']);
- startPosition = position;
- }
- // We don't want to replace hashtags that vary only in case due to accessibility, but we need to fire off an event so that
- // the suggestions are dismissed and the cursor moves forward.
- if (suggestion.type !== 'hashtag' || token.slice(1).localeCompare(suggestion.name, undefined, { sensitivity: 'accent' }) !== 0) {
- dispatch({
- type: COMPOSE_SUGGESTION_SELECT,
- position: startPosition,
- token,
- completion,
- path,
- });
- } else {
- dispatch({
- type: COMPOSE_SUGGESTION_IGNORE,
- position: startPosition,
- token,
- completion,
- path,
- });
- }
- };
- };
- export function updateSuggestionTags(token) {
- return {
- type: COMPOSE_SUGGESTION_TAGS_UPDATE,
- token,
- };
- }
- export function updateTagHistory(tags) {
- return {
- type: COMPOSE_TAG_HISTORY_UPDATE,
- tags,
- };
- }
- export function hydrateCompose() {
- return (dispatch, getState) => {
- const me = getState().getIn(['meta', 'me']);
- const history = tagHistory.get(me);
- if (history !== null) {
- dispatch(updateTagHistory(history));
- }
- };
- }
- function insertIntoTagHistory(recognizedTags, text) {
- return (dispatch, getState) => {
- const state = getState();
- const oldHistory = state.getIn(['compose', 'tagHistory']);
- const me = state.getIn(['meta', 'me']);
- // FIXME: Matching input hashtags with recognized hashtags has become more
- // complicated because of new normalization rules, it's no longer just
- // a case sensitivity issue
- const names = recognizedTags.map(tag => {
- const matches = text.match(new RegExp(`#${tag.name}`, 'i'));
- if (matches && matches.length > 0) {
- return matches[0].slice(1);
- } else {
- return tag.name;
- }
- });
- const intersectedOldHistory = oldHistory.filter(name => names.findIndex(newName => newName.toLowerCase() === name.toLowerCase()) === -1);
- names.push(...intersectedOldHistory.toJS());
- const newHistory = names.slice(0, 1000);
- tagHistory.set(me, newHistory);
- dispatch(updateTagHistory(newHistory));
- };
- }
- export function mountCompose() {
- return {
- type: COMPOSE_MOUNT,
- };
- };
- export function unmountCompose() {
- return {
- type: COMPOSE_UNMOUNT,
- };
- };
- export function changeComposeSensitivity() {
- return {
- type: COMPOSE_SENSITIVITY_CHANGE,
- };
- };
- export const changeComposeLanguage = language => ({
- type: COMPOSE_LANGUAGE_CHANGE,
- language,
- });
- export function changeComposeSpoilerness() {
- return {
- type: COMPOSE_SPOILERNESS_CHANGE,
- };
- };
- export function changeComposeSpoilerText(text) {
- return {
- type: COMPOSE_SPOILER_TEXT_CHANGE,
- text,
- };
- };
- export function changeComposeVisibility(value) {
- return {
- type: COMPOSE_VISIBILITY_CHANGE,
- value,
- };
- };
- export function insertEmojiCompose(position, emoji, needsSpace) {
- return {
- type: COMPOSE_EMOJI_INSERT,
- position,
- emoji,
- needsSpace,
- };
- };
- export function changeComposing(value) {
- return {
- type: COMPOSE_COMPOSING_CHANGE,
- value,
- };
- };
- export function addPoll() {
- return {
- type: COMPOSE_POLL_ADD,
- };
- };
- export function removePoll() {
- return {
- type: COMPOSE_POLL_REMOVE,
- };
- };
- export function addPollOption(title) {
- return {
- type: COMPOSE_POLL_OPTION_ADD,
- title,
- };
- };
- export function changePollOption(index, title) {
- return {
- type: COMPOSE_POLL_OPTION_CHANGE,
- index,
- title,
- };
- };
- export function removePollOption(index) {
- return {
- type: COMPOSE_POLL_OPTION_REMOVE,
- index,
- };
- };
- export function changePollSettings(expiresIn, isMultiple) {
- return {
- type: COMPOSE_POLL_SETTINGS_CHANGE,
- expiresIn,
- isMultiple,
- };
- };
|