Add polls (#10111)
* Add polls Fix #1629 * Add tests * Fixes * Change API for creating polls * Use name instead of content for votes * Remove poll validation for remote polls * Add polls to public pages * When updating the poll, update options just in case they were changed * Fix public pages showing both poll and other media
This commit is contained in:
parent
99dc212ae5
commit
230a012f00
47 changed files with 1038 additions and 19 deletions
|
@ -1,11 +1,10 @@
|
|||
// import { autoPlayGif } from '../../initial_state';
|
||||
// import { putAccounts, putStatuses } from '../../storage/modifier';
|
||||
import { normalizeAccount, normalizeStatus } from './normalizer';
|
||||
|
||||
export const ACCOUNT_IMPORT = 'ACCOUNT_IMPORT';
|
||||
export const ACCOUNT_IMPORT = 'ACCOUNT_IMPORT';
|
||||
export const ACCOUNTS_IMPORT = 'ACCOUNTS_IMPORT';
|
||||
export const STATUS_IMPORT = 'STATUS_IMPORT';
|
||||
export const STATUS_IMPORT = 'STATUS_IMPORT';
|
||||
export const STATUSES_IMPORT = 'STATUSES_IMPORT';
|
||||
export const POLLS_IMPORT = 'POLLS_IMPORT';
|
||||
|
||||
function pushUnique(array, object) {
|
||||
if (array.every(element => element.id !== object.id)) {
|
||||
|
@ -29,6 +28,10 @@ export function importStatuses(statuses) {
|
|||
return { type: STATUSES_IMPORT, statuses };
|
||||
}
|
||||
|
||||
export function importPolls(polls) {
|
||||
return { type: POLLS_IMPORT, polls };
|
||||
}
|
||||
|
||||
export function importFetchedAccount(account) {
|
||||
return importFetchedAccounts([account]);
|
||||
}
|
||||
|
@ -45,7 +48,6 @@ export function importFetchedAccounts(accounts) {
|
|||
}
|
||||
|
||||
accounts.forEach(processAccount);
|
||||
//putAccounts(normalAccounts, !autoPlayGif);
|
||||
|
||||
return importAccounts(normalAccounts);
|
||||
}
|
||||
|
@ -58,6 +60,7 @@ export function importFetchedStatuses(statuses) {
|
|||
return (dispatch, getState) => {
|
||||
const accounts = [];
|
||||
const normalStatuses = [];
|
||||
const polls = [];
|
||||
|
||||
function processStatus(status) {
|
||||
pushUnique(normalStatuses, normalizeStatus(status, getState().getIn(['statuses', status.id])));
|
||||
|
@ -66,12 +69,16 @@ export function importFetchedStatuses(statuses) {
|
|||
if (status.reblog && status.reblog.id) {
|
||||
processStatus(status.reblog);
|
||||
}
|
||||
|
||||
if (status.poll && status.poll.id) {
|
||||
pushUnique(polls, status.poll);
|
||||
}
|
||||
}
|
||||
|
||||
statuses.forEach(processStatus);
|
||||
//putStatuses(normalStatuses);
|
||||
|
||||
dispatch(importFetchedAccounts(accounts));
|
||||
dispatch(importStatuses(normalStatuses));
|
||||
dispatch(importPolls(polls));
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue