Merge branch 'eslint-spacing' into 'develop'

eslint: enforce spacing of imports (and infix ops)

See merge request soapbox-pub/soapbox-fe!1351
This commit is contained in:
Alex Gleason 2022-05-11 21:26:59 +00:00
commit 54dfb0e23e
102 changed files with 1885 additions and 1882 deletions

View File

@ -65,11 +65,14 @@ module.exports = {
], ],
'comma-style': ['warn', 'last'], 'comma-style': ['warn', 'last'],
'space-before-function-paren': ['error', 'never'], 'space-before-function-paren': ['error', 'never'],
'space-infix-ops': 'error',
'space-in-parens': ['error', 'never'], 'space-in-parens': ['error', 'never'],
'keyword-spacing': 'error',
'consistent-return': 'error', 'consistent-return': 'error',
'dot-notation': 'error', 'dot-notation': 'error',
eqeqeq: 'error', eqeqeq: 'error',
indent: ['error', 2, { indent: ['error', 2, {
SwitchCase: 1, // https://stackoverflow.com/a/53055584/8811886
ignoredNodes: ['TemplateLiteral'], ignoredNodes: ['TemplateLiteral'],
}], }],
'jsx-quotes': ['error', 'prefer-single'], 'jsx-quotes': ['error', 'prefer-single'],

View File

@ -515,15 +515,15 @@ const fetchComposeSuggestionsTags = (dispatch, getState, token) => {
export function fetchComposeSuggestions(token) { export function fetchComposeSuggestions(token) {
return (dispatch, getState) => { return (dispatch, getState) => {
switch (token[0]) { switch (token[0]) {
case ':': case ':':
fetchComposeSuggestionsEmojis(dispatch, getState, token); fetchComposeSuggestionsEmojis(dispatch, getState, token);
break; break;
case '#': case '#':
fetchComposeSuggestionsTags(dispatch, getState, token); fetchComposeSuggestionsTags(dispatch, getState, token);
break; break;
default: default:
fetchComposeSuggestionsAccounts(dispatch, getState, token); fetchComposeSuggestionsAccounts(dispatch, getState, token);
break; break;
} }
}; };
} }

View File

@ -67,7 +67,7 @@ export function createFilter(intl, phrase, expires_at, context, whole_word, irre
export function deleteFilter(intl, id) { export function deleteFilter(intl, id) {
return (dispatch, getState) => { return (dispatch, getState) => {
dispatch({ type: FILTERS_DELETE_REQUEST }); dispatch({ type: FILTERS_DELETE_REQUEST });
return api(getState).delete('/api/v1/filters/'+id).then(response => { return api(getState).delete('/api/v1/filters/' + id).then(response => {
dispatch({ type: FILTERS_DELETE_SUCCESS, filter: response.data }); dispatch({ type: FILTERS_DELETE_SUCCESS, filter: response.data });
dispatch(snackbar.success(intl.formatMessage(messages.removed))); dispatch(snackbar.success(intl.formatMessage(messages.removed)));
}).catch(error => { }).catch(error => {

View File

@ -46,7 +46,7 @@ export const fetchInstance = createAsyncThunk<void, void, { state: RootState }>(
dispatch(fetchNodeinfo()); dispatch(fetchNodeinfo());
} }
return instance; return instance;
} catch(e) { } catch (e) {
return rejectWithValue(e); return rejectWithValue(e);
} }
}, },

View File

@ -51,47 +51,47 @@ export function connectTimelineStream(timelineId, path, pollingRefresh = null, a
}, },
onReceive(data) { onReceive(data) {
switch(data.event) { switch (data.event) {
case 'update': case 'update':
dispatch(processTimelineUpdate(timelineId, JSON.parse(data.payload), accept)); dispatch(processTimelineUpdate(timelineId, JSON.parse(data.payload), accept));
break; break;
case 'status.update': case 'status.update':
dispatch(updateStatus(JSON.parse(data.payload))); dispatch(updateStatus(JSON.parse(data.payload)));
break; break;
case 'delete': case 'delete':
dispatch(deleteFromTimelines(data.payload)); dispatch(deleteFromTimelines(data.payload));
break; break;
case 'notification': case 'notification':
messages[locale]().then(messages => { messages[locale]().then(messages => {
dispatch(updateNotificationsQueue(JSON.parse(data.payload), messages, locale, window.location.pathname)); dispatch(updateNotificationsQueue(JSON.parse(data.payload), messages, locale, window.location.pathname));
}).catch(error => { }).catch(error => {
console.error(error); console.error(error);
});
break;
case 'conversation':
dispatch(updateConversations(JSON.parse(data.payload)));
break;
case 'filters_changed':
dispatch(fetchFilters());
break;
case 'pleroma:chat_update':
dispatch((dispatch, getState) => {
const chat = JSON.parse(data.payload);
const me = getState().get('me');
const messageOwned = !(chat.last_message && chat.last_message.account_id !== me);
dispatch({
type: STREAMING_CHAT_UPDATE,
chat,
me,
// Only play sounds for recipient messages
meta: !messageOwned && getSettings(getState()).getIn(['chats', 'sound']) && { sound: 'chat' },
}); });
}); break;
break; case 'conversation':
case 'pleroma:follow_relationships_update': dispatch(updateConversations(JSON.parse(data.payload)));
dispatch(updateFollowRelationships(JSON.parse(data.payload))); break;
break; case 'filters_changed':
dispatch(fetchFilters());
break;
case 'pleroma:chat_update':
dispatch((dispatch, getState) => {
const chat = JSON.parse(data.payload);
const me = getState().get('me');
const messageOwned = !(chat.last_message && chat.last_message.account_id !== me);
dispatch({
type: STREAMING_CHAT_UPDATE,
chat,
me,
// Only play sounds for recipient messages
meta: !messageOwned && getSettings(getState()).getIn(['chats', 'sound']) && { sound: 'chat' },
});
});
break;
case 'pleroma:follow_relationships_update':
dispatch(updateFollowRelationships(JSON.parse(data.payload)));
break;
} }
}, },
}; };

View File

@ -108,47 +108,47 @@ export default class AutosuggestInput extends ImmutablePureComponent {
return; return;
} }
switch(e.key) { switch (e.key) {
case 'Escape': case 'Escape':
if (suggestions.size === 0 || suggestionsHidden) { if (suggestions.size === 0 || suggestionsHidden) {
document.querySelector('.ui').parentElement.focus(); document.querySelector('.ui').parentElement.focus();
} else {
e.preventDefault();
this.setState({ suggestionsHidden: true });
}
break;
case 'ArrowDown':
if (!suggestionsHidden && (suggestions.size > 0 || menu)) {
e.preventDefault();
this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, lastIndex) });
}
break;
case 'ArrowUp':
if (!suggestionsHidden && (suggestions.size > 0 || menu)) {
e.preventDefault();
this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, firstIndex) });
}
break;
case 'Enter':
case 'Tab':
// Select suggestion
if (!suggestionsHidden && selectedSuggestion > -1 && (suggestions.size > 0 || menu)) {
e.preventDefault();
e.stopPropagation();
this.setState({ selectedSuggestion: firstIndex });
if (selectedSuggestion < suggestions.size) {
this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions.get(selectedSuggestion));
} else { } else {
const item = menu[selectedSuggestion - suggestions.size]; e.preventDefault();
this.handleMenuItemAction(item); this.setState({ suggestionsHidden: true });
} }
}
break; break;
case 'ArrowDown':
if (!suggestionsHidden && (suggestions.size > 0 || menu)) {
e.preventDefault();
this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, lastIndex) });
}
break;
case 'ArrowUp':
if (!suggestionsHidden && (suggestions.size > 0 || menu)) {
e.preventDefault();
this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, firstIndex) });
}
break;
case 'Enter':
case 'Tab':
// Select suggestion
if (!suggestionsHidden && selectedSuggestion > -1 && (suggestions.size > 0 || menu)) {
e.preventDefault();
e.stopPropagation();
this.setState({ selectedSuggestion: firstIndex });
if (selectedSuggestion < suggestions.size) {
this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions.get(selectedSuggestion));
} else {
const item = menu[selectedSuggestion - suggestions.size];
this.handleMenuItemAction(item);
}
}
break;
} }
if (e.defaultPrevented || !this.props.onKeyDown) { if (e.defaultPrevented || !this.props.onKeyDown) {

View File

@ -97,40 +97,40 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
return; return;
} }
switch(e.key) { switch (e.key) {
case 'Escape': case 'Escape':
if (suggestions.size === 0 || suggestionsHidden) { if (suggestions.size === 0 || suggestionsHidden) {
document.querySelector('.ui').parentElement.focus(); document.querySelector('.ui').parentElement.focus();
} else { } else {
e.preventDefault(); e.preventDefault();
this.setState({ suggestionsHidden: true }); this.setState({ suggestionsHidden: true });
} }
break; break;
case 'ArrowDown': case 'ArrowDown':
if (suggestions.size > 0 && !suggestionsHidden) { if (suggestions.size > 0 && !suggestionsHidden) {
e.preventDefault(); e.preventDefault();
this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, suggestions.size - 1) }); this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, suggestions.size - 1) });
} }
break; break;
case 'ArrowUp': case 'ArrowUp':
if (suggestions.size > 0 && !suggestionsHidden) { if (suggestions.size > 0 && !suggestionsHidden) {
e.preventDefault(); e.preventDefault();
this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, 0) }); this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, 0) });
} }
break; break;
case 'Enter': case 'Enter':
case 'Tab': case 'Tab':
// Select suggestion // Select suggestion
if (this.state.lastToken !== null && suggestions.size > 0 && !suggestionsHidden) { if (this.state.lastToken !== null && suggestions.size > 0 && !suggestionsHidden) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions.get(selectedSuggestion)); this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions.get(selectedSuggestion));
} }
break; break;
} }
if (e.defaultPrevented || !this.props.onKeyDown) { if (e.defaultPrevented || !this.props.onKeyDown) {

View File

@ -95,29 +95,29 @@ class DropdownMenu extends React.PureComponent<IDropdownMenu, IDropdownMenuState
const index = items.indexOf(document.activeElement as any); const index = items.indexOf(document.activeElement as any);
let element = null; let element = null;
switch(e.key) { switch (e.key) {
case 'ArrowDown': case 'ArrowDown':
element = items[index+1] || items[0]; element = items[index + 1] || items[0];
break; break;
case 'ArrowUp': case 'ArrowUp':
element = items[index-1] || items[items.length-1]; element = items[index - 1] || items[items.length - 1];
break; break;
case 'Tab': case 'Tab':
if (e.shiftKey) { if (e.shiftKey) {
element = items[index-1] || items[items.length-1]; element = items[index - 1] || items[items.length - 1];
} else { } else {
element = items[index+1] || items[0]; element = items[index + 1] || items[0];
} }
break; break;
case 'Home': case 'Home':
element = items[0]; element = items[0];
break; break;
case 'End': case 'End':
element = items[items.length-1]; element = items[items.length - 1];
break; break;
case 'Escape': case 'Escape':
this.props.onClose(); this.props.onClose();
break; break;
} }
if (element) { if (element) {
@ -312,22 +312,22 @@ class Dropdown extends React.PureComponent<IDropdown, IDropdownState> {
} }
handleButtonKeyDown: React.EventHandler<React.KeyboardEvent> = (e) => { handleButtonKeyDown: React.EventHandler<React.KeyboardEvent> = (e) => {
switch(e.key) { switch (e.key) {
case ' ': case ' ':
case 'Enter': case 'Enter':
this.handleMouseDown(e); this.handleMouseDown(e);
break; break;
} }
} }
handleKeyPress: React.EventHandler<React.KeyboardEvent<HTMLButtonElement>> = (e) => { handleKeyPress: React.EventHandler<React.KeyboardEvent<HTMLButtonElement>> = (e) => {
switch(e.key) { switch (e.key) {
case ' ': case ' ':
case 'Enter': case 'Enter':
this.handleClick(e); this.handleClick(e);
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
break; break;
} }
} }

View File

@ -68,22 +68,22 @@ class EmojiSelector extends ImmutablePureComponent<IEmojiSelector> {
const { onUnfocus } = this.props; const { onUnfocus } = this.props;
switch (e.key) { switch (e.key) {
case 'Tab': case 'Tab':
e.preventDefault(); e.preventDefault();
if (e.shiftKey) this._selectPreviousEmoji(i); if (e.shiftKey) this._selectPreviousEmoji(i);
else this._selectNextEmoji(i); else this._selectNextEmoji(i);
break; break;
case 'Left': case 'Left':
case 'ArrowLeft': case 'ArrowLeft':
this._selectPreviousEmoji(i); this._selectPreviousEmoji(i);
break; break;
case 'Right': case 'Right':
case 'ArrowRight': case 'ArrowRight':
this._selectNextEmoji(i); this._selectNextEmoji(i);
break; break;
case 'Escape': case 'Escape':
onUnfocus(); onUnfocus();
break; break;
} }
} }

View File

@ -56,13 +56,13 @@ class FilterBar extends React.PureComponent {
const index = items.indexOf(document.activeElement); const index = items.indexOf(document.activeElement);
let element = null; let element = null;
switch(e.key) { switch (e.key) {
case 'ArrowRight': case 'ArrowRight':
element = items[index+1] || items[0]; element = items[index + 1] || items[0];
break; break;
case 'ArrowLeft': case 'ArrowLeft':
element = items[index-1] || items[items.length-1]; element = items[index - 1] || items[items.length - 1];
break; break;
} }
if (element) { if (element) {

View File

@ -1,5 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import { Helmet as ReactHelmet } from'react-helmet'; import { Helmet as ReactHelmet } from 'react-helmet';
import { useAppSelector, useSettings } from 'soapbox/hooks'; import { useAppSelector, useSettings } from 'soapbox/hooks';
import FaviconService from 'soapbox/utils/favicon_service'; import FaviconService from 'soapbox/utils/favicon_service';

View File

@ -337,7 +337,7 @@ class MediaGallery extends React.PureComponent {
const aspectRatio = media.getIn([0, 'meta', 'original', 'aspect']); const aspectRatio = media.getIn([0, 'meta', 'original', 'aspect']);
const getHeight = () => { const getHeight = () => {
if (!aspectRatio) return width*9/16; if (!aspectRatio) return width * 9 / 16;
if (isPanoramic(aspectRatio)) return Math.floor(width / maximumAspectRatio); if (isPanoramic(aspectRatio)) return Math.floor(width / maximumAspectRatio);
if (isPortrait(aspectRatio)) return Math.floor(width / minimumAspectRatio); if (isPortrait(aspectRatio)) return Math.floor(width / minimumAspectRatio);
return Math.floor(width / aspectRatio); return Math.floor(width / aspectRatio);

View File

@ -54,16 +54,16 @@ const selectUnits = delta => {
const getUnitDelay = units => { const getUnitDelay = units => {
switch (units) { switch (units) {
case 'second': case 'second':
return SECOND; return SECOND;
case 'minute': case 'minute':
return MINUTE; return MINUTE;
case 'hour': case 'hour':
return HOUR; return HOUR;
case 'day': case 'day':
return DAY; return DAY;
default: default:
return MAX_DELAY; return MAX_DELAY;
} }
}; };

View File

@ -143,7 +143,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
<Link to='/' onClick={onClose}> <Link to='/' onClick={onClose}>
{logo ? ( {logo ? (
<img alt='Logo' src={logo} className='h-5 w-auto cursor-pointer' /> <img alt='Logo' src={logo} className='h-5 w-auto cursor-pointer' />
): ( ) : (
<Icon <Icon
alt='Logo' alt='Logo'
src={require('@tabler/icons/icons/home.svg')} src={require('@tabler/icons/icons/home.svg')}

View File

@ -673,7 +673,7 @@ class StatusActionBar extends ImmutablePureComponent<IStatusActionBar, IStatusAc
count={emojiReactCount} count={emojiReactCount}
/> />
</EmojiButtonWrapper> </EmojiButtonWrapper>
): ( ) : (
<StatusActionButton <StatusActionButton
title={intl.formatMessage(messages.favourite)} title={intl.formatMessage(messages.favourite)}
icon={require('@tabler/icons/icons/heart.svg')} icon={require('@tabler/icons/icons/heart.svg')}

View File

@ -85,7 +85,7 @@ class Audio extends React.PureComponent {
_setDimensions() { _setDimensions() {
const width = this.player.offsetWidth; const width = this.player.offsetWidth;
const height = this.props.fullscreen ? this.player.offsetHeight : (width / (16/9)); const height = this.props.fullscreen ? this.player.offsetHeight : (width / (16 / 9));
if (this.props.cacheWidth) { if (this.props.cacheWidth) {
this.props.cacheWidth(width); this.props.cacheWidth(width);
@ -412,27 +412,27 @@ class Audio extends React.PureComponent {
} }
handleKeyDown = e => { handleKeyDown = e => {
switch(e.key) { switch (e.key) {
case 'k': case 'k':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.togglePlay(); this.togglePlay();
break; break;
case 'm': case 'm':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.toggleMute(); this.toggleMute();
break; break;
case 'j': case 'j':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.seekBy(-10); this.seekBy(-10);
break; break;
case 'l': case 'l':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.seekBy(10); this.seekBy(10);
break; break;
} }
} }

View File

@ -40,7 +40,7 @@ export default class Visualizer {
getTickPoints(count) { getTickPoints(count) {
const coords = []; const coords = [];
for(let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
const rad = Math.PI * 2 * i / count; const rad = Math.PI * 2 * i / count;
coords.push({ x: Math.cos(rad), y: -Math.sin(rad) }); coords.push({ x: Math.cos(rad), y: -Math.sin(rad) });
} }

View File

@ -30,7 +30,7 @@ const CaptchaField: React.FC<ICaptchaField> = ({
onFetch = noOp, onFetch = noOp,
onFetchFail = noOp, onFetchFail = noOp,
onClick = noOp, onClick = noOp,
refreshInterval = 5*60*1000, // 5 minutes, Pleroma default refreshInterval = 5 * 60 * 1000, // 5 minutes, Pleroma default
idempotencyKey, idempotencyKey,
}) => { }) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@ -71,26 +71,26 @@ const CaptchaField: React.FC<ICaptchaField> = ({
}; };
}, [idempotencyKey]); }, [idempotencyKey]);
switch(captcha.get('type')) { switch (captcha.get('type')) {
case 'native': case 'native':
return ( return (
<div> <div>
<Text> <Text>
<FormattedMessage id='registration.captcha.hint' defaultMessage='Click the image to get a new captcha' /> <FormattedMessage id='registration.captcha.hint' defaultMessage='Click the image to get a new captcha' />
</Text> </Text>
<NativeCaptchaField <NativeCaptchaField
captcha={captcha} captcha={captcha}
onChange={onChange} onChange={onChange}
onClick={onClick} onClick={onClick}
name={name} name={name}
value={value} value={value}
/> />
</div> </div>
); );
case 'none': case 'none':
default: default:
return null; return null;
} }
}; };

View File

@ -132,7 +132,7 @@ class ChatBox extends ImmutablePureComponent {
onUploadProgress = (e) => { onUploadProgress = (e) => {
const { loaded, total } = e; const { loaded, total } = e;
this.setState({ uploadProgress: loaded/total }); this.setState({ uploadProgress: loaded / total });
} }
handleFiles = (files) => { handleFiles = (files) => {
@ -193,7 +193,7 @@ class ChatBox extends ImmutablePureComponent {
<div className='chat-box' onMouseOver={this.handleHover}> <div className='chat-box' onMouseOver={this.handleHover}>
<ChatMessageList chatMessageIds={chatMessageIds} chatId={chatId} /> <ChatMessageList chatMessageIds={chatMessageIds} chatId={chatId} />
{this.renderAttachment()} {this.renderAttachment()}
<UploadProgress active={isUploading} progress={uploadProgress*100} /> <UploadProgress active={isUploading} progress={uploadProgress * 100} />
<div className='chat-box__actions simple_form'> <div className='chat-box__actions simple_form'>
<div className='chat-box__send'> <div className='chat-box__send'>
{this.renderActionButton()} {this.renderActionButton()}

View File

@ -314,17 +314,17 @@ class ChatMessageList extends ImmutablePureComponent {
return ( return (
<div className='chat-messages' ref={this.setRef}> <div className='chat-messages' ref={this.setRef}>
{chatMessages.reduce((acc, curr, idx) => { {chatMessages.reduce((acc, curr, idx) => {
const lastMessage = chatMessages.get(idx-1); const lastMessage = chatMessages.get(idx - 1);
if (lastMessage) { if (lastMessage) {
const key = `${curr.get('id')}_divider`; const key = `${curr.get('id')}_divider`;
switch(timeChange(lastMessage, curr)) { switch (timeChange(lastMessage, curr)) {
case 'today': case 'today':
acc.push(this.renderDivider(key, intl.formatMessage(messages.today))); acc.push(this.renderDivider(key, intl.formatMessage(messages.today)));
break; break;
case 'date': case 'date':
acc.push(this.renderDivider(key, new Date(curr.get('created_at')).toDateString())); acc.push(this.renderDivider(key, new Date(curr.get('created_at')).toDateString()));
break; break;
} }
} }

View File

@ -229,8 +229,8 @@ class ComposeForm extends ImmutablePureComponent {
const spoilerUpdated = this.props.spoiler !== prevProps.spoiler; const spoilerUpdated = this.props.spoiler !== prevProps.spoiler;
if (spoilerUpdated) { if (spoilerUpdated) {
switch (this.props.spoiler) { switch (this.props.spoiler) {
case true: this.focusSpoilerInput(); break; case true: this.focusSpoilerInput(); break;
case false: this.focusTextarea(); break; case false: this.focusTextarea(); break;
} }
} }
} }

View File

@ -55,32 +55,32 @@ class PrivacyDropdownMenu extends React.PureComponent {
}); });
let element = null; let element = null;
switch(e.key) { switch (e.key) {
case 'Escape': case 'Escape':
this.props.onClose(); this.props.onClose();
break; break;
case 'Enter': case 'Enter':
this.handleClick(e); this.handleClick(e);
break; break;
case 'ArrowDown': case 'ArrowDown':
element = this.node.childNodes[index + 1] || this.node.firstChild;
break;
case 'ArrowUp':
element = this.node.childNodes[index - 1] || this.node.lastChild;
break;
case 'Tab':
if (e.shiftKey) {
element = this.node.childNodes[index - 1] || this.node.lastChild;
} else {
element = this.node.childNodes[index + 1] || this.node.firstChild; element = this.node.childNodes[index + 1] || this.node.firstChild;
} break;
break; case 'ArrowUp':
case 'Home': element = this.node.childNodes[index - 1] || this.node.lastChild;
element = this.node.firstChild; break;
break; case 'Tab':
case 'End': if (e.shiftKey) {
element = this.node.lastChild; element = this.node.childNodes[index - 1] || this.node.lastChild;
break; } else {
element = this.node.childNodes[index + 1] || this.node.firstChild;
}
break;
case 'Home':
element = this.node.firstChild;
break;
case 'End':
element = this.node.lastChild;
break;
} }
if (element) { if (element) {
@ -211,10 +211,10 @@ class PrivacyDropdown extends React.PureComponent {
} }
handleKeyDown = e => { handleKeyDown = e => {
switch(e.key) { switch (e.key) {
case 'Escape': case 'Escape':
this.handleClose(); this.handleClose();
break; break;
} }
} }
@ -225,11 +225,11 @@ class PrivacyDropdown extends React.PureComponent {
} }
handleButtonKeyDown = (e) => { handleButtonKeyDown = (e) => {
switch(e.key) { switch (e.key) {
case ' ': case ' ':
case 'Enter': case 'Enter':
this.handleMouseDown(); this.handleMouseDown();
break; break;
} }
} }

View File

@ -158,7 +158,7 @@ class Upload extends ImmutablePureComponent {
className={classNames('compose-form__upload-thumbnail', `${mediaType}`)} className={classNames('compose-form__upload-thumbnail', `${mediaType}`)}
style={{ style={{
transform: `scale(${scale})`, transform: `scale(${scale})`,
backgroundImage: mediaType === 'image' ? `url(${media.get('preview_url')})`: null, backgroundImage: mediaType === 'image' ? `url(${media.get('preview_url')})` : null,
backgroundPosition: `${x}% ${y}%` }} backgroundPosition: `${x}% ${y}%` }}
> >
<div className={classNames('compose-form__upload__actions', { active })}> <div className={classNames('compose-form__upload__actions', { active })}>

View File

@ -177,8 +177,8 @@ export const urlRegex = (function() {
'(?:' + '(?:' +
'#{validGeneralUrlPathChars}*' + '#{validGeneralUrlPathChars}*' +
'(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*' + '(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*' +
'#{validUrlPathEndingChars}'+ '#{validUrlPathEndingChars}' +
')|(?:@#{validGeneralUrlPathChars}+\/)'+ ')|(?:@#{validGeneralUrlPathChars}+\/)' +
')', 'i'); ')', 'i');
regexen.validUrlQueryChars = /[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i; regexen.validUrlQueryChars = /[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i;
regexen.validUrlQueryEndingChars = /[a-z0-9_&=#\/]/i; regexen.validUrlQueryEndingChars = /[a-z0-9_&=#\/]/i;

View File

@ -409,7 +409,7 @@ const EditProfile: React.FC = () => {
hint={<FormattedMessage id='edit_profile.hints.hide_network' defaultMessage='Who you follow and who follows you will not be shown on your profile' />} hint={<FormattedMessage id='edit_profile.hints.hide_network' defaultMessage='Who you follow and who follows you will not be shown on your profile' />}
> >
<Toggle <Toggle
checked={account ? hidesNetwork(account): false} checked={account ? hidesNetwork(account) : false}
onChange={handleHideNetworkChange} onChange={handleHideNetworkChange}
/> />
</ListItem> </ListItem>

View File

@ -132,12 +132,12 @@ class Introduction extends React.PureComponent {
handleKeyUp = ({ key }) => { handleKeyUp = ({ key }) => {
switch (key) { switch (key) {
case 'ArrowLeft': case 'ArrowLeft':
this.handlePrev(); this.handlePrev();
break; break;
case 'ArrowRight': case 'ArrowRight':
this.handleNext(); this.handleNext();
break; break;
} }
} }

View File

@ -214,46 +214,46 @@ const Notification: React.FC<INotificaton> = (props) => {
const renderContent = () => { const renderContent = () => {
switch (type) { switch (type) {
case 'follow': case 'follow':
case 'follow_request': case 'follow_request':
return account && typeof account === 'object' ? ( return account && typeof account === 'object' ? (
<AccountContainer <AccountContainer
id={account.id} id={account.id}
hidden={hidden} hidden={hidden}
avatarSize={48} avatarSize={48}
/> />
) : null; ) : null;
case 'move': case 'move':
return account && typeof account === 'object' && notification.target && typeof notification.target === 'object' ? ( return account && typeof account === 'object' && notification.target && typeof notification.target === 'object' ? (
<AccountContainer <AccountContainer
id={notification.target.id} id={notification.target.id}
hidden={hidden} hidden={hidden}
avatarSize={48} avatarSize={48}
/> />
) : null; ) : null;
case 'favourite': case 'favourite':
case 'mention': case 'mention':
case 'reblog': case 'reblog':
case 'status': case 'status':
case 'poll': case 'poll':
case 'pleroma:emoji_reaction': case 'pleroma:emoji_reaction':
return status && typeof status === 'object' ? ( return status && typeof status === 'object' ? (
<StatusContainer <StatusContainer
// @ts-ignore // @ts-ignore
id={status.id} id={status.id}
withDismiss withDismiss
hidden={hidden} hidden={hidden}
onMoveDown={handleMoveDown} onMoveDown={handleMoveDown}
onMoveUp={handleMoveUp} onMoveUp={handleMoveUp}
contextType='notifications' contextType='notifications'
getScrollPosition={props.getScrollPosition} getScrollPosition={props.getScrollPosition}
updateScrollBottom={props.updateScrollBottom} updateScrollBottom={props.updateScrollBottom}
cachedMediaWidth={props.cachedMediaWidth} cachedMediaWidth={props.cachedMediaWidth}
cacheMediaWidth={props.cacheMediaWidth} cacheMediaWidth={props.cacheMediaWidth}
/> />
) : null; ) : null;
default: default:
return null; return null;
} }
}; };

View File

@ -46,12 +46,12 @@ const OnboardingWizard = () => {
const handleKeyUp = ({ key }: KeyboardEvent): void => { const handleKeyUp = ({ key }: KeyboardEvent): void => {
switch (key) { switch (key) {
case 'ArrowLeft': case 'ArrowLeft':
handlePreviousStep(); handlePreviousStep();
break; break;
case 'ArrowRight': case 'ArrowRight':
handleNextStep(); handleNextStep();
break; break;
} }
}; };

View File

@ -22,7 +22,7 @@ const moneyFormat = (amount: number): string => (
currency: 'usd', currency: 'usd',
notation: 'compact', notation: 'compact',
}) })
.format(amount/100) .format(amount / 100)
); );
const FundingPanel: React.FC = () => { const FundingPanel: React.FC = () => {
@ -59,7 +59,7 @@ const FundingPanel: React.FC = () => {
<div className='funding-panel__ratio'> <div className='funding-panel__ratio'>
<Text>{ratioText}</Text> <Text>{ratioText}</Text>
</div> </div>
<ProgressBar progress={amount/goal} /> <ProgressBar progress={amount / goal} />
<div className='funding-panel__description'> <div className='funding-panel__description'>
<Text>{goalText}</Text> <Text>{goalText}</Text>
</div> </div>

View File

@ -57,17 +57,17 @@ class MediaModal extends ImmutablePureComponent {
} }
handleKeyDown = (e) => { handleKeyDown = (e) => {
switch(e.key) { switch (e.key) {
case 'ArrowLeft': case 'ArrowLeft':
this.handlePrevClick(); this.handlePrevClick();
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
break; break;
case 'ArrowRight': case 'ArrowRight':
this.handleNextClick(); this.handleNextClick();
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
break; break;
} }
} }

View File

@ -108,42 +108,42 @@ const ReportModal = ({ onClose }: IReportModal) => {
const handleNextStep = () => { const handleNextStep = () => {
switch (currentStep) { switch (currentStep) {
case Steps.ONE: case Steps.ONE:
setCurrentStep(Steps.TWO); setCurrentStep(Steps.TWO);
break; break;
case Steps.TWO: case Steps.TWO:
handleSubmit(); handleSubmit();
break; break;
case Steps.THREE: case Steps.THREE:
dispatch(submitReportSuccess()); dispatch(submitReportSuccess());
onClose(); onClose();
break; break;
default: default:
break; break;
} }
}; };
const renderSelectedStatuses = useCallback(() => { const renderSelectedStatuses = useCallback(() => {
switch (selectedStatusIds.size) { switch (selectedStatusIds.size) {
case 0: case 0:
return ( return (
<div className='bg-gray-100 dark:bg-slate-700 p-4 rounded-lg flex items-center justify-center w-full'> <div className='bg-gray-100 dark:bg-slate-700 p-4 rounded-lg flex items-center justify-center w-full'>
<Text theme='muted'>{intl.formatMessage(messages.blankslate)}</Text> <Text theme='muted'>{intl.formatMessage(messages.blankslate)}</Text>
</div> </div>
); );
default: default:
return <SelectedStatus statusId={selectedStatusIds.first()} />; return <SelectedStatus statusId={selectedStatusIds.first()} />;
} }
}, [selectedStatusIds.size]); }, [selectedStatusIds.size]);
const confirmationText = useMemo(() => { const confirmationText = useMemo(() => {
switch (currentStep) { switch (currentStep) {
case Steps.TWO: case Steps.TWO:
return intl.formatMessage(messages.submit); return intl.formatMessage(messages.submit);
case Steps.THREE: case Steps.THREE:
return intl.formatMessage(messages.done); return intl.formatMessage(messages.done);
default: default:
return intl.formatMessage(messages.next); return intl.formatMessage(messages.next);
} }
}, [currentStep]); }, [currentStep]);
@ -157,14 +157,14 @@ const ReportModal = ({ onClose }: IReportModal) => {
const calculateProgress = useCallback(() => { const calculateProgress = useCallback(() => {
switch (currentStep) { switch (currentStep) {
case Steps.ONE: case Steps.ONE:
return 0.33; return 0.33;
case Steps.TWO: case Steps.TWO:
return 0.66; return 0.66;
case Steps.THREE: case Steps.THREE:
return 1; return 1;
default: default:
return 0; return 0;
} }
}, [currentStep]); }, [currentStep]);

View File

@ -20,14 +20,14 @@ const ThemeSelector: React.FC<IThemeSelector> = ({ value, onChange }) => {
const themeIconSrc = useMemo(() => { const themeIconSrc = useMemo(() => {
switch (value) { switch (value) {
case 'system': case 'system':
return require('@tabler/icons/icons/device-desktop.svg'); return require('@tabler/icons/icons/device-desktop.svg');
case 'light': case 'light':
return require('@tabler/icons/icons/sun.svg'); return require('@tabler/icons/icons/sun.svg');
case 'dark': case 'dark':
return require('@tabler/icons/icons/moon.svg'); return require('@tabler/icons/icons/moon.svg');
default: default:
return null; return null;
} }
}, [value]); }, [value]);

View File

@ -20,12 +20,12 @@ const UploadArea: React.FC<IUploadArea> = ({ active, onClose }) => {
const keyCode = e.keyCode; const keyCode = e.keyCode;
if (active) { if (active) {
switch(keyCode) { switch (keyCode) {
case 27: case 27:
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
onClose(); onClose();
break; break;
} }
} }
}; };

View File

@ -115,24 +115,24 @@ const EmailPassThru = ({ match }) => {
if (errorKey) { if (errorKey) {
switch (errorKey) { switch (errorKey) {
case 'token_expired': case 'token_expired':
message = intl.formatMessage({ message = intl.formatMessage({
id: 'email_passthru.fail.expired', id: 'email_passthru.fail.expired',
defaultMessage: 'Your email token has expired.', defaultMessage: 'Your email token has expired.',
}); });
setStatus(Statuses.TOKEN_EXPIRED); setStatus(Statuses.TOKEN_EXPIRED);
break; break;
case 'token_not_found': case 'token_not_found':
message = intl.formatMessage({ message = intl.formatMessage({
id: 'email_passthru.fail.not_found', id: 'email_passthru.fail.not_found',
defaultMessage: 'Your email token is invalid.', defaultMessage: 'Your email token is invalid.',
}); });
message = 'Your token is invalid'; message = 'Your token is invalid';
setStatus(Statuses.TOKEN_NOT_FOUND); setStatus(Statuses.TOKEN_NOT_FOUND);
break; break;
default: default:
setStatus(Statuses.GENERIC_FAIL); setStatus(Statuses.GENERIC_FAIL);
break; break;
} }
} }
@ -142,16 +142,16 @@ const EmailPassThru = ({ match }) => {
}, [token]); }, [token]);
switch (status) { switch (status) {
case Statuses.SUCCESS: case Statuses.SUCCESS:
return <Success />; return <Success />;
case Statuses.TOKEN_EXPIRED: case Statuses.TOKEN_EXPIRED:
return <TokenExpired />; return <TokenExpired />;
case Statuses.TOKEN_NOT_FOUND: case Statuses.TOKEN_NOT_FOUND:
return <TokenNotFound />; return <TokenNotFound />;
case Statuses.GENERIC_FAIL: case Statuses.GENERIC_FAIL:
return <GenericFail />; return <GenericFail />;
default: default:
return <Spinner />; return <Spinner />;
} }
}; };

View File

@ -290,42 +290,42 @@ class Video extends React.PureComponent {
handleKeyDown = e => { handleKeyDown = e => {
const frameTime = 1 / 25; const frameTime = 1 / 25;
switch(e.key) { switch (e.key) {
case 'k': case 'k':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.togglePlay(); this.togglePlay();
break; break;
case 'm': case 'm':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.toggleMute(); this.toggleMute();
break; break;
case 'f': case 'f':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.toggleFullscreen(); this.toggleFullscreen();
break; break;
case 'j': case 'j':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.seekBy(-10); this.seekBy(-10);
break; break;
case 'l': case 'l':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.seekBy(10); this.seekBy(10);
break; break;
case ',': case ',':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.seekBy(-frameTime); this.seekBy(-frameTime);
break; break;
case '.': case '.':
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
this.seekBy(frameTime); this.seekBy(frameTime);
break; break;
} }
// If we are in fullscreen mode, we don't want any hotkeys // If we are in fullscreen mode, we don't want any hotkeys
@ -505,7 +505,7 @@ class Video extends React.PureComponent {
if (inline && containerWidth) { if (inline && containerWidth) {
width = containerWidth; width = containerWidth;
const minSize = containerWidth / (16/9); const minSize = containerWidth / (16 / 9);
if (isPanoramic(aspectRatio)) { if (isPanoramic(aspectRatio)) {
height = Math.max(Math.floor(containerWidth / maximumAspectRatio), minSize); height = Math.max(Math.floor(containerWidth / maximumAspectRatio), minSize);

View File

@ -23,20 +23,20 @@ type State = ReturnType<typeof ReducerRecord>;
export default function account_notes(state: State = ReducerRecord(), action: AnyAction) { export default function account_notes(state: State = ReducerRecord(), action: AnyAction) {
switch (action.type) { switch (action.type) {
case ACCOUNT_NOTE_INIT_MODAL: case ACCOUNT_NOTE_INIT_MODAL:
return state.withMutations((state) => { return state.withMutations((state) => {
state.setIn(['edit', 'isSubmitting'], false); state.setIn(['edit', 'isSubmitting'], false);
state.setIn(['edit', 'account_id'], action.account.get('id')); state.setIn(['edit', 'account_id'], action.account.get('id'));
state.setIn(['edit', 'comment'], action.comment); state.setIn(['edit', 'comment'], action.comment);
}); });
case ACCOUNT_NOTE_CHANGE_COMMENT: case ACCOUNT_NOTE_CHANGE_COMMENT:
return state.setIn(['edit', 'comment'], action.comment); return state.setIn(['edit', 'comment'], action.comment);
case ACCOUNT_NOTE_SUBMIT_REQUEST: case ACCOUNT_NOTE_SUBMIT_REQUEST:
return state.setIn(['edit', 'isSubmitting'], true); return state.setIn(['edit', 'isSubmitting'], true);
case ACCOUNT_NOTE_SUBMIT_FAIL: case ACCOUNT_NOTE_SUBMIT_FAIL:
case ACCOUNT_NOTE_SUBMIT_SUCCESS: case ACCOUNT_NOTE_SUBMIT_SUCCESS:
return state.setIn(['edit', 'isSubmitting'], false); return state.setIn(['edit', 'isSubmitting'], false);
default: default:
return state; return state;
} }
} }

View File

@ -93,13 +93,13 @@ const addTags = (
); );
tags.forEach(tag => { tags.forEach(tag => {
switch(tag) { switch (tag) {
case 'verified': case 'verified':
state.setIn([id, 'verified'], true); state.setIn([id, 'verified'], true);
break; break;
case 'donor': case 'donor':
state.setIn([id, 'donor'], true); state.setIn([id, 'donor'], true);
break; break;
} }
}); });
}); });
@ -118,13 +118,13 @@ const removeTags = (
); );
tags.forEach(tag => { tags.forEach(tag => {
switch(tag) { switch (tag) {
case 'verified': case 'verified':
state.setIn([id, 'verified'], false); state.setIn([id, 'verified'], false);
break; break;
case 'donor': case 'donor':
state.setIn([id, 'donor'], false); state.setIn([id, 'donor'], false);
break; break;
} }
}); });
}); });
@ -243,50 +243,50 @@ const setSuggested = (state: State, accountIds: Array<string>, isSuggested: bool
}; };
export default function accounts(state: State = initialState, action: AnyAction): State { export default function accounts(state: State = initialState, action: AnyAction): State {
switch(action.type) { switch (action.type) {
case ACCOUNT_IMPORT: case ACCOUNT_IMPORT:
return fixAccount(state, action.account); return fixAccount(state, action.account);
case ACCOUNTS_IMPORT: case ACCOUNTS_IMPORT:
return normalizeAccounts(state, action.accounts); return normalizeAccounts(state, action.accounts);
case ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP: case ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP:
return fixAccount(state, { id: -1, username: action.username }); return fixAccount(state, { id: -1, username: action.username });
case CHATS_FETCH_SUCCESS: case CHATS_FETCH_SUCCESS:
case CHATS_EXPAND_SUCCESS: case CHATS_EXPAND_SUCCESS:
return importAccountsFromChats(state, action.chats); return importAccountsFromChats(state, action.chats);
case CHAT_FETCH_SUCCESS: case CHAT_FETCH_SUCCESS:
case STREAMING_CHAT_UPDATE: case STREAMING_CHAT_UPDATE:
return importAccountsFromChats(state, [action.chat]); return importAccountsFromChats(state, [action.chat]);
case ADMIN_USERS_TAG_REQUEST: case ADMIN_USERS_TAG_REQUEST:
case ADMIN_USERS_TAG_SUCCESS: case ADMIN_USERS_TAG_SUCCESS:
case ADMIN_USERS_UNTAG_FAIL: case ADMIN_USERS_UNTAG_FAIL:
return addTags(state, action.accountIds, action.tags); return addTags(state, action.accountIds, action.tags);
case ADMIN_USERS_UNTAG_REQUEST: case ADMIN_USERS_UNTAG_REQUEST:
case ADMIN_USERS_UNTAG_SUCCESS: case ADMIN_USERS_UNTAG_SUCCESS:
case ADMIN_USERS_TAG_FAIL: case ADMIN_USERS_TAG_FAIL:
return removeTags(state, action.accountIds, action.tags); return removeTags(state, action.accountIds, action.tags);
case ADMIN_ADD_PERMISSION_GROUP_REQUEST: case ADMIN_ADD_PERMISSION_GROUP_REQUEST:
case ADMIN_ADD_PERMISSION_GROUP_SUCCESS: case ADMIN_ADD_PERMISSION_GROUP_SUCCESS:
case ADMIN_REMOVE_PERMISSION_GROUP_FAIL: case ADMIN_REMOVE_PERMISSION_GROUP_FAIL:
return addPermission(state, action.accountIds, action.permissionGroup); return addPermission(state, action.accountIds, action.permissionGroup);
case ADMIN_REMOVE_PERMISSION_GROUP_REQUEST: case ADMIN_REMOVE_PERMISSION_GROUP_REQUEST:
case ADMIN_REMOVE_PERMISSION_GROUP_SUCCESS: case ADMIN_REMOVE_PERMISSION_GROUP_SUCCESS:
case ADMIN_ADD_PERMISSION_GROUP_FAIL: case ADMIN_ADD_PERMISSION_GROUP_FAIL:
return removePermission(state, action.accountIds, action.permissionGroup); return removePermission(state, action.accountIds, action.permissionGroup);
case ADMIN_USERS_DELETE_REQUEST: case ADMIN_USERS_DELETE_REQUEST:
case ADMIN_USERS_DEACTIVATE_REQUEST: case ADMIN_USERS_DEACTIVATE_REQUEST:
return setActive(state, action.accountIds, false); return setActive(state, action.accountIds, false);
case ADMIN_USERS_DELETE_FAIL: case ADMIN_USERS_DELETE_FAIL:
case ADMIN_USERS_DEACTIVATE_FAIL: case ADMIN_USERS_DEACTIVATE_FAIL:
return setActive(state, action.accountIds, true); return setActive(state, action.accountIds, true);
case ADMIN_USERS_FETCH_SUCCESS: case ADMIN_USERS_FETCH_SUCCESS:
return importAdminUsers(state, action.users); return importAdminUsers(state, action.users);
case ADMIN_USERS_SUGGEST_REQUEST: case ADMIN_USERS_SUGGEST_REQUEST:
case ADMIN_USERS_UNSUGGEST_FAIL: case ADMIN_USERS_UNSUGGEST_FAIL:
return setSuggested(state, action.accountIds, true); return setSuggested(state, action.accountIds, true);
case ADMIN_USERS_UNSUGGEST_REQUEST: case ADMIN_USERS_UNSUGGEST_REQUEST:
case ADMIN_USERS_SUGGEST_FAIL: case ADMIN_USERS_SUGGEST_FAIL:
return setSuggested(state, action.accountIds, false); return setSuggested(state, action.accountIds, false);
default: default:
return state; return state;
} }
} }

View File

@ -36,19 +36,19 @@ const updateFollowCounters = (state, counterUpdates) => {
const initialState = ImmutableMap(); const initialState = ImmutableMap();
export default function accountsCounters(state = initialState, action) { export default function accountsCounters(state = initialState, action) {
switch(action.type) { switch (action.type) {
case ACCOUNT_IMPORT: case ACCOUNT_IMPORT:
return normalizeAccount(state, action.account); return normalizeAccount(state, action.account);
case ACCOUNTS_IMPORT: case ACCOUNTS_IMPORT:
return normalizeAccounts(state, action.accounts); return normalizeAccounts(state, action.accounts);
case ACCOUNT_FOLLOW_SUCCESS: case ACCOUNT_FOLLOW_SUCCESS:
return action.alreadyFollowing ? state : return action.alreadyFollowing ? state :
state.updateIn([action.relationship.id, 'followers_count'], num => num + 1); state.updateIn([action.relationship.id, 'followers_count'], num => num + 1);
case ACCOUNT_UNFOLLOW_SUCCESS: case ACCOUNT_UNFOLLOW_SUCCESS:
return state.updateIn([action.relationship.id, 'followers_count'], num => Math.max(0, num - 1)); return state.updateIn([action.relationship.id, 'followers_count'], num => Math.max(0, num - 1));
case STREAMING_FOLLOW_RELATIONSHIPS_UPDATE: case STREAMING_FOLLOW_RELATIONSHIPS_UPDATE:
return updateFollowCounters(state, [action.follower, action.following]); return updateFollowCounters(state, [action.follower, action.following]);
default: default:
return state; return state;
} }
} }

View File

@ -20,14 +20,14 @@ const importAccount = (state, account) => {
}; };
export default function accounts_meta(state = initialState, action) { export default function accounts_meta(state = initialState, action) {
switch(action.type) { switch (action.type) {
case ME_FETCH_SUCCESS: case ME_FETCH_SUCCESS:
case ME_PATCH_SUCCESS: case ME_PATCH_SUCCESS:
return importAccount(state, fromJS(action.me)); return importAccount(state, fromJS(action.me));
case VERIFY_CREDENTIALS_SUCCESS: case VERIFY_CREDENTIALS_SUCCESS:
case AUTH_ACCOUNT_REMEMBER_SUCCESS: case AUTH_ACCOUNT_REMEMBER_SUCCESS:
return importAccount(state, fromJS(action.account)); return importAccount(state, fromJS(action.account));
default: default:
return state; return state;
} }
} }

View File

@ -137,12 +137,12 @@ function handleReportDiffs(state: State, reports: APIReport[]) {
// hence the need for a new function. // hence the need for a new function.
return state.withMutations(state => { return state.withMutations(state => {
reports.forEach(report => { reports.forEach(report => {
switch(report.state) { switch (report.state) {
case 'open': case 'open':
state.update('openReports', orderedSet => orderedSet.add(report.id)); state.update('openReports', orderedSet => orderedSet.add(report.id));
break; break;
default: default:
state.update('openReports', orderedSet => orderedSet.delete(report.id)); state.update('openReports', orderedSet => orderedSet.delete(report.id));
} }
}); });
}); });
@ -159,25 +159,25 @@ const importConfigs = (state: State, configs: any): State => {
}; };
export default function admin(state: State = ReducerRecord(), action: AnyAction): State { export default function admin(state: State = ReducerRecord(), action: AnyAction): State {
switch(action.type) { switch (action.type) {
case ADMIN_CONFIG_FETCH_SUCCESS: case ADMIN_CONFIG_FETCH_SUCCESS:
case ADMIN_CONFIG_UPDATE_SUCCESS: case ADMIN_CONFIG_UPDATE_SUCCESS:
return importConfigs(state, action.configs); return importConfigs(state, action.configs);
case ADMIN_REPORTS_FETCH_SUCCESS: case ADMIN_REPORTS_FETCH_SUCCESS:
return importReports(state, action.reports); return importReports(state, action.reports);
case ADMIN_REPORTS_PATCH_REQUEST: case ADMIN_REPORTS_PATCH_REQUEST:
case ADMIN_REPORTS_PATCH_SUCCESS: case ADMIN_REPORTS_PATCH_SUCCESS:
return handleReportDiffs(state, action.reports); return handleReportDiffs(state, action.reports);
case ADMIN_USERS_FETCH_SUCCESS: case ADMIN_USERS_FETCH_SUCCESS:
return importUsers(state, action.users, action.filters, action.page); return importUsers(state, action.users, action.filters, action.page);
case ADMIN_USERS_DELETE_REQUEST: case ADMIN_USERS_DELETE_REQUEST:
case ADMIN_USERS_DELETE_SUCCESS: case ADMIN_USERS_DELETE_SUCCESS:
return deleteUsers(state, action.accountIds); return deleteUsers(state, action.accountIds);
case ADMIN_USERS_APPROVE_REQUEST: case ADMIN_USERS_APPROVE_REQUEST:
return state.update('awaitingApproval', set => set.subtract(action.accountIds)); return state.update('awaitingApproval', set => set.subtract(action.accountIds));
case ADMIN_USERS_APPROVE_SUCCESS: case ADMIN_USERS_APPROVE_SUCCESS:
return approveUsers(state, action.users); return approveUsers(state, action.users);
default: default:
return state; return state;
} }
} }

View File

@ -36,10 +36,10 @@ const importItems = (state, items, total) => {
}; };
export default function admin_log(state = ReducerRecord(), action) { export default function admin_log(state = ReducerRecord(), action) {
switch(action.type) { switch (action.type) {
case ADMIN_LOG_FETCH_SUCCESS: case ADMIN_LOG_FETCH_SUCCESS:
return importItems(state, action.items, action.total); return importItems(state, action.items, action.total);
default: default:
return state; return state;
} }
} }

View File

@ -40,14 +40,14 @@ const deleteAlert = (state: State, alert: PlainAlert): State => {
}; };
export default function alerts(state: State = ImmutableList<Alert>(), action: AnyAction): State { export default function alerts(state: State = ImmutableList<Alert>(), action: AnyAction): State {
switch(action.type) { switch (action.type) {
case ALERT_SHOW: case ALERT_SHOW:
return importAlert(state, action); return importAlert(state, action);
case ALERT_DISMISS: case ALERT_DISMISS:
return deleteAlert(state, action.alert); return deleteAlert(state, action.alert);
case ALERT_CLEAR: case ALERT_CLEAR:
return state.clear(); return state.clear();
default: default:
return state; return state;
} }
} }

View File

@ -20,25 +20,25 @@ const initialState = ImmutableMap({
}); });
export default function aliasesReducer(state = initialState, action) { export default function aliasesReducer(state = initialState, action) {
switch(action.type) { switch (action.type) {
case ALIASES_FETCH_SUCCESS: case ALIASES_FETCH_SUCCESS:
return state return state
.setIn(['aliases', 'items'], action.value); .setIn(['aliases', 'items'], action.value);
case ALIASES_SUGGESTIONS_CHANGE: case ALIASES_SUGGESTIONS_CHANGE:
return state return state
.setIn(['suggestions', 'value'], action.value) .setIn(['suggestions', 'value'], action.value)
.setIn(['suggestions', 'loaded'], false); .setIn(['suggestions', 'loaded'], false);
case ALIASES_SUGGESTIONS_READY: case ALIASES_SUGGESTIONS_READY:
return state return state
.setIn(['suggestions', 'items'], ImmutableList(action.accounts.map(item => item.id))) .setIn(['suggestions', 'items'], ImmutableList(action.accounts.map(item => item.id)))
.setIn(['suggestions', 'loaded'], true); .setIn(['suggestions', 'loaded'], true);
case ALIASES_SUGGESTIONS_CLEAR: case ALIASES_SUGGESTIONS_CLEAR:
return state.update('suggestions', suggestions => suggestions.withMutations(map => { return state.update('suggestions', suggestions => suggestions.withMutations(map => {
map.set('items', ImmutableList()); map.set('items', ImmutableList());
map.set('value', ''); map.set('value', '');
map.set('loaded', false); map.set('loaded', false);
})); }));
default: default:
return state; return state;
} }
} }

View File

@ -282,28 +282,28 @@ const deleteForbiddenToken = (state, error, token) => {
}; };
const reducer = (state, action) => { const reducer = (state, action) => {
switch(action.type) { switch (action.type) {
case AUTH_APP_CREATED: case AUTH_APP_CREATED:
return state.set('app', fromJS(action.app)); return state.set('app', fromJS(action.app));
case AUTH_APP_AUTHORIZED: case AUTH_APP_AUTHORIZED:
return state.update('app', ImmutableMap(), app => app.merge(fromJS(action.token))); return state.update('app', ImmutableMap(), app => app.merge(fromJS(action.token)));
case AUTH_LOGGED_IN: case AUTH_LOGGED_IN:
return importToken(state, action.token); return importToken(state, action.token);
case AUTH_LOGGED_OUT: case AUTH_LOGGED_OUT:
return deleteUser(state, action.account); return deleteUser(state, action.account);
case VERIFY_CREDENTIALS_SUCCESS: case VERIFY_CREDENTIALS_SUCCESS:
persistAuthAccount(action.account); persistAuthAccount(action.account);
return importCredentials(state, action.token, action.account); return importCredentials(state, action.token, action.account);
case VERIFY_CREDENTIALS_FAIL: case VERIFY_CREDENTIALS_FAIL:
return deleteForbiddenToken(state, action.error, action.token); return deleteForbiddenToken(state, action.error, action.token);
case SWITCH_ACCOUNT: case SWITCH_ACCOUNT:
return state.set('me', action.account.get('url')); return state.set('me', action.account.get('url'));
case ME_FETCH_SKIP: case ME_FETCH_SKIP:
return state.set('me', null); return state.set('me', null);
case MASTODON_PRELOAD_IMPORT: case MASTODON_PRELOAD_IMPORT:
return importMastodonPreload(state, fromJS(action.data)); return importMastodonPreload(state, fromJS(action.data));
default: default:
return state; return state;
} }
}; };

View File

@ -18,11 +18,11 @@ const importBackups = (state, backups) => {
}; };
export default function backups(state = initialState, action) { export default function backups(state = initialState, action) {
switch(action.type) { switch (action.type) {
case BACKUPS_FETCH_SUCCESS: case BACKUPS_FETCH_SUCCESS:
case BACKUPS_CREATE_SUCCESS: case BACKUPS_CREATE_SUCCESS:
return importBackups(state, fromJS(action.backups)); return importBackups(state, fromJS(action.backups));
default: default:
return state; return state;
} }
} }

View File

@ -51,25 +51,25 @@ const replaceMessage = (state: State, chatId: string, oldId: string, newId: stri
}; };
export default function chatMessageLists(state = initialState, action: AnyAction) { export default function chatMessageLists(state = initialState, action: AnyAction) {
switch(action.type) { switch (action.type) {
case CHAT_MESSAGE_SEND_REQUEST: case CHAT_MESSAGE_SEND_REQUEST:
return updateList(state, action.chatId, [action.uuid]); return updateList(state, action.chatId, [action.uuid]);
case CHATS_FETCH_SUCCESS: case CHATS_FETCH_SUCCESS:
case CHATS_EXPAND_SUCCESS: case CHATS_EXPAND_SUCCESS:
return importLastMessages(state, action.chats); return importLastMessages(state, action.chats);
case STREAMING_CHAT_UPDATE: case STREAMING_CHAT_UPDATE:
if (action.chat.last_message && if (action.chat.last_message &&
action.chat.last_message.account_id !== action.me) action.chat.last_message.account_id !== action.me)
return importMessages(state, [action.chat.last_message]); return importMessages(state, [action.chat.last_message]);
else else
return state;
case CHAT_MESSAGES_FETCH_SUCCESS:
return updateList(state, action.chatId, action.chatMessages.map((chat: APIEntity) => chat.id));
case CHAT_MESSAGE_SEND_SUCCESS:
return replaceMessage(state, action.chatId, action.uuid, action.chatMessage.id);
case CHAT_MESSAGE_DELETE_SUCCESS:
return state.update(action.chatId, chat => chat!.delete(action.messageId));
default:
return state; return state;
case CHAT_MESSAGES_FETCH_SUCCESS:
return updateList(state, action.chatId, action.chatMessages.map((chat: APIEntity) => chat.id));
case CHAT_MESSAGE_SEND_SUCCESS:
return replaceMessage(state, action.chatId, action.uuid, action.chatMessage.id);
case CHAT_MESSAGE_DELETE_SUCCESS:
return state.update(action.chatId, chat => chat!.delete(action.messageId));
default:
return state;
} }
} }

View File

@ -37,31 +37,31 @@ const importLastMessages = (state: State, chats: APIEntities) =>
const initialState: State = ImmutableMap(); const initialState: State = ImmutableMap();
export default function chatMessages(state = initialState, action: AnyAction) { export default function chatMessages(state = initialState, action: AnyAction) {
switch(action.type) { switch (action.type) {
case CHAT_MESSAGE_SEND_REQUEST: case CHAT_MESSAGE_SEND_REQUEST:
return importMessage(state, fromJS({ return importMessage(state, fromJS({
id: action.uuid, // Make fake message to get overriden later id: action.uuid, // Make fake message to get overriden later
chat_id: action.chatId, chat_id: action.chatId,
account_id: action.me, account_id: action.me,
content: action.params.content, content: action.params.content,
created_at: (new Date()).toISOString(), created_at: (new Date()).toISOString(),
pending: true, pending: true,
})); }));
case CHATS_FETCH_SUCCESS: case CHATS_FETCH_SUCCESS:
case CHATS_EXPAND_SUCCESS: case CHATS_EXPAND_SUCCESS:
return importLastMessages(state, action.chats); return importLastMessages(state, action.chats);
case CHAT_MESSAGES_FETCH_SUCCESS: case CHAT_MESSAGES_FETCH_SUCCESS:
return importMessages(state, action.chatMessages); return importMessages(state, action.chatMessages);
case CHAT_MESSAGE_SEND_SUCCESS: case CHAT_MESSAGE_SEND_SUCCESS:
return importMessage(state, fromJS(action.chatMessage)).delete(action.uuid); return importMessage(state, fromJS(action.chatMessage)).delete(action.uuid);
case STREAMING_CHAT_UPDATE: case STREAMING_CHAT_UPDATE:
return importLastMessages(state, [action.chat]); return importLastMessages(state, [action.chat]);
case CHAT_MESSAGE_DELETE_REQUEST: case CHAT_MESSAGE_DELETE_REQUEST:
return state.update(action.messageId, chatMessage => return state.update(action.messageId, chatMessage =>
chatMessage!.set('pending', true).set('deleting', true)); chatMessage!.set('pending', true).set('deleting', true));
case CHAT_MESSAGE_DELETE_SUCCESS: case CHAT_MESSAGE_DELETE_SUCCESS:
return state.delete(action.messageId); return state.delete(action.messageId);
default: default:
return state; return state;
} }
} }

View File

@ -55,22 +55,22 @@ const importChats = (state: State, chats: APIEntities, next?: string) =>
}); });
export default function chats(state: State = ReducerRecord(), action: AnyAction): State { export default function chats(state: State = ReducerRecord(), action: AnyAction): State {
switch(action.type) { switch (action.type) {
case CHATS_FETCH_REQUEST: case CHATS_FETCH_REQUEST:
case CHATS_EXPAND_REQUEST: case CHATS_EXPAND_REQUEST:
return state.set('isLoading', true); return state.set('isLoading', true);
case CHATS_FETCH_SUCCESS: case CHATS_FETCH_SUCCESS:
case CHATS_EXPAND_SUCCESS: case CHATS_EXPAND_SUCCESS:
return importChats(state, action.chats, action.next); return importChats(state, action.chats, action.next);
case STREAMING_CHAT_UPDATE: case STREAMING_CHAT_UPDATE:
return importChats(state, [action.chat]); return importChats(state, [action.chat]);
case CHAT_FETCH_SUCCESS: case CHAT_FETCH_SUCCESS:
return importChats(state, [action.chat]); return importChats(state, [action.chat]);
case CHAT_READ_REQUEST: case CHAT_READ_REQUEST:
return state.setIn([action.chatId, 'unread'], 0); return state.setIn([action.chatId, 'unread'], 0);
case CHAT_READ_SUCCESS: case CHAT_READ_SUCCESS:
return importChats(state, [action.chat]); return importChats(state, [action.chat]);
default: default:
return state; return state;
} }
} }

View File

@ -273,223 +273,223 @@ const updateAccount = (state, account) => {
const updateSetting = (state, path, value) => { const updateSetting = (state, path, value) => {
const pathString = path.join(','); const pathString = path.join(',');
switch (pathString) { switch (pathString) {
case 'defaultPrivacy': case 'defaultPrivacy':
return state.set('default_privacy', value).set('privacy', value); return state.set('default_privacy', value).set('privacy', value);
case 'defaultContentType': case 'defaultContentType':
return state.set('default_content_type', value).set('content_type', value); return state.set('default_content_type', value).set('content_type', value);
default: default:
return state; return state;
} }
}; };
export default function compose(state = initialState, action) { export default function compose(state = initialState, action) {
switch(action.type) { switch (action.type) {
case COMPOSE_MOUNT: case COMPOSE_MOUNT:
return state.set('mounted', state.get('mounted') + 1); return state.set('mounted', state.get('mounted') + 1);
case COMPOSE_UNMOUNT: case COMPOSE_UNMOUNT:
return state return state
.set('mounted', Math.max(state.get('mounted') - 1, 0)) .set('mounted', Math.max(state.get('mounted') - 1, 0))
.set('is_composing', false); .set('is_composing', false);
case COMPOSE_SENSITIVITY_CHANGE: case COMPOSE_SENSITIVITY_CHANGE:
return state.withMutations(map => { return state.withMutations(map => {
if (!state.get('spoiler')) { if (!state.get('spoiler')) {
map.set('sensitive', !state.get('sensitive')); map.set('sensitive', !state.get('sensitive'));
}
map.set('idempotencyKey', uuid());
});
case COMPOSE_TYPE_CHANGE:
return state.withMutations(map => {
map.set('content_type', action.value);
map.set('idempotencyKey', uuid());
});
case COMPOSE_SPOILERNESS_CHANGE:
return state.withMutations(map => {
map.set('spoiler_text', '');
map.set('spoiler', !state.get('spoiler'));
map.set('idempotencyKey', uuid());
if (!state.get('sensitive') && state.get('media_attachments').size >= 1) {
map.set('sensitive', true);
}
});
case COMPOSE_SPOILER_TEXT_CHANGE:
return state
.set('spoiler_text', action.text)
.set('idempotencyKey', uuid());
case COMPOSE_VISIBILITY_CHANGE:
return state
.set('privacy', action.value)
.set('idempotencyKey', uuid());
case COMPOSE_CHANGE:
return state
.set('text', action.text)
.set('idempotencyKey', uuid());
case COMPOSE_COMPOSING_CHANGE:
return state.set('is_composing', action.value);
case COMPOSE_REPLY:
return state.withMutations(map => {
map.set('in_reply_to', action.status.get('id'));
map.set('to', action.explicitAddressing ? statusToMentionsArray(action.status, action.account) : ImmutableOrderedSet());
map.set('text', !action.explicitAddressing ? statusToTextMentions(state, action.status, action.account) : '');
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('idempotencyKey', uuid());
map.set('content_type', state.get('default_content_type'));
if (action.status.get('spoiler_text', '').length > 0) {
map.set('spoiler', true);
map.set('spoiler_text', action.status.get('spoiler_text'));
} else {
map.set('spoiler', false);
map.set('spoiler_text', '');
}
});
case COMPOSE_QUOTE:
return state.withMutations(map => {
map.set('quote', action.status.get('id'));
map.set('to', undefined);
map.set('text', '');
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('idempotencyKey', uuid());
map.set('content_type', state.get('default_content_type'));
map.set('spoiler', false);
map.set('spoiler_text', '');
});
case COMPOSE_SUBMIT_REQUEST:
return state.set('is_submitting', true);
case COMPOSE_UPLOAD_CHANGE_REQUEST:
return state.set('is_changing_upload', true);
case COMPOSE_REPLY_CANCEL:
case COMPOSE_QUOTE_CANCEL:
case COMPOSE_RESET:
case COMPOSE_SUBMIT_SUCCESS:
return clearAll(state);
case COMPOSE_SUBMIT_FAIL:
return state.set('is_submitting', false);
case COMPOSE_UPLOAD_CHANGE_FAIL:
return state.set('is_changing_upload', false);
case COMPOSE_UPLOAD_REQUEST:
return state.set('is_uploading', true);
case COMPOSE_UPLOAD_SUCCESS:
return appendMedia(state, fromJS(action.media));
case COMPOSE_UPLOAD_FAIL:
return state.set('is_uploading', false);
case COMPOSE_UPLOAD_UNDO:
return removeMedia(state, action.media_id);
case COMPOSE_UPLOAD_PROGRESS:
return state.set('progress', Math.round((action.loaded / action.total) * 100));
case COMPOSE_MENTION:
return state.withMutations(map => {
map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' '));
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('idempotencyKey', uuid());
});
case COMPOSE_DIRECT:
return state.withMutations(map => {
map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' '));
map.set('privacy', 'direct');
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('idempotencyKey', uuid());
});
case COMPOSE_SUGGESTIONS_CLEAR:
return state.update('suggestions', ImmutableList(), list => list.clear()).set('suggestion_token', null);
case COMPOSE_SUGGESTIONS_READY:
return state.set('suggestions', ImmutableList(action.accounts ? action.accounts.map(item => item.id) : action.emojis)).set('suggestion_token', action.token);
case COMPOSE_SUGGESTION_SELECT:
return insertSuggestion(state, action.position, action.token, action.completion, action.path);
case COMPOSE_SUGGESTION_TAGS_UPDATE:
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} if (action.id === state.get('quote')) {
return state.set('quote', null);
} else {
return state;
}
case COMPOSE_EMOJI_INSERT:
return insertEmoji(state, action.position, action.emoji, action.needsSpace);
case COMPOSE_UPLOAD_CHANGE_SUCCESS:
return state
.set('is_changing_upload', false)
.update('media_attachments', list => list.map(item => {
if (item.get('id') === action.media.id) {
return fromJS(action.media);
} }
return item; map.set('idempotencyKey', uuid());
})); });
case COMPOSE_SET_STATUS: case COMPOSE_TYPE_CHANGE:
return state.withMutations(map => { return state.withMutations(map => {
map.set('id', action.status.get('id')); map.set('content_type', action.value);
map.set('text', action.rawText || unescapeHTML(expandMentions(action.status))); map.set('idempotencyKey', uuid());
map.set('to', action.explicitAddressing ? getExplicitMentions(action.status.get('account', 'id'), action.status) : ImmutableOrderedSet()); });
map.set('in_reply_to', action.status.get('in_reply_to_id')); case COMPOSE_SPOILERNESS_CHANGE:
map.set('privacy', action.status.get('visibility')); return state.withMutations(map => {
map.set('focusDate', new Date()); map.set('spoiler_text', '');
map.set('caretPosition', null); map.set('spoiler', !state.get('spoiler'));
map.set('idempotencyKey', uuid()); map.set('idempotencyKey', uuid());
map.set('content_type', action.contentType || 'text/plain');
if (action.v?.software === PLEROMA && hasIntegerMediaIds(action.status)) { if (!state.get('sensitive') && state.get('media_attachments').size >= 1) {
map.set('media_attachments', ImmutableList()); map.set('sensitive', true);
} else { }
map.set('media_attachments', action.status.get('media_attachments')); });
} case COMPOSE_SPOILER_TEXT_CHANGE:
return state
.set('spoiler_text', action.text)
.set('idempotencyKey', uuid());
case COMPOSE_VISIBILITY_CHANGE:
return state
.set('privacy', action.value)
.set('idempotencyKey', uuid());
case COMPOSE_CHANGE:
return state
.set('text', action.text)
.set('idempotencyKey', uuid());
case COMPOSE_COMPOSING_CHANGE:
return state.set('is_composing', action.value);
case COMPOSE_REPLY:
return state.withMutations(map => {
map.set('in_reply_to', action.status.get('id'));
map.set('to', action.explicitAddressing ? statusToMentionsArray(action.status, action.account) : ImmutableOrderedSet());
map.set('text', !action.explicitAddressing ? statusToTextMentions(state, action.status, action.account) : '');
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('idempotencyKey', uuid());
map.set('content_type', state.get('default_content_type'));
if (action.status.get('spoiler_text').length > 0) { if (action.status.get('spoiler_text', '').length > 0) {
map.set('spoiler', true); map.set('spoiler', true);
map.set('spoiler_text', action.status.get('spoiler_text')); map.set('spoiler_text', action.status.get('spoiler_text'));
} else { } else {
map.set('spoiler', false);
map.set('spoiler_text', '');
}
});
case COMPOSE_QUOTE:
return state.withMutations(map => {
map.set('quote', action.status.get('id'));
map.set('to', undefined);
map.set('text', '');
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('idempotencyKey', uuid());
map.set('content_type', state.get('default_content_type'));
map.set('spoiler', false); map.set('spoiler', false);
map.set('spoiler_text', ''); map.set('spoiler_text', '');
});
case COMPOSE_SUBMIT_REQUEST:
return state.set('is_submitting', true);
case COMPOSE_UPLOAD_CHANGE_REQUEST:
return state.set('is_changing_upload', true);
case COMPOSE_REPLY_CANCEL:
case COMPOSE_QUOTE_CANCEL:
case COMPOSE_RESET:
case COMPOSE_SUBMIT_SUCCESS:
return clearAll(state);
case COMPOSE_SUBMIT_FAIL:
return state.set('is_submitting', false);
case COMPOSE_UPLOAD_CHANGE_FAIL:
return state.set('is_changing_upload', false);
case COMPOSE_UPLOAD_REQUEST:
return state.set('is_uploading', true);
case COMPOSE_UPLOAD_SUCCESS:
return appendMedia(state, fromJS(action.media));
case COMPOSE_UPLOAD_FAIL:
return state.set('is_uploading', false);
case COMPOSE_UPLOAD_UNDO:
return removeMedia(state, action.media_id);
case COMPOSE_UPLOAD_PROGRESS:
return state.set('progress', Math.round((action.loaded / action.total) * 100));
case COMPOSE_MENTION:
return state.withMutations(map => {
map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' '));
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('idempotencyKey', uuid());
});
case COMPOSE_DIRECT:
return state.withMutations(map => {
map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' '));
map.set('privacy', 'direct');
map.set('focusDate', new Date());
map.set('caretPosition', null);
map.set('idempotencyKey', uuid());
});
case COMPOSE_SUGGESTIONS_CLEAR:
return state.update('suggestions', ImmutableList(), list => list.clear()).set('suggestion_token', null);
case COMPOSE_SUGGESTIONS_READY:
return state.set('suggestions', ImmutableList(action.accounts ? action.accounts.map(item => item.id) : action.emojis)).set('suggestion_token', action.token);
case COMPOSE_SUGGESTION_SELECT:
return insertSuggestion(state, action.position, action.token, action.completion, action.path);
case COMPOSE_SUGGESTION_TAGS_UPDATE:
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} if (action.id === state.get('quote')) {
return state.set('quote', null);
} else {
return state;
} }
case COMPOSE_EMOJI_INSERT:
return insertEmoji(state, action.position, action.emoji, action.needsSpace);
case COMPOSE_UPLOAD_CHANGE_SUCCESS:
return state
.set('is_changing_upload', false)
.update('media_attachments', list => list.map(item => {
if (item.get('id') === action.media.id) {
return fromJS(action.media);
}
if (action.status.get('poll')) { return item;
map.set('poll', ImmutableMap({
options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
multiple: action.status.getIn(['poll', 'multiple']),
expires_in: 24 * 3600,
})); }));
} case COMPOSE_SET_STATUS:
}); return state.withMutations(map => {
case COMPOSE_POLL_ADD: map.set('id', action.status.get('id'));
return state.set('poll', initialPoll); map.set('text', action.rawText || unescapeHTML(expandMentions(action.status)));
case COMPOSE_POLL_REMOVE: map.set('to', action.explicitAddressing ? getExplicitMentions(action.status.get('account', 'id'), action.status) : ImmutableOrderedSet());
return state.set('poll', null); map.set('in_reply_to', action.status.get('in_reply_to_id'));
case COMPOSE_SCHEDULE_ADD: map.set('privacy', action.status.get('visibility'));
return state.set('schedule', new Date()); map.set('focusDate', new Date());
case COMPOSE_SCHEDULE_SET: map.set('caretPosition', null);
return state.set('schedule', action.date); map.set('idempotencyKey', uuid());
case COMPOSE_SCHEDULE_REMOVE: map.set('content_type', action.contentType || 'text/plain');
return state.set('schedule', null);
case COMPOSE_POLL_OPTION_ADD: if (action.v?.software === PLEROMA && hasIntegerMediaIds(action.status)) {
return state.updateIn(['poll', 'options'], options => options.push(action.title)); map.set('media_attachments', ImmutableList());
case COMPOSE_POLL_OPTION_CHANGE: } else {
return state.setIn(['poll', 'options', action.index], action.title); map.set('media_attachments', action.status.get('media_attachments'));
case COMPOSE_POLL_OPTION_REMOVE: }
return state.updateIn(['poll', 'options'], options => options.delete(action.index));
case COMPOSE_POLL_SETTINGS_CHANGE: if (action.status.get('spoiler_text').length > 0) {
return state.update('poll', poll => poll.set('expires_in', action.expiresIn).set('multiple', action.isMultiple)); map.set('spoiler', true);
case COMPOSE_ADD_TO_MENTIONS: map.set('spoiler_text', action.status.get('spoiler_text'));
return state.update('to', mentions => mentions.add(action.account)); } else {
case COMPOSE_REMOVE_FROM_MENTIONS: map.set('spoiler', false);
return state.update('to', mentions => mentions.delete(action.account)); map.set('spoiler_text', '');
case ME_FETCH_SUCCESS: }
return importAccount(state, action.me);
case ME_PATCH_SUCCESS: if (action.status.get('poll')) {
return updateAccount(state, action.me); map.set('poll', ImmutableMap({
case SETTING_CHANGE: options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
return updateSetting(state, action.path, action.value); multiple: action.status.getIn(['poll', 'multiple']),
default: expires_in: 24 * 3600,
return state; }));
}
});
case COMPOSE_POLL_ADD:
return state.set('poll', initialPoll);
case COMPOSE_POLL_REMOVE:
return state.set('poll', null);
case COMPOSE_SCHEDULE_ADD:
return state.set('schedule', new Date());
case COMPOSE_SCHEDULE_SET:
return state.set('schedule', action.date);
case COMPOSE_SCHEDULE_REMOVE:
return state.set('schedule', null);
case COMPOSE_POLL_OPTION_ADD:
return state.updateIn(['poll', 'options'], options => options.push(action.title));
case COMPOSE_POLL_OPTION_CHANGE:
return state.setIn(['poll', 'options', action.index], action.title);
case COMPOSE_POLL_OPTION_REMOVE:
return state.updateIn(['poll', 'options'], options => options.delete(action.index));
case COMPOSE_POLL_SETTINGS_CHANGE:
return state.update('poll', poll => poll.set('expires_in', action.expiresIn).set('multiple', action.isMultiple));
case COMPOSE_ADD_TO_MENTIONS:
return state.update('to', mentions => mentions.add(action.account));
case COMPOSE_REMOVE_FROM_MENTIONS:
return state.update('to', mentions => mentions.delete(action.account));
case ME_FETCH_SUCCESS:
return importAccount(state, action.me);
case ME_PATCH_SUCCESS:
return updateAccount(state, action.me);
case SETTING_CHANGE:
return updateSetting(state, action.path, action.value);
default:
return state;
} }
} }

View File

@ -141,23 +141,23 @@ const deletePendingStatus = (state, { in_reply_to_id }, idempotencyKey) => {
}; };
export default function replies(state = initialState, action) { export default function replies(state = initialState, action) {
switch(action.type) { switch (action.type) {
case ACCOUNT_BLOCK_SUCCESS: case ACCOUNT_BLOCK_SUCCESS:
case ACCOUNT_MUTE_SUCCESS: case ACCOUNT_MUTE_SUCCESS:
return filterContexts(state, action.relationship, action.statuses); return filterContexts(state, action.relationship, action.statuses);
case CONTEXT_FETCH_SUCCESS: case CONTEXT_FETCH_SUCCESS:
return normalizeContext(state, action.id, action.ancestors, action.descendants); return normalizeContext(state, action.id, action.ancestors, action.descendants);
case TIMELINE_DELETE: case TIMELINE_DELETE:
return deleteStatuses(state, [action.id]); return deleteStatuses(state, [action.id]);
case STATUS_CREATE_REQUEST: case STATUS_CREATE_REQUEST:
return importPendingStatus(state, action.params, action.idempotencyKey); return importPendingStatus(state, action.params, action.idempotencyKey);
case STATUS_CREATE_SUCCESS: case STATUS_CREATE_SUCCESS:
return deletePendingStatus(state, action.status, action.idempotencyKey); return deletePendingStatus(state, action.status, action.idempotencyKey);
case STATUS_IMPORT: case STATUS_IMPORT:
return importStatus(state, action.status, action.idempotencyKey); return importStatus(state, action.status, action.idempotencyKey);
case STATUSES_IMPORT: case STATUSES_IMPORT:
return importStatuses(state, action.statuses); return importStatuses(state, action.statuses);
default: default:
return state; return state;
} }
} }

View File

@ -77,27 +77,27 @@ const expandNormalizedConversations = (state, conversations, next, isLoadingRece
export default function conversations(state = initialState, action) { export default function conversations(state = initialState, action) {
switch (action.type) { switch (action.type) {
case CONVERSATIONS_FETCH_REQUEST: case CONVERSATIONS_FETCH_REQUEST:
return state.set('isLoading', true); return state.set('isLoading', true);
case CONVERSATIONS_FETCH_FAIL: case CONVERSATIONS_FETCH_FAIL:
return state.set('isLoading', false); return state.set('isLoading', false);
case CONVERSATIONS_FETCH_SUCCESS: case CONVERSATIONS_FETCH_SUCCESS:
return expandNormalizedConversations(state, action.conversations, action.next, action.isLoadingRecent); return expandNormalizedConversations(state, action.conversations, action.next, action.isLoadingRecent);
case CONVERSATIONS_UPDATE: case CONVERSATIONS_UPDATE:
return updateConversation(state, action.conversation); return updateConversation(state, action.conversation);
case CONVERSATIONS_MOUNT: case CONVERSATIONS_MOUNT:
return state.update('mounted', count => count + 1); return state.update('mounted', count => count + 1);
case CONVERSATIONS_UNMOUNT: case CONVERSATIONS_UNMOUNT:
return state.update('mounted', count => count - 1); return state.update('mounted', count => count - 1);
case CONVERSATIONS_READ: case CONVERSATIONS_READ:
return state.update('items', list => list.map(item => { return state.update('items', list => list.map(item => {
if (item.get('id') === action.id) { if (item.get('id') === action.id) {
return item.set('unread', false); return item.set('unread', false);
} }
return item; return item;
})); }));
default: default:
return state; return state;
} }
} }

View File

@ -13,14 +13,14 @@ const initialState = ImmutableMap({
}); });
export default function domainLists(state = initialState, action) { export default function domainLists(state = initialState, action) {
switch(action.type) { switch (action.type) {
case DOMAIN_BLOCKS_FETCH_SUCCESS: case DOMAIN_BLOCKS_FETCH_SUCCESS:
return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.domains)).setIn(['blocks', 'next'], action.next); return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.domains)).setIn(['blocks', 'next'], action.next);
case DOMAIN_BLOCKS_EXPAND_SUCCESS: case DOMAIN_BLOCKS_EXPAND_SUCCESS:
return state.updateIn(['blocks', 'items'], set => set.union(action.domains)).setIn(['blocks', 'next'], action.next); return state.updateIn(['blocks', 'items'], set => set.union(action.domains)).setIn(['blocks', 'next'], action.next);
case DOMAIN_UNBLOCK_SUCCESS: case DOMAIN_UNBLOCK_SUCCESS:
return state.updateIn(['blocks', 'items'], set => set.delete(action.domain)); return state.updateIn(['blocks', 'items'], set => set.delete(action.domain));
default: default:
return state; return state;
} }
} }

View File

@ -9,11 +9,11 @@ const initialState = ImmutableMap({ openId: null, placement: null, keyboard: fal
export default function dropdownMenu(state = initialState, action) { export default function dropdownMenu(state = initialState, action) {
switch (action.type) { switch (action.type) {
case DROPDOWN_MENU_OPEN: case DROPDOWN_MENU_OPEN:
return state.merge({ openId: action.id, placement: action.placement, keyboard: action.keyboard }); return state.merge({ openId: action.id, placement: action.placement, keyboard: action.keyboard });
case DROPDOWN_MENU_CLOSE: case DROPDOWN_MENU_CLOSE:
return state.get('openId') === action.id ? state.set('openId', null) : state; return state.get('openId') === action.id ? state.set('openId', null) : state;
default: default:
return state; return state;
} }
} }

View File

@ -16,10 +16,10 @@ const importFilters = (_state: State, filters: unknown): State => {
}; };
export default function filters(state: State = ImmutableList<Filter>(), action: AnyAction): State { export default function filters(state: State = ImmutableList<Filter>(), action: AnyAction): State {
switch(action.type) { switch (action.type) {
case FILTERS_FETCH_SUCCESS: case FILTERS_FETCH_SUCCESS:
return importFilters(state, action.filters); return importFilters(state, action.filters);
default: default:
return state; return state;
} }
} }

View File

@ -22,37 +22,37 @@ const initialState = ImmutableMap({
}); });
export default function groupEditorReducer(state = initialState, action) { export default function groupEditorReducer(state = initialState, action) {
switch(action.type) { switch (action.type) {
case GROUP_EDITOR_RESET: case GROUP_EDITOR_RESET:
return initialState; return initialState;
case GROUP_EDITOR_SETUP: case GROUP_EDITOR_SETUP:
return state.withMutations(map => { return state.withMutations(map => {
map.set('groupId', action.group.get('id')); map.set('groupId', action.group.get('id'));
map.set('title', action.group.get('title')); map.set('title', action.group.get('title'));
map.set('description', action.group.get('description')); map.set('description', action.group.get('description'));
map.set('isSubmitting', false); map.set('isSubmitting', false);
}); });
case GROUP_EDITOR_VALUE_CHANGE: case GROUP_EDITOR_VALUE_CHANGE:
return state.withMutations(map => { return state.withMutations(map => {
map.set(action.field, action.value); map.set(action.field, action.value);
map.set('isChanged', true); map.set('isChanged', true);
}); });
case GROUP_CREATE_REQUEST: case GROUP_CREATE_REQUEST:
case GROUP_UPDATE_REQUEST: case GROUP_UPDATE_REQUEST:
return state.withMutations(map => { return state.withMutations(map => {
map.set('isSubmitting', true); map.set('isSubmitting', true);
map.set('isChanged', false); map.set('isChanged', false);
}); });
case GROUP_CREATE_FAIL: case GROUP_CREATE_FAIL:
case GROUP_UPDATE_FAIL: case GROUP_UPDATE_FAIL:
return state.set('isSubmitting', false); return state.set('isSubmitting', false);
case GROUP_CREATE_SUCCESS: case GROUP_CREATE_SUCCESS:
case GROUP_UPDATE_SUCCESS: case GROUP_UPDATE_SUCCESS:
return state.withMutations(map => { return state.withMutations(map => {
map.set('isSubmitting', false); map.set('isSubmitting', false);
map.set('groupId', action.group.id); map.set('groupId', action.group.id);
}); });
default: default:
return state; return state;
} }
} }

View File

@ -13,10 +13,10 @@ const normalizeList = (state, type, id, groups) => {
}; };
export default function groupLists(state = initialState, action) { export default function groupLists(state = initialState, action) {
switch(action.type) { switch (action.type) {
case GROUPS_FETCH_SUCCESS: case GROUPS_FETCH_SUCCESS:
return normalizeList(state, action.tab, action.id, action.groups); return normalizeList(state, action.tab, action.id, action.groups);
default: default:
return state; return state;
} }
} }

View File

@ -15,13 +15,13 @@ const normalizeRelationships = (state, relationships) => {
const initialState = ImmutableMap(); const initialState = ImmutableMap();
export default function group_relationships(state = initialState, action) { export default function group_relationships(state = initialState, action) {
switch(action.type) { switch (action.type) {
case GROUP_JOIN_SUCCESS: case GROUP_JOIN_SUCCESS:
case GROUP_LEAVE_SUCCESS: case GROUP_LEAVE_SUCCESS:
return normalizeRelationship(state, action.relationship); return normalizeRelationship(state, action.relationship);
case GROUP_RELATIONSHIPS_FETCH_SUCCESS: case GROUP_RELATIONSHIPS_FETCH_SUCCESS:
return normalizeRelationships(state, action.relationships); return normalizeRelationships(state, action.relationships);
default: default:
return state; return state;
} }
} }

View File

@ -20,15 +20,15 @@ const normalizeGroups = (state, groups) => {
}; };
export default function groups(state = initialState, action) { export default function groups(state = initialState, action) {
switch(action.type) { switch (action.type) {
case GROUP_FETCH_SUCCESS: case GROUP_FETCH_SUCCESS:
case GROUP_UPDATE_SUCCESS: case GROUP_UPDATE_SUCCESS:
return normalizeGroup(state, action.group); return normalizeGroup(state, action.group);
case GROUPS_FETCH_SUCCESS: case GROUPS_FETCH_SUCCESS:
return normalizeGroups(state, action.groups); return normalizeGroups(state, action.groups);
case GROUP_FETCH_FAIL: case GROUP_FETCH_FAIL:
return state.set(action.id, false); return state.set(action.id, false);
default: default:
return state; return state;
} }
} }

View File

@ -16,20 +16,20 @@ type State = ImmutableMap<string, ReturnType<typeof HistoryRecord>>;
const initialState: State = ImmutableMap(); const initialState: State = ImmutableMap();
export default function history(state: State = initialState, action: AnyAction) { export default function history(state: State = initialState, action: AnyAction) {
switch(action.type) { switch (action.type) {
case HISTORY_FETCH_REQUEST: case HISTORY_FETCH_REQUEST:
return state.update(action.statusId, HistoryRecord(), history => history!.withMutations(map => { return state.update(action.statusId, HistoryRecord(), history => history!.withMutations(map => {
map.set('loading', true); map.set('loading', true);
map.set('items', ImmutableList()); map.set('items', ImmutableList());
})); }));
case HISTORY_FETCH_SUCCESS: case HISTORY_FETCH_SUCCESS:
return state.update(action.statusId, HistoryRecord(), history => history!.withMutations(map => { return state.update(action.statusId, HistoryRecord(), history => history!.withMutations(map => {
map.set('loading', false); map.set('loading', false);
map.set('items', ImmutableList(action.history.map((x: any, i: number) => ({ ...x, account: x.account.id, original: i === 0 })).reverse().map(normalizeStatusEdit))); map.set('items', ImmutableList(action.history.map((x: any, i: number) => ({ ...x, account: x.account.id, original: i === 0 })).reverse().map(normalizeStatusEdit)));
})); }));
case HISTORY_FETCH_FAIL: case HISTORY_FETCH_FAIL:
return state.update(action.statusId, HistoryRecord(), history => history!.set('loading', false)); return state.update(action.statusId, HistoryRecord(), history => history!.set('loading', false));
default: default:
return state; return state;
} }
} }

View File

@ -9,18 +9,18 @@ import {
const initialState = ImmutableMap(); const initialState = ImmutableMap();
export default function identityProofsReducer(state = initialState, action) { export default function identityProofsReducer(state = initialState, action) {
switch(action.type) { switch (action.type) {
case IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST: case IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST:
return state.set('isLoading', true); return state.set('isLoading', true);
case IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL: case IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL:
return state.set('isLoading', false); return state.set('isLoading', false);
case IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS: case IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS:
return state.update(identity_proofs => identity_proofs.withMutations(map => { return state.update(identity_proofs => identity_proofs.withMutations(map => {
map.set('isLoading', false); map.set('isLoading', false);
map.set('loaded', true); map.set('loaded', true);
map.set(action.accountId, fromJS(action.identity_proofs)); map.set(action.accountId, fromJS(action.identity_proofs));
})); }));
default: default:
return state; return state;
} }
} }

View File

@ -152,11 +152,11 @@ const logOut = (state: any = StateRecord()): ReturnType<typeof appReducer> => {
}; };
const rootReducer: typeof appReducer = (state, action) => { const rootReducer: typeof appReducer = (state, action) => {
switch(action.type) { switch (action.type) {
case AUTH_LOGGED_OUT: case AUTH_LOGGED_OUT:
return appReducer(logOut(state), action); return appReducer(logOut(state), action);
default: default:
return appReducer(state, action); return appReducer(state, action);
} }
}; };

View File

@ -111,22 +111,22 @@ const handleInstanceFetchFail = (state: typeof initialState, error: Record<strin
}; };
export default function instance(state = initialState, action: AnyAction) { export default function instance(state = initialState, action: AnyAction) {
switch(action.type) { switch (action.type) {
case PLEROMA_PRELOAD_IMPORT: case PLEROMA_PRELOAD_IMPORT:
return preloadImport(state, action, '/api/v1/instance'); return preloadImport(state, action, '/api/v1/instance');
case rememberInstance.fulfilled.type: case rememberInstance.fulfilled.type:
return importInstance(state, ImmutableMap(fromJS(action.payload))); return importInstance(state, ImmutableMap(fromJS(action.payload)));
case fetchInstance.fulfilled.type: case fetchInstance.fulfilled.type:
persistInstance(action.payload); persistInstance(action.payload);
return importInstance(state, ImmutableMap(fromJS(action.payload))); return importInstance(state, ImmutableMap(fromJS(action.payload)));
case fetchInstance.rejected.type: case fetchInstance.rejected.type:
return handleInstanceFetchFail(state, action.error); return handleInstanceFetchFail(state, action.error);
case fetchNodeinfo.fulfilled.type: case fetchNodeinfo.fulfilled.type:
return importNodeinfo(state, ImmutableMap(fromJS(action.payload))); return importNodeinfo(state, ImmutableMap(fromJS(action.payload)));
case ADMIN_CONFIG_UPDATE_REQUEST: case ADMIN_CONFIG_UPDATE_REQUEST:
case ADMIN_CONFIG_UPDATE_SUCCESS: case ADMIN_CONFIG_UPDATE_SUCCESS:
return importConfigs(state, ImmutableList(fromJS(action.configs))); return importConfigs(state, ImmutableList(fromJS(action.configs)));
default: default:
return state; return state;
} }
} }

View File

@ -26,28 +26,28 @@ const ReducerRecord = ImmutableRecord({
type State = ReturnType<typeof ReducerRecord>; type State = ReturnType<typeof ReducerRecord>;
export default function listAdderReducer(state: State = ReducerRecord(), action: AnyAction) { export default function listAdderReducer(state: State = ReducerRecord(), action: AnyAction) {
switch(action.type) { switch (action.type) {
case LIST_ADDER_RESET: case LIST_ADDER_RESET:
return ReducerRecord(); return ReducerRecord();
case LIST_ADDER_SETUP: case LIST_ADDER_SETUP:
return state.withMutations(map => { return state.withMutations(map => {
map.set('accountId', action.account.get('id')); map.set('accountId', action.account.get('id'));
}); });
case LIST_ADDER_LISTS_FETCH_REQUEST: case LIST_ADDER_LISTS_FETCH_REQUEST:
return state.setIn(['lists', 'isLoading'], true); return state.setIn(['lists', 'isLoading'], true);
case LIST_ADDER_LISTS_FETCH_FAIL: case LIST_ADDER_LISTS_FETCH_FAIL:
return state.setIn(['lists', 'isLoading'], false); return state.setIn(['lists', 'isLoading'], false);
case LIST_ADDER_LISTS_FETCH_SUCCESS: case LIST_ADDER_LISTS_FETCH_SUCCESS:
return state.update('lists', lists => lists.withMutations(map => { return state.update('lists', lists => lists.withMutations(map => {
map.set('isLoading', false); map.set('isLoading', false);
map.set('loaded', true); map.set('loaded', true);
map.set('items', ImmutableList(action.lists.map((item: { id: string }) => item.id))); map.set('items', ImmutableList(action.lists.map((item: { id: string }) => item.id)));
})); }));
case LIST_EDITOR_ADD_SUCCESS: case LIST_EDITOR_ADD_SUCCESS:
return state.updateIn(['lists', 'items'], list => (list as ImmutableList<string>).unshift(action.listId)); return state.updateIn(['lists', 'items'], list => (list as ImmutableList<string>).unshift(action.listId));
case LIST_EDITOR_REMOVE_SUCCESS: case LIST_EDITOR_REMOVE_SUCCESS:
return state.updateIn(['lists', 'items'], list => (list as ImmutableList<string>).filterNot(item => item === action.listId)); return state.updateIn(['lists', 'items'], list => (list as ImmutableList<string>).filterNot(item => item === action.listId));
default: default:
return state; return state;
} }
} }

View File

@ -46,59 +46,59 @@ const ReducerRecord = ImmutableRecord({
type State = ReturnType<typeof ReducerRecord>; type State = ReturnType<typeof ReducerRecord>;
export default function listEditorReducer(state: State = ReducerRecord(), action: AnyAction) { export default function listEditorReducer(state: State = ReducerRecord(), action: AnyAction) {
switch(action.type) { switch (action.type) {
case LIST_EDITOR_RESET: case LIST_EDITOR_RESET:
return ReducerRecord(); return ReducerRecord();
case LIST_EDITOR_SETUP: case LIST_EDITOR_SETUP:
return state.withMutations(map => { return state.withMutations(map => {
map.set('listId', action.list.get('id')); map.set('listId', action.list.get('id'));
map.set('title', action.list.get('title')); map.set('title', action.list.get('title'));
map.set('isSubmitting', false); map.set('isSubmitting', false);
}); });
case LIST_EDITOR_TITLE_CHANGE: case LIST_EDITOR_TITLE_CHANGE:
return state.withMutations(map => { return state.withMutations(map => {
map.set('title', action.value); map.set('title', action.value);
map.set('isChanged', true); map.set('isChanged', true);
}); });
case LIST_CREATE_REQUEST: case LIST_CREATE_REQUEST:
case LIST_UPDATE_REQUEST: case LIST_UPDATE_REQUEST:
return state.withMutations(map => { return state.withMutations(map => {
map.set('isSubmitting', true); map.set('isSubmitting', true);
map.set('isChanged', false); map.set('isChanged', false);
}); });
case LIST_CREATE_FAIL: case LIST_CREATE_FAIL:
case LIST_UPDATE_FAIL: case LIST_UPDATE_FAIL:
return state.set('isSubmitting', false); return state.set('isSubmitting', false);
case LIST_CREATE_SUCCESS: case LIST_CREATE_SUCCESS:
case LIST_UPDATE_SUCCESS: case LIST_UPDATE_SUCCESS:
return state.withMutations(map => { return state.withMutations(map => {
map.set('isSubmitting', false); map.set('isSubmitting', false);
map.set('listId', action.list.id); map.set('listId', action.list.id);
}); });
case LIST_ACCOUNTS_FETCH_REQUEST: case LIST_ACCOUNTS_FETCH_REQUEST:
return state.setIn(['accounts', 'isLoading'], true); return state.setIn(['accounts', 'isLoading'], true);
case LIST_ACCOUNTS_FETCH_FAIL: case LIST_ACCOUNTS_FETCH_FAIL:
return state.setIn(['accounts', 'isLoading'], false); return state.setIn(['accounts', 'isLoading'], false);
case LIST_ACCOUNTS_FETCH_SUCCESS: case LIST_ACCOUNTS_FETCH_SUCCESS:
return state.update('accounts', accounts => accounts.withMutations(map => { return state.update('accounts', accounts => accounts.withMutations(map => {
map.set('isLoading', false); map.set('isLoading', false);
map.set('loaded', true); map.set('loaded', true);
map.set('items', ImmutableList(action.accounts.map((item: { id: string }) => item.id))); map.set('items', ImmutableList(action.accounts.map((item: { id: string }) => item.id)));
})); }));
case LIST_EDITOR_SUGGESTIONS_CHANGE: case LIST_EDITOR_SUGGESTIONS_CHANGE:
return state.setIn(['suggestions', 'value'], action.value); return state.setIn(['suggestions', 'value'], action.value);
case LIST_EDITOR_SUGGESTIONS_READY: case LIST_EDITOR_SUGGESTIONS_READY:
return state.setIn(['suggestions', 'items'], ImmutableList(action.accounts.map((item: { id: string }) => item.id))); return state.setIn(['suggestions', 'items'], ImmutableList(action.accounts.map((item: { id: string }) => item.id)));
case LIST_EDITOR_SUGGESTIONS_CLEAR: case LIST_EDITOR_SUGGESTIONS_CLEAR:
return state.update('suggestions', suggestions => suggestions.withMutations(map => { return state.update('suggestions', suggestions => suggestions.withMutations(map => {
map.set('items', ImmutableList()); map.set('items', ImmutableList());
map.set('value', ''); map.set('value', '');
})); }));
case LIST_EDITOR_ADD_SUCCESS: case LIST_EDITOR_ADD_SUCCESS:
return state.updateIn(['accounts', 'items'], list => (list as ImmutableList<string>).unshift(action.accountId)); return state.updateIn(['accounts', 'items'], list => (list as ImmutableList<string>).unshift(action.accountId));
case LIST_EDITOR_REMOVE_SUCCESS: case LIST_EDITOR_REMOVE_SUCCESS:
return state.updateIn(['accounts', 'items'], list => (list as ImmutableList<string>).filterNot((item) => item === action.accountId)); return state.updateIn(['accounts', 'items'], list => (list as ImmutableList<string>).filterNot((item) => item === action.accountId));
default: default:
return state; return state;
} }
} }

View File

@ -30,17 +30,17 @@ const importLists = (state: State, lists: APIEntities) => {
}; };
export default function lists(state: State = initialState, action: AnyAction) { export default function lists(state: State = initialState, action: AnyAction) {
switch(action.type) { switch (action.type) {
case LIST_FETCH_SUCCESS: case LIST_FETCH_SUCCESS:
case LIST_CREATE_SUCCESS: case LIST_CREATE_SUCCESS:
case LIST_UPDATE_SUCCESS: case LIST_UPDATE_SUCCESS:
return importList(state, action.list); return importList(state, action.list);
case LISTS_FETCH_SUCCESS: case LISTS_FETCH_SUCCESS:
return importLists(state, action.lists); return importLists(state, action.lists);
case LIST_DELETE_SUCCESS: case LIST_DELETE_SUCCESS:
case LIST_FETCH_FAIL: case LIST_FETCH_FAIL:
return state.set(action.id, false); return state.set(action.id, false);
default: default:
return state; return state;
} }
} }

View File

@ -25,19 +25,19 @@ const handleForbidden = (state: Me, error: AxiosError) => {
}; };
export default function me(state: Me = initialState, action: AnyAction): Me { export default function me(state: Me = initialState, action: AnyAction): Me {
switch(action.type) { switch (action.type) {
case ME_FETCH_SUCCESS: case ME_FETCH_SUCCESS:
case ME_PATCH_SUCCESS: case ME_PATCH_SUCCESS:
return action.me.id; return action.me.id;
case VERIFY_CREDENTIALS_SUCCESS: case VERIFY_CREDENTIALS_SUCCESS:
case AUTH_ACCOUNT_REMEMBER_SUCCESS: case AUTH_ACCOUNT_REMEMBER_SUCCESS:
return state || action.account.id; return state || action.account.id;
case ME_FETCH_SKIP: case ME_FETCH_SKIP:
case AUTH_LOGGED_OUT: case AUTH_LOGGED_OUT:
return false; return false;
case ME_FETCH_FAIL: case ME_FETCH_FAIL:
return handleForbidden(state, action.error); return handleForbidden(state, action.error);
default: default:
return state; return state;
} }
} }

View File

@ -11,13 +11,13 @@ const ReducerRecord = ImmutableRecord({
}); });
export default function meta(state = ReducerRecord(), action: AnyAction) { export default function meta(state = ReducerRecord(), action: AnyAction) {
switch(action.type) { switch (action.type) {
case fetchInstance.rejected.type: case fetchInstance.rejected.type:
if (action.payload.response?.status === 404) { if (action.payload.response?.status === 404) {
return state.set('instance_fetch_failed', true); return state.set('instance_fetch_failed', true);
} }
return state; return state;
default: default:
return state; return state;
} }
} }

View File

@ -5,21 +5,21 @@ import { MODAL_OPEN, MODAL_CLOSE } from '../actions/modals';
const initialState = ImmutableList(); const initialState = ImmutableList();
export default function modal(state = initialState, action) { export default function modal(state = initialState, action) {
switch(action.type) { switch (action.type) {
case MODAL_OPEN: case MODAL_OPEN:
return state.push({ modalType: action.modalType, modalProps: action.modalProps }); return state.push({ modalType: action.modalType, modalProps: action.modalProps });
case MODAL_CLOSE: case MODAL_CLOSE:
if (state.size === 0) { if (state.size === 0) {
return state;
}
if (action.modalType === undefined) {
return state.pop();
}
if (state.some(({ modalType }) => action.modalType === modalType)) {
return state.slice(0, state.findLastIndex(({ modalType }) => action.modalType === modalType));
}
return state;
default:
return state; return state;
}
if (action.modalType === undefined) {
return state.pop();
}
if (state.some(({ modalType }) => action.modalType === modalType)) {
return state.slice(0, state.findLastIndex(({ modalType }) => action.modalType === modalType));
}
return state;
default:
return state;
} }
} }

View File

@ -15,15 +15,15 @@ const initialState = ImmutableMap({
export default function mutes(state = initialState, action) { export default function mutes(state = initialState, action) {
switch (action.type) { switch (action.type) {
case MUTES_INIT_MODAL: case MUTES_INIT_MODAL:
return state.withMutations((state) => { return state.withMutations((state) => {
state.setIn(['new', 'isSubmitting'], false); state.setIn(['new', 'isSubmitting'], false);
state.setIn(['new', 'account'], action.account); state.setIn(['new', 'account'], action.account);
state.setIn(['new', 'notifications'], true); state.setIn(['new', 'notifications'], true);
}); });
case MUTES_TOGGLE_HIDE_NOTIFICATIONS: case MUTES_TOGGLE_HIDE_NOTIFICATIONS:
return state.updateIn(['new', 'notifications'], (old) => !old); return state.updateIn(['new', 'notifications'], (old) => !old);
default: default:
return state; return state;
} }
} }

View File

@ -183,44 +183,44 @@ const importMarker = (state, marker) => {
}; };
export default function notifications(state = ReducerRecord(), action) { export default function notifications(state = ReducerRecord(), action) {
switch(action.type) { switch (action.type) {
case NOTIFICATIONS_EXPAND_REQUEST: case NOTIFICATIONS_EXPAND_REQUEST:
return state.set('isLoading', true); return state.set('isLoading', true);
case NOTIFICATIONS_EXPAND_FAIL: case NOTIFICATIONS_EXPAND_FAIL:
return state.set('isLoading', false); return state.set('isLoading', false);
case NOTIFICATIONS_FILTER_SET: case NOTIFICATIONS_FILTER_SET:
return state.delete('items').set('hasMore', true); return state.delete('items').set('hasMore', true);
case NOTIFICATIONS_SCROLL_TOP: case NOTIFICATIONS_SCROLL_TOP:
return updateTop(state, action.top); return updateTop(state, action.top);
case NOTIFICATIONS_UPDATE: case NOTIFICATIONS_UPDATE:
return importNotification(state, action.notification); return importNotification(state, action.notification);
case NOTIFICATIONS_UPDATE_QUEUE: case NOTIFICATIONS_UPDATE_QUEUE:
return updateNotificationsQueue(state, action.notification, action.intlMessages, action.intlLocale); return updateNotificationsQueue(state, action.notification, action.intlMessages, action.intlLocale);
case NOTIFICATIONS_DEQUEUE: case NOTIFICATIONS_DEQUEUE:
return state.withMutations(mutable => { return state.withMutations(mutable => {
mutable.delete('queuedNotifications'); mutable.delete('queuedNotifications');
mutable.set('totalQueuedNotificationsCount', 0); mutable.set('totalQueuedNotificationsCount', 0);
}); });
case NOTIFICATIONS_EXPAND_SUCCESS: case NOTIFICATIONS_EXPAND_SUCCESS:
return expandNormalizedNotifications(state, action.notifications, action.next); return expandNormalizedNotifications(state, action.notifications, action.next);
case ACCOUNT_BLOCK_SUCCESS: case ACCOUNT_BLOCK_SUCCESS:
return filterNotifications(state, action.relationship); return filterNotifications(state, action.relationship);
case ACCOUNT_MUTE_SUCCESS: case ACCOUNT_MUTE_SUCCESS:
return action.relationship.muting_notifications ? filterNotifications(state, action.relationship) : state; return action.relationship.muting_notifications ? filterNotifications(state, action.relationship) : state;
case FOLLOW_REQUEST_AUTHORIZE_SUCCESS: case FOLLOW_REQUEST_AUTHORIZE_SUCCESS:
case FOLLOW_REQUEST_REJECT_SUCCESS: case FOLLOW_REQUEST_REJECT_SUCCESS:
return filterNotificationIds(state, [action.id], 'follow_request'); return filterNotificationIds(state, [action.id], 'follow_request');
case NOTIFICATIONS_CLEAR: case NOTIFICATIONS_CLEAR:
return state.delete('items').set('hasMore', false); return state.delete('items').set('hasMore', false);
case NOTIFICATIONS_MARK_READ_REQUEST: case NOTIFICATIONS_MARK_READ_REQUEST:
return state.set('lastRead', action.lastRead); return state.set('lastRead', action.lastRead);
case MARKER_FETCH_SUCCESS: case MARKER_FETCH_SUCCESS:
case MARKER_SAVE_REQUEST: case MARKER_SAVE_REQUEST:
case MARKER_SAVE_SUCCESS: case MARKER_SAVE_SUCCESS:
return importMarker(state, fromJS(action.marker)); return importMarker(state, fromJS(action.marker));
case TIMELINE_DELETE: case TIMELINE_DELETE:
return deleteByStatus(state, action.id); return deleteByStatus(state, action.id);
default: default:
return state; return state;
} }
} }

View File

@ -11,12 +11,12 @@ const initialState: OnboardingState = {
}; };
export default function onboarding(state: OnboardingState = initialState, action: OnboardingActions): OnboardingState { export default function onboarding(state: OnboardingState = initialState, action: OnboardingActions): OnboardingState {
switch(action.type) { switch (action.type) {
case ONBOARDING_START: case ONBOARDING_START:
return { ...state, needsOnboarding: true }; return { ...state, needsOnboarding: true };
case ONBOARDING_END: case ONBOARDING_END:
return { ...state, needsOnboarding: false }; return { ...state, needsOnboarding: false };
default: default:
return state; return state;
} }
} }

View File

@ -39,12 +39,12 @@ const normalizePatronAccount = (state: State, account: Record<string, any>) => {
}; };
export default function patron(state = ReducerRecord(), action: AnyAction) { export default function patron(state = ReducerRecord(), action: AnyAction) {
switch(action.type) { switch (action.type) {
case PATRON_INSTANCE_FETCH_SUCCESS: case PATRON_INSTANCE_FETCH_SUCCESS:
return state.set('instance', PatronInstanceRecord(ImmutableMap(fromJS(action.instance)))); return state.set('instance', PatronInstanceRecord(ImmutableMap(fromJS(action.instance))));
case PATRON_ACCOUNT_FETCH_SUCCESS: case PATRON_ACCOUNT_FETCH_SUCCESS:
return normalizePatronAccount(state, action.account); return normalizePatronAccount(state, action.account);
default: default:
return state; return state;
} }
} }

View File

@ -14,12 +14,12 @@ const deleteStatus = (state, idempotencyKey) => state.delete(idempotencyKey);
const initialState = ImmutableMap(); const initialState = ImmutableMap();
export default function pending_statuses(state = initialState, action) { export default function pending_statuses(state = initialState, action) {
switch(action.type) { switch (action.type) {
case STATUS_CREATE_REQUEST: case STATUS_CREATE_REQUEST:
return importStatus(state, fromJS(action.params), action.idempotencyKey); return importStatus(state, fromJS(action.params), action.idempotencyKey);
case STATUS_CREATE_SUCCESS: case STATUS_CREATE_SUCCESS:
return deleteStatus(state, action.idempotencyKey); return deleteStatus(state, action.idempotencyKey);
default: default:
return state; return state;
} }
} }

View File

@ -30,10 +30,10 @@ const importPolls = (state: State, polls: Array<APIEntity>) => {
const initialState: State = ImmutableMap(); const initialState: State = ImmutableMap();
export default function polls(state: State = initialState, action: AnyAction): State { export default function polls(state: State = initialState, action: AnyAction): State {
switch(action.type) { switch (action.type) {
case POLLS_IMPORT: case POLLS_IMPORT:
return importPolls(state, action.polls); return importPolls(state, action.polls);
default: default:
return state; return state;
} }
} }

View File

@ -9,20 +9,20 @@ import {
const initialState = ImmutableMap(); const initialState = ImmutableMap();
export default function profileHoverCard(state = initialState, action) { export default function profileHoverCard(state = initialState, action) {
switch(action.type) { switch (action.type) {
case PROFILE_HOVER_CARD_OPEN: case PROFILE_HOVER_CARD_OPEN:
return ImmutableMap({ return ImmutableMap({
ref: action.ref, ref: action.ref,
accountId: action.accountId, accountId: action.accountId,
}); });
case PROFILE_HOVER_CARD_UPDATE: case PROFILE_HOVER_CARD_UPDATE:
return state.set('hovered', true); return state.set('hovered', true);
case PROFILE_HOVER_CARD_CLOSE: case PROFILE_HOVER_CARD_CLOSE:
if (state.get('hovered') === true && !action.force) if (state.get('hovered') === true && !action.force)
return state;
else
return ImmutableMap();
default:
return state; return state;
else
return ImmutableMap();
default:
return state;
} }
} }

View File

@ -17,22 +17,22 @@ const initialState = ImmutableMap({
}); });
export default function push_subscriptions(state = initialState, action) { export default function push_subscriptions(state = initialState, action) {
switch(action.type) { switch (action.type) {
case SET_SUBSCRIPTION: case SET_SUBSCRIPTION:
return state return state
.set('subscription', new ImmutableMap({ .set('subscription', new ImmutableMap({
id: action.subscription.id, id: action.subscription.id,
endpoint: action.subscription.endpoint, endpoint: action.subscription.endpoint,
})) }))
.set('alerts', new ImmutableMap(action.subscription.alerts)) .set('alerts', new ImmutableMap(action.subscription.alerts))
.set('isSubscribed', true); .set('isSubscribed', true);
case SET_BROWSER_SUPPORT: case SET_BROWSER_SUPPORT:
return state.set('browserSupport', action.value); return state.set('browserSupport', action.value);
case CLEAR_SUBSCRIPTION: case CLEAR_SUBSCRIPTION:
return initialState; return initialState;
case SET_ALERTS: case SET_ALERTS:
return state.setIn(action.path, action.value); return state.setIn(action.path, action.value);
default: default:
return state; return state;
} }
} }

View File

@ -64,15 +64,15 @@ const importPleromaAccounts = (state, accounts) => {
}; };
const followStateToRelationship = followState => { const followStateToRelationship = followState => {
switch(followState) { switch (followState) {
case 'follow_pending': case 'follow_pending':
return { following: false, requested: true }; return { following: false, requested: true };
case 'follow_accept': case 'follow_accept':
return { following: true, requested: false }; return { following: true, requested: false };
case 'follow_reject': case 'follow_reject':
return { following: false, requested: false }; return { following: false, requested: false };
default: default:
return {}; return {};
} }
}; };
@ -84,44 +84,44 @@ const updateFollowRelationship = (state, id, followState) => {
const initialState = ImmutableMap(); const initialState = ImmutableMap();
export default function relationships(state = initialState, action) { export default function relationships(state = initialState, action) {
switch(action.type) { switch (action.type) {
case ACCOUNT_IMPORT: case ACCOUNT_IMPORT:
return importPleromaAccount(state, action.account); return importPleromaAccount(state, action.account);
case ACCOUNTS_IMPORT: case ACCOUNTS_IMPORT:
return importPleromaAccounts(state, action.accounts); return importPleromaAccounts(state, action.accounts);
case ACCOUNT_FOLLOW_REQUEST: case ACCOUNT_FOLLOW_REQUEST:
return state.setIn([action.id, 'following'], true); return state.setIn([action.id, 'following'], true);
case ACCOUNT_FOLLOW_FAIL: case ACCOUNT_FOLLOW_FAIL:
return state.setIn([action.id, 'following'], false); return state.setIn([action.id, 'following'], false);
case ACCOUNT_UNFOLLOW_REQUEST: case ACCOUNT_UNFOLLOW_REQUEST:
return state.setIn([action.id, 'following'], false); return state.setIn([action.id, 'following'], false);
case ACCOUNT_UNFOLLOW_FAIL: case ACCOUNT_UNFOLLOW_FAIL:
return state.setIn([action.id, 'following'], true); return state.setIn([action.id, 'following'], true);
case ACCOUNT_FOLLOW_SUCCESS: case ACCOUNT_FOLLOW_SUCCESS:
case ACCOUNT_UNFOLLOW_SUCCESS: case ACCOUNT_UNFOLLOW_SUCCESS:
case ACCOUNT_BLOCK_SUCCESS: case ACCOUNT_BLOCK_SUCCESS:
case ACCOUNT_UNBLOCK_SUCCESS: case ACCOUNT_UNBLOCK_SUCCESS:
case ACCOUNT_MUTE_SUCCESS: case ACCOUNT_MUTE_SUCCESS:
case ACCOUNT_UNMUTE_SUCCESS: case ACCOUNT_UNMUTE_SUCCESS:
case ACCOUNT_SUBSCRIBE_SUCCESS: case ACCOUNT_SUBSCRIBE_SUCCESS:
case ACCOUNT_UNSUBSCRIBE_SUCCESS: case ACCOUNT_UNSUBSCRIBE_SUCCESS:
case ACCOUNT_PIN_SUCCESS: case ACCOUNT_PIN_SUCCESS:
case ACCOUNT_UNPIN_SUCCESS: case ACCOUNT_UNPIN_SUCCESS:
case ACCOUNT_NOTE_SUBMIT_SUCCESS: case ACCOUNT_NOTE_SUBMIT_SUCCESS:
return normalizeRelationship(state, action.relationship); return normalizeRelationship(state, action.relationship);
case RELATIONSHIPS_FETCH_SUCCESS: case RELATIONSHIPS_FETCH_SUCCESS:
return normalizeRelationships(state, action.relationships); return normalizeRelationships(state, action.relationships);
case DOMAIN_BLOCK_SUCCESS: case DOMAIN_BLOCK_SUCCESS:
return setDomainBlocking(state, action.accounts, true); return setDomainBlocking(state, action.accounts, true);
case DOMAIN_UNBLOCK_SUCCESS: case DOMAIN_UNBLOCK_SUCCESS:
return setDomainBlocking(state, action.accounts, false); return setDomainBlocking(state, action.accounts, false);
case STREAMING_FOLLOW_RELATIONSHIPS_UPDATE: case STREAMING_FOLLOW_RELATIONSHIPS_UPDATE:
if (action.follower.id === action.me) { if (action.follower.id === action.me) {
return updateFollowRelationship(state, action.following.id, action.state); return updateFollowRelationship(state, action.following.id, action.state);
} else { } else {
return state;
}
default:
return state; return state;
}
default:
return state;
} }
} }

View File

@ -26,56 +26,56 @@ const initialState = ImmutableMap({
}); });
export default function reports(state = initialState, action) { export default function reports(state = initialState, action) {
switch(action.type) { switch (action.type) {
case REPORT_INIT: case REPORT_INIT:
return state.withMutations(map => { return state.withMutations(map => {
map.setIn(['new', 'isSubmitting'], false); map.setIn(['new', 'isSubmitting'], false);
map.setIn(['new', 'account_id'], action.account.get('id')); map.setIn(['new', 'account_id'], action.account.get('id'));
if (state.getIn(['new', 'account_id']) !== action.account.get('id')) { if (state.getIn(['new', 'account_id']) !== action.account.get('id')) {
map.setIn(['new', 'status_ids'], action.status ? ImmutableSet([action.status.getIn(['reblog', 'id'], action.status.get('id'))]) : ImmutableSet()); map.setIn(['new', 'status_ids'], action.status ? ImmutableSet([action.status.getIn(['reblog', 'id'], action.status.get('id'))]) : ImmutableSet());
map.setIn(['new', 'comment'], '');
} else if (action.status) {
map.updateIn(['new', 'status_ids'], ImmutableSet(), set => set.add(action.status.getIn(['reblog', 'id'], action.status.get('id'))));
}
});
case REPORT_STATUS_TOGGLE:
return state.updateIn(['new', 'status_ids'], ImmutableSet(), set => {
if (action.checked) {
return set.add(action.statusId);
}
return set.remove(action.statusId);
});
case REPORT_COMMENT_CHANGE:
return state.setIn(['new', 'comment'], action.comment);
case REPORT_FORWARD_CHANGE:
return state.setIn(['new', 'forward'], action.forward);
case REPORT_BLOCK_CHANGE:
return state.setIn(['new', 'block'], action.block);
case REPORT_RULE_CHANGE:
return state.updateIn(['new', 'rule_ids'], ImmutableSet(), (set) => {
if (set.includes(action.rule_id)) {
return set.remove(action.rule_id);
}
return set.add(action.rule_id);
});
case REPORT_SUBMIT_REQUEST:
return state.setIn(['new', 'isSubmitting'], true);
case REPORT_SUBMIT_FAIL:
return state.setIn(['new', 'isSubmitting'], false);
case REPORT_CANCEL:
case REPORT_SUBMIT_SUCCESS:
return state.withMutations(map => {
map.setIn(['new', 'account_id'], null);
map.setIn(['new', 'status_ids'], ImmutableSet());
map.setIn(['new', 'comment'], ''); map.setIn(['new', 'comment'], '');
} else if (action.status) { map.setIn(['new', 'isSubmitting'], false);
map.updateIn(['new', 'status_ids'], ImmutableSet(), set => set.add(action.status.getIn(['reblog', 'id'], action.status.get('id')))); map.setIn(['new', 'rule_ids'], ImmutableSet());
} map.setIn(['new', 'block'], false);
}); });
case REPORT_STATUS_TOGGLE: default:
return state.updateIn(['new', 'status_ids'], ImmutableSet(), set => { return state;
if (action.checked) {
return set.add(action.statusId);
}
return set.remove(action.statusId);
});
case REPORT_COMMENT_CHANGE:
return state.setIn(['new', 'comment'], action.comment);
case REPORT_FORWARD_CHANGE:
return state.setIn(['new', 'forward'], action.forward);
case REPORT_BLOCK_CHANGE:
return state.setIn(['new', 'block'], action.block);
case REPORT_RULE_CHANGE:
return state.updateIn(['new', 'rule_ids'], ImmutableSet(), (set) => {
if (set.includes(action.rule_id)) {
return set.remove(action.rule_id);
}
return set.add(action.rule_id);
});
case REPORT_SUBMIT_REQUEST:
return state.setIn(['new', 'isSubmitting'], true);
case REPORT_SUBMIT_FAIL:
return state.setIn(['new', 'isSubmitting'], false);
case REPORT_CANCEL:
case REPORT_SUBMIT_SUCCESS:
return state.withMutations(map => {
map.setIn(['new', 'account_id'], null);
map.setIn(['new', 'status_ids'], ImmutableSet());
map.setIn(['new', 'comment'], '');
map.setIn(['new', 'isSubmitting'], false);
map.setIn(['new', 'rule_ids'], ImmutableSet());
map.setIn(['new', 'block'], false);
});
default:
return state;
} }
} }

View File

@ -21,11 +21,11 @@ const initialState: RulesState = {
export default function rules(state: RulesState = initialState, action: RulesActions): RulesState { export default function rules(state: RulesState = initialState, action: RulesActions): RulesState {
switch (action.type) { switch (action.type) {
case RULES_FETCH_REQUEST: case RULES_FETCH_REQUEST:
return { ...state, isLoading: true }; return { ...state, isLoading: true };
case RULES_FETCH_SUCCESS: case RULES_FETCH_SUCCESS:
return { ...state, isLoading: false, items: action.payload }; return { ...state, isLoading: false, items: action.payload };
default: default:
return state; return state;
} }
} }

View File

@ -22,17 +22,17 @@ const deleteStatus = (state, id) => state.delete(id);
const initialState = ImmutableMap(); const initialState = ImmutableMap();
export default function scheduled_statuses(state = initialState, action) { export default function scheduled_statuses(state = initialState, action) {
switch(action.type) { switch (action.type) {
case STATUS_IMPORT: case STATUS_IMPORT:
case STATUS_CREATE_SUCCESS: case STATUS_CREATE_SUCCESS:
return importStatus(state, action.status); return importStatus(state, action.status);
case STATUSES_IMPORT: case STATUSES_IMPORT:
case SCHEDULED_STATUSES_FETCH_SUCCESS: case SCHEDULED_STATUSES_FETCH_SUCCESS:
return importStatuses(state, action.statuses); return importStatuses(state, action.statuses);
case SCHEDULED_STATUS_CANCEL_REQUEST: case SCHEDULED_STATUS_CANCEL_REQUEST:
case SCHEDULED_STATUS_CANCEL_SUCCESS: case SCHEDULED_STATUS_CANCEL_SUCCESS:
return deleteStatus(state, action.id); return deleteStatus(state, action.id);
default: default:
return state; return state;
} }
} }

View File

@ -77,29 +77,29 @@ const handleSubmitted = (state, value) => {
}; };
export default function search(state = initialState, action) { export default function search(state = initialState, action) {
switch(action.type) { switch (action.type) {
case SEARCH_CHANGE: case SEARCH_CHANGE:
return state.set('value', action.value); return state.set('value', action.value);
case SEARCH_CLEAR: case SEARCH_CLEAR:
return initialState; return initialState;
case SEARCH_SHOW: case SEARCH_SHOW:
return state.set('hidden', false); return state.set('hidden', false);
case COMPOSE_REPLY: case COMPOSE_REPLY:
case COMPOSE_MENTION: case COMPOSE_MENTION:
case COMPOSE_DIRECT: case COMPOSE_DIRECT:
case COMPOSE_QUOTE: case COMPOSE_QUOTE:
return state.set('hidden', true); return state.set('hidden', true);
case SEARCH_FETCH_REQUEST: case SEARCH_FETCH_REQUEST:
return handleSubmitted(state, action.value); return handleSubmitted(state, action.value);
case SEARCH_FETCH_SUCCESS: case SEARCH_FETCH_SUCCESS:
return importResults(state, action.results, action.searchTerm, action.searchType); return importResults(state, action.results, action.searchTerm, action.searchType);
case SEARCH_FILTER_SET: case SEARCH_FILTER_SET:
return state.set('filter', action.value); return state.set('filter', action.value);
case SEARCH_EXPAND_REQUEST: case SEARCH_EXPAND_REQUEST:
return state.setIn(['results', `${action.searchType}Loaded`], false); return state.setIn(['results', `${action.searchType}Loaded`], false);
case SEARCH_EXPAND_SUCCESS: case SEARCH_EXPAND_SUCCESS:
return paginateResults(state, action.searchType, action.results, action.searchTerm); return paginateResults(state, action.searchType, action.results, action.searchTerm);
default: default:
return state; return state;
} }
} }

View File

@ -38,18 +38,18 @@ const disableMfa = (state, method) => {
}; };
export default function security(state = initialState, action) { export default function security(state = initialState, action) {
switch(action.type) { switch (action.type) {
case FETCH_TOKENS_SUCCESS: case FETCH_TOKENS_SUCCESS:
return state.set('tokens', fromJS(action.tokens)); return state.set('tokens', fromJS(action.tokens));
case REVOKE_TOKEN_SUCCESS: case REVOKE_TOKEN_SUCCESS:
return deleteToken(state, action.id); return deleteToken(state, action.id);
case MFA_FETCH_SUCCESS: case MFA_FETCH_SUCCESS:
return importMfa(state, fromJS(action.data)); return importMfa(state, fromJS(action.data));
case MFA_CONFIRM_SUCCESS: case MFA_CONFIRM_SUCCESS:
return enableMfa(state, action.method); return enableMfa(state, action.method);
case MFA_DISABLE_SUCCESS: case MFA_DISABLE_SUCCESS:
return disableMfa(state, action.method); return disableMfa(state, action.method);
default: default:
return state; return state;
} }
} }

View File

@ -29,22 +29,22 @@ const importSettings = (state, account) => {
}; };
export default function settings(state = initialState, action) { export default function settings(state = initialState, action) {
switch(action.type) { switch (action.type) {
case ME_FETCH_SUCCESS: case ME_FETCH_SUCCESS:
return importSettings(state, action.me); return importSettings(state, action.me);
case NOTIFICATIONS_FILTER_SET: case NOTIFICATIONS_FILTER_SET:
case SEARCH_FILTER_SET: case SEARCH_FILTER_SET:
case SETTING_CHANGE: case SETTING_CHANGE:
return state return state
.setIn(action.path, action.value) .setIn(action.path, action.value)
.set('saved', false); .set('saved', false);
case EMOJI_USE: case EMOJI_USE:
return updateFrequentEmojis(state, action.emoji); return updateFrequentEmojis(state, action.emoji);
case SETTING_SAVE: case SETTING_SAVE:
return state.set('saved', true); return state.set('saved', true);
case SETTINGS_UPDATE: case SETTINGS_UPDATE:
return fromJS(action.settings); return fromJS(action.settings);
default: default:
return state; return state;
} }
} }

View File

@ -11,12 +11,12 @@ const initialState: State = {
}; };
export default function sidebar(state: State = initialState, action: AnyAction): State { export default function sidebar(state: State = initialState, action: AnyAction): State {
switch(action.type) { switch (action.type) {
case SIDEBAR_OPEN: case SIDEBAR_OPEN:
return { sidebarOpen: true }; return { sidebarOpen: true };
case SIDEBAR_CLOSE: case SIDEBAR_CLOSE:
return { sidebarOpen: false }; return { sidebarOpen: false };
default: default:
return state; return state;
} }
} }

View File

@ -52,18 +52,18 @@ const importSoapboxConfig = (state, soapboxConfig, host) => {
}; };
export default function soapbox(state = initialState, action) { export default function soapbox(state = initialState, action) {
switch(action.type) { switch (action.type) {
case PLEROMA_PRELOAD_IMPORT: case PLEROMA_PRELOAD_IMPORT:
return preloadImport(state, action); return preloadImport(state, action);
case SOAPBOX_CONFIG_REMEMBER_SUCCESS: case SOAPBOX_CONFIG_REMEMBER_SUCCESS:
return fromJS(action.soapboxConfig); return fromJS(action.soapboxConfig);
case SOAPBOX_CONFIG_REQUEST_SUCCESS: case SOAPBOX_CONFIG_REQUEST_SUCCESS:
return importSoapboxConfig(state, fromJS(action.soapboxConfig), action.host); return importSoapboxConfig(state, fromJS(action.soapboxConfig), action.host);
case SOAPBOX_CONFIG_REQUEST_FAIL: case SOAPBOX_CONFIG_REQUEST_FAIL:
return fallbackState.mergeDeep(state); return fallbackState.mergeDeep(state);
case ADMIN_CONFIG_UPDATE_SUCCESS: case ADMIN_CONFIG_UPDATE_SUCCESS:
return updateFromAdmin(state, fromJS(action.configs)); return updateFromAdmin(state, fromJS(action.configs));
default: default:
return state; return state;
} }
} }

View File

@ -97,65 +97,65 @@ const removeOneFromList = (state, listType, status) => {
}; };
export default function statusLists(state = initialState, action) { export default function statusLists(state = initialState, action) {
switch(action.type) { switch (action.type) {
case FAVOURITED_STATUSES_FETCH_REQUEST: case FAVOURITED_STATUSES_FETCH_REQUEST:
case FAVOURITED_STATUSES_EXPAND_REQUEST: case FAVOURITED_STATUSES_EXPAND_REQUEST:
return setLoading(state, 'favourites', true); return setLoading(state, 'favourites', true);
case FAVOURITED_STATUSES_FETCH_FAIL: case FAVOURITED_STATUSES_FETCH_FAIL:
case FAVOURITED_STATUSES_EXPAND_FAIL: case FAVOURITED_STATUSES_EXPAND_FAIL:
return setLoading(state, 'favourites', false); return setLoading(state, 'favourites', false);
case FAVOURITED_STATUSES_FETCH_SUCCESS: case FAVOURITED_STATUSES_FETCH_SUCCESS:
return normalizeList(state, 'favourites', action.statuses, action.next); return normalizeList(state, 'favourites', action.statuses, action.next);
case FAVOURITED_STATUSES_EXPAND_SUCCESS: case FAVOURITED_STATUSES_EXPAND_SUCCESS:
return appendToList(state, 'favourites', action.statuses, action.next); return appendToList(state, 'favourites', action.statuses, action.next);
case ACCOUNT_FAVOURITED_STATUSES_FETCH_REQUEST: case ACCOUNT_FAVOURITED_STATUSES_FETCH_REQUEST:
case ACCOUNT_FAVOURITED_STATUSES_EXPAND_REQUEST: case ACCOUNT_FAVOURITED_STATUSES_EXPAND_REQUEST:
return setLoading(state, `favourites:${action.accountId}`, true); return setLoading(state, `favourites:${action.accountId}`, true);
case ACCOUNT_FAVOURITED_STATUSES_FETCH_FAIL: case ACCOUNT_FAVOURITED_STATUSES_FETCH_FAIL:
case ACCOUNT_FAVOURITED_STATUSES_EXPAND_FAIL: case ACCOUNT_FAVOURITED_STATUSES_EXPAND_FAIL:
return setLoading(state, `favourites:${action.accountId}`, false); return setLoading(state, `favourites:${action.accountId}`, false);
case ACCOUNT_FAVOURITED_STATUSES_FETCH_SUCCESS: case ACCOUNT_FAVOURITED_STATUSES_FETCH_SUCCESS:
return normalizeList(state, `favourites:${action.accountId}`, action.statuses, action.next); return normalizeList(state, `favourites:${action.accountId}`, action.statuses, action.next);
case ACCOUNT_FAVOURITED_STATUSES_EXPAND_SUCCESS: case ACCOUNT_FAVOURITED_STATUSES_EXPAND_SUCCESS:
return appendToList(state, `favourites:${action.accountId}`, action.statuses, action.next); return appendToList(state, `favourites:${action.accountId}`, action.statuses, action.next);
case BOOKMARKED_STATUSES_FETCH_REQUEST: case BOOKMARKED_STATUSES_FETCH_REQUEST:
case BOOKMARKED_STATUSES_EXPAND_REQUEST: case BOOKMARKED_STATUSES_EXPAND_REQUEST:
return setLoading(state, 'bookmarks', true); return setLoading(state, 'bookmarks', true);
case BOOKMARKED_STATUSES_FETCH_FAIL: case BOOKMARKED_STATUSES_FETCH_FAIL:
case BOOKMARKED_STATUSES_EXPAND_FAIL: case BOOKMARKED_STATUSES_EXPAND_FAIL:
return setLoading(state, 'bookmarks', false); return setLoading(state, 'bookmarks', false);
case BOOKMARKED_STATUSES_FETCH_SUCCESS: case BOOKMARKED_STATUSES_FETCH_SUCCESS:
return normalizeList(state, 'bookmarks', action.statuses, action.next); return normalizeList(state, 'bookmarks', action.statuses, action.next);
case BOOKMARKED_STATUSES_EXPAND_SUCCESS: case BOOKMARKED_STATUSES_EXPAND_SUCCESS:
return appendToList(state, 'bookmarks', action.statuses, action.next); return appendToList(state, 'bookmarks', action.statuses, action.next);
case FAVOURITE_SUCCESS: case FAVOURITE_SUCCESS:
return prependOneToList(state, 'favourites', action.status); return prependOneToList(state, 'favourites', action.status);
case UNFAVOURITE_SUCCESS: case UNFAVOURITE_SUCCESS:
return removeOneFromList(state, 'favourites', action.status); return removeOneFromList(state, 'favourites', action.status);
case BOOKMARK_SUCCESS: case BOOKMARK_SUCCESS:
return prependOneToList(state, 'bookmarks', action.status); return prependOneToList(state, 'bookmarks', action.status);
case UNBOOKMARK_SUCCESS: case UNBOOKMARK_SUCCESS:
return removeOneFromList(state, 'bookmarks', action.status); return removeOneFromList(state, 'bookmarks', action.status);
case PINNED_STATUSES_FETCH_SUCCESS: case PINNED_STATUSES_FETCH_SUCCESS:
return normalizeList(state, 'pins', action.statuses, action.next); return normalizeList(state, 'pins', action.statuses, action.next);
case PIN_SUCCESS: case PIN_SUCCESS:
return prependOneToList(state, 'pins', action.status); return prependOneToList(state, 'pins', action.status);
case UNPIN_SUCCESS: case UNPIN_SUCCESS:
return removeOneFromList(state, 'pins', action.status); return removeOneFromList(state, 'pins', action.status);
case SCHEDULED_STATUSES_FETCH_REQUEST: case SCHEDULED_STATUSES_FETCH_REQUEST:
case SCHEDULED_STATUSES_EXPAND_REQUEST: case SCHEDULED_STATUSES_EXPAND_REQUEST:
return setLoading(state, 'scheduled_statuses', true); return setLoading(state, 'scheduled_statuses', true);
case SCHEDULED_STATUSES_FETCH_FAIL: case SCHEDULED_STATUSES_FETCH_FAIL:
case SCHEDULED_STATUSES_EXPAND_FAIL: case SCHEDULED_STATUSES_EXPAND_FAIL:
return setLoading(state, 'scheduled_statuses', false); return setLoading(state, 'scheduled_statuses', false);
case SCHEDULED_STATUSES_FETCH_SUCCESS: case SCHEDULED_STATUSES_FETCH_SUCCESS:
return normalizeList(state, 'scheduled_statuses', action.statuses, action.next); return normalizeList(state, 'scheduled_statuses', action.statuses, action.next);
case SCHEDULED_STATUSES_EXPAND_SUCCESS: case SCHEDULED_STATUSES_EXPAND_SUCCESS:
return appendToList(state, 'scheduled_statuses', action.statuses, action.next); return appendToList(state, 'scheduled_statuses', action.statuses, action.next);
case SCHEDULED_STATUS_CANCEL_REQUEST: case SCHEDULED_STATUS_CANCEL_REQUEST:
case SCHEDULED_STATUS_CANCEL_SUCCESS: case SCHEDULED_STATUS_CANCEL_SUCCESS:
return removeOneFromList(state, 'scheduled_statuses', action.id || action.status.get('id')); return removeOneFromList(state, 'scheduled_statuses', action.id || action.status.get('id'));
default: default:
return state; return state;
} }
} }

View File

@ -194,64 +194,64 @@ const simulateFavourite = (
const initialState: State = ImmutableMap(); const initialState: State = ImmutableMap();
export default function statuses(state = initialState, action: AnyAction): State { export default function statuses(state = initialState, action: AnyAction): State {
switch(action.type) { switch (action.type) {
case STATUS_IMPORT: case STATUS_IMPORT:
return importStatus(state, action.status, action.expandSpoilers); return importStatus(state, action.status, action.expandSpoilers);
case STATUSES_IMPORT: case STATUSES_IMPORT:
return importStatuses(state, action.statuses, action.expandSpoilers); return importStatuses(state, action.statuses, action.expandSpoilers);
case STATUS_CREATE_REQUEST: case STATUS_CREATE_REQUEST:
return importPendingStatus(state, action.params); return importPendingStatus(state, action.params);
case STATUS_CREATE_FAIL: case STATUS_CREATE_FAIL:
return deletePendingStatus(state, action.params); return deletePendingStatus(state, action.params);
case FAVOURITE_REQUEST: case FAVOURITE_REQUEST:
return simulateFavourite(state, action.status.id, true); return simulateFavourite(state, action.status.id, true);
case UNFAVOURITE_REQUEST: case UNFAVOURITE_REQUEST:
return simulateFavourite(state, action.status.id, false); return simulateFavourite(state, action.status.id, false);
case EMOJI_REACT_REQUEST: case EMOJI_REACT_REQUEST:
return state return state
.updateIn( .updateIn(
[action.status.get('id'), 'pleroma', 'emoji_reactions'], [action.status.get('id'), 'pleroma', 'emoji_reactions'],
emojiReacts => simulateEmojiReact(emojiReacts as any, action.emoji), emojiReacts => simulateEmojiReact(emojiReacts as any, action.emoji),
); );
case UNEMOJI_REACT_REQUEST: case UNEMOJI_REACT_REQUEST:
return state return state
.updateIn( .updateIn(
[action.status.get('id'), 'pleroma', 'emoji_reactions'], [action.status.get('id'), 'pleroma', 'emoji_reactions'],
emojiReacts => simulateUnEmojiReact(emojiReacts as any, action.emoji), emojiReacts => simulateUnEmojiReact(emojiReacts as any, action.emoji),
); );
case FAVOURITE_FAIL: case FAVOURITE_FAIL:
return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'favourited'], false); return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'favourited'], false);
case REBLOG_REQUEST: case REBLOG_REQUEST:
return state.setIn([action.status.get('id'), 'reblogged'], true); return state.setIn([action.status.get('id'), 'reblogged'], true);
case REBLOG_FAIL: case REBLOG_FAIL:
return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'reblogged'], false); return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'reblogged'], false);
case UNREBLOG_REQUEST: case UNREBLOG_REQUEST:
return state.setIn([action.status.get('id'), 'reblogged'], false); return state.setIn([action.status.get('id'), 'reblogged'], false);
case UNREBLOG_FAIL: case UNREBLOG_FAIL:
return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'reblogged'], true); return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'reblogged'], true);
case STATUS_MUTE_SUCCESS: case STATUS_MUTE_SUCCESS:
return state.setIn([action.id, 'muted'], true); return state.setIn([action.id, 'muted'], true);
case STATUS_UNMUTE_SUCCESS: case STATUS_UNMUTE_SUCCESS:
return state.setIn([action.id, 'muted'], false); return state.setIn([action.id, 'muted'], false);
case STATUS_REVEAL: case STATUS_REVEAL:
return state.withMutations(map => { return state.withMutations(map => {
action.ids.forEach((id: string) => { action.ids.forEach((id: string) => {
if (!(state.get(id) === undefined)) { if (!(state.get(id) === undefined)) {
map.setIn([id, 'hidden'], false); map.setIn([id, 'hidden'], false);
} }
});
}); });
}); case STATUS_HIDE:
case STATUS_HIDE: return state.withMutations(map => {
return state.withMutations(map => { action.ids.forEach((id: string) => {
action.ids.forEach((id: string) => { if (!(state.get(id) === undefined)) {
if (!(state.get(id) === undefined)) { map.setIn([id, 'hidden'], true);
map.setIn([id, 'hidden'], true); }
} });
}); });
}); case TIMELINE_DELETE:
case TIMELINE_DELETE: return deleteStatus(state, action.id, action.references);
return deleteStatus(state, action.id, action.references); default:
default: return state;
return state;
} }
} }

View File

@ -49,25 +49,25 @@ const dismissAccounts = (state, accountIds) => {
}; };
export default function suggestionsReducer(state = initialState, action) { export default function suggestionsReducer(state = initialState, action) {
switch(action.type) { switch (action.type) {
case SUGGESTIONS_FETCH_REQUEST: case SUGGESTIONS_FETCH_REQUEST:
case SUGGESTIONS_V2_FETCH_REQUEST: case SUGGESTIONS_V2_FETCH_REQUEST:
return state.set('isLoading', true); return state.set('isLoading', true);
case SUGGESTIONS_FETCH_SUCCESS: case SUGGESTIONS_FETCH_SUCCESS:
return importAccounts(state, action.accounts); return importAccounts(state, action.accounts);
case SUGGESTIONS_V2_FETCH_SUCCESS: case SUGGESTIONS_V2_FETCH_SUCCESS:
return importSuggestions(state, action.suggestions); return importSuggestions(state, action.suggestions);
case SUGGESTIONS_FETCH_FAIL: case SUGGESTIONS_FETCH_FAIL:
case SUGGESTIONS_V2_FETCH_FAIL: case SUGGESTIONS_V2_FETCH_FAIL:
return state.set('isLoading', false); return state.set('isLoading', false);
case SUGGESTIONS_DISMISS: case SUGGESTIONS_DISMISS:
return dismissAccount(state, action.id); return dismissAccount(state, action.id);
case ACCOUNT_BLOCK_SUCCESS: case ACCOUNT_BLOCK_SUCCESS:
case ACCOUNT_MUTE_SUCCESS: case ACCOUNT_MUTE_SUCCESS:
return dismissAccount(state, action.relationship.id); return dismissAccount(state, action.relationship.id);
case DOMAIN_BLOCK_SUCCESS: case DOMAIN_BLOCK_SUCCESS:
return dismissAccounts(state, action.accounts); return dismissAccounts(state, action.accounts);
default: default:
return state; return state;
} }
} }

View File

@ -233,13 +233,13 @@ const timelineDisconnect = (state, timelineId) => {
}; };
const getTimelinesByVisibility = visibility => { const getTimelinesByVisibility = visibility => {
switch(visibility) { switch (visibility) {
case 'direct': case 'direct':
return ['direct']; return ['direct'];
case 'public': case 'public':
return ['home', 'community', 'public']; return ['home', 'community', 'public'];
default: default:
return ['home']; return ['home'];
} }
}; };
@ -299,43 +299,43 @@ const handleExpandFail = (state, timelineId) => {
}; };
export default function timelines(state = initialState, action) { export default function timelines(state = initialState, action) {
switch(action.type) { switch (action.type) {
case STATUS_CREATE_REQUEST: case STATUS_CREATE_REQUEST:
if (action.params.scheduled_at) return state; if (action.params.scheduled_at) return state;
return importPendingStatus(state, action.params, action.idempotencyKey); return importPendingStatus(state, action.params, action.idempotencyKey);
case STATUS_CREATE_SUCCESS: case STATUS_CREATE_SUCCESS:
if (action.status.scheduled_at) return state; if (action.status.scheduled_at) return state;
return importStatus(state, action.status, action.idempotencyKey); return importStatus(state, action.status, action.idempotencyKey);
case TIMELINE_EXPAND_REQUEST: case TIMELINE_EXPAND_REQUEST:
return setLoading(state, action.timeline, true); return setLoading(state, action.timeline, true);
case TIMELINE_EXPAND_FAIL: case TIMELINE_EXPAND_FAIL:
return handleExpandFail(state, action.timeline); return handleExpandFail(state, action.timeline);
case TIMELINE_EXPAND_SUCCESS: case TIMELINE_EXPAND_SUCCESS:
return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial, action.isLoadingRecent); return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial, action.isLoadingRecent);
case TIMELINE_UPDATE: case TIMELINE_UPDATE:
return updateTimeline(state, action.timeline, action.statusId); return updateTimeline(state, action.timeline, action.statusId);
case TIMELINE_UPDATE_QUEUE: case TIMELINE_UPDATE_QUEUE:
return updateTimelineQueue(state, action.timeline, action.statusId); return updateTimelineQueue(state, action.timeline, action.statusId);
case TIMELINE_DEQUEUE: case TIMELINE_DEQUEUE:
return timelineDequeue(state, action.timeline); return timelineDequeue(state, action.timeline);
case TIMELINE_DELETE: case TIMELINE_DELETE:
return deleteStatus(state, action.id, action.accountId, action.references, action.reblogOf); return deleteStatus(state, action.id, action.accountId, action.references, action.reblogOf);
case TIMELINE_CLEAR: case TIMELINE_CLEAR:
return clearTimeline(state, action.timeline); return clearTimeline(state, action.timeline);
case ACCOUNT_BLOCK_SUCCESS: case ACCOUNT_BLOCK_SUCCESS:
case ACCOUNT_MUTE_SUCCESS: case ACCOUNT_MUTE_SUCCESS:
return filterTimelines(state, action.relationship, action.statuses); return filterTimelines(state, action.relationship, action.statuses);
case ACCOUNT_UNFOLLOW_SUCCESS: case ACCOUNT_UNFOLLOW_SUCCESS:
return filterTimeline(state, 'home', action.relationship, action.statuses); return filterTimeline(state, 'home', action.relationship, action.statuses);
case TIMELINE_SCROLL_TOP: case TIMELINE_SCROLL_TOP:
return updateTop(state, action.timeline, action.top); return updateTop(state, action.timeline, action.top);
case TIMELINE_CONNECT: case TIMELINE_CONNECT:
return timelineConnect(state, action.timeline); return timelineConnect(state, action.timeline);
case TIMELINE_DISCONNECT: case TIMELINE_DISCONNECT:
return timelineDisconnect(state, action.timeline); return timelineDisconnect(state, action.timeline);
case GROUP_REMOVE_STATUS_SUCCESS: case GROUP_REMOVE_STATUS_SUCCESS:
return removeStatusFromGroup(state, action.groupId, action.id); return removeStatusFromGroup(state, action.groupId, action.id);
default: default:
return state; return state;
} }
} }

View File

@ -20,12 +20,12 @@ const importStatuses = (state, statuses) => {
}; };
export default function trending_statuses(state = initialState, action) { export default function trending_statuses(state = initialState, action) {
switch(action.type) { switch (action.type) {
case TRENDING_STATUSES_FETCH_REQUEST: case TRENDING_STATUSES_FETCH_REQUEST:
return state.set('isLoading', true); return state.set('isLoading', true);
case TRENDING_STATUSES_FETCH_SUCCESS: case TRENDING_STATUSES_FETCH_SUCCESS:
return importStatuses(state, action.statuses); return importStatuses(state, action.statuses);
default: default:
return state; return state;
} }
} }

View File

@ -12,17 +12,17 @@ const initialState = ImmutableMap({
}); });
export default function trendsReducer(state = initialState, action) { export default function trendsReducer(state = initialState, action) {
switch(action.type) { switch (action.type) {
case TRENDS_FETCH_REQUEST: case TRENDS_FETCH_REQUEST:
return state.set('isLoading', true); return state.set('isLoading', true);
case TRENDS_FETCH_SUCCESS: case TRENDS_FETCH_SUCCESS:
return state.withMutations(map => { return state.withMutations(map => {
map.set('items', fromJS(action.tags.map((x => x)))); map.set('items', fromJS(action.tags.map((x => x))));
map.set('isLoading', false); map.set('isLoading', false);
}); });
case TRENDS_FETCH_FAIL: case TRENDS_FETCH_FAIL:
return state.set('isLoading', false); return state.set('isLoading', false);
default: default:
return state; return state;
} }
} }

View File

@ -82,63 +82,63 @@ const normalizeFollowRequest = (state, notification) => {
}; };
export default function userLists(state = initialState, action) { export default function userLists(state = initialState, action) {
switch(action.type) { switch (action.type) {
case FOLLOWERS_FETCH_SUCCESS: case FOLLOWERS_FETCH_SUCCESS:
return normalizeList(state, 'followers', action.id, action.accounts, action.next); return normalizeList(state, 'followers', action.id, action.accounts, action.next);
case FOLLOWERS_EXPAND_SUCCESS: case FOLLOWERS_EXPAND_SUCCESS:
return appendToList(state, 'followers', action.id, action.accounts, action.next); return appendToList(state, 'followers', action.id, action.accounts, action.next);
case FOLLOWING_FETCH_SUCCESS: case FOLLOWING_FETCH_SUCCESS:
return normalizeList(state, 'following', action.id, action.accounts, action.next); return normalizeList(state, 'following', action.id, action.accounts, action.next);
case FOLLOWING_EXPAND_SUCCESS: case FOLLOWING_EXPAND_SUCCESS:
return appendToList(state, 'following', action.id, action.accounts, action.next); return appendToList(state, 'following', action.id, action.accounts, action.next);
case REBLOGS_FETCH_SUCCESS: case REBLOGS_FETCH_SUCCESS:
return state.setIn(['reblogged_by', action.id], ImmutableOrderedSet(action.accounts.map(item => item.id))); return state.setIn(['reblogged_by', action.id], ImmutableOrderedSet(action.accounts.map(item => item.id)));
case FAVOURITES_FETCH_SUCCESS: case FAVOURITES_FETCH_SUCCESS:
return state.setIn(['favourited_by', action.id], ImmutableOrderedSet(action.accounts.map(item => item.id))); return state.setIn(['favourited_by', action.id], ImmutableOrderedSet(action.accounts.map(item => item.id)));
case REACTIONS_FETCH_SUCCESS: case REACTIONS_FETCH_SUCCESS:
return state.setIn(['reactions', action.id], action.reactions.map(({ accounts, ...reaction }) => ({ ...reaction, accounts: ImmutableOrderedSet(accounts.map(account => account.id)) }))); return state.setIn(['reactions', action.id], action.reactions.map(({ accounts, ...reaction }) => ({ ...reaction, accounts: ImmutableOrderedSet(accounts.map(account => account.id)) })));
case NOTIFICATIONS_UPDATE: case NOTIFICATIONS_UPDATE:
return action.notification.type === 'follow_request' ? normalizeFollowRequest(state, action.notification) : state; return action.notification.type === 'follow_request' ? normalizeFollowRequest(state, action.notification) : state;
case FOLLOW_REQUESTS_FETCH_SUCCESS: case FOLLOW_REQUESTS_FETCH_SUCCESS:
return state.setIn(['follow_requests', 'items'], ImmutableOrderedSet(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next); return state.setIn(['follow_requests', 'items'], ImmutableOrderedSet(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next);
case FOLLOW_REQUESTS_EXPAND_SUCCESS: case FOLLOW_REQUESTS_EXPAND_SUCCESS:
return state.updateIn(['follow_requests', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next); return state.updateIn(['follow_requests', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next);
case FOLLOW_REQUEST_AUTHORIZE_SUCCESS: case FOLLOW_REQUEST_AUTHORIZE_SUCCESS:
case FOLLOW_REQUEST_REJECT_SUCCESS: case FOLLOW_REQUEST_REJECT_SUCCESS:
return state.updateIn(['follow_requests', 'items'], list => list.filterNot(item => item === action.id)); return state.updateIn(['follow_requests', 'items'], list => list.filterNot(item => item === action.id));
case BLOCKS_FETCH_SUCCESS: case BLOCKS_FETCH_SUCCESS:
return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next); return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next);
case BLOCKS_EXPAND_SUCCESS: case BLOCKS_EXPAND_SUCCESS:
return state.updateIn(['blocks', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next); return state.updateIn(['blocks', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next);
case MUTES_FETCH_SUCCESS: case MUTES_FETCH_SUCCESS:
return state.setIn(['mutes', 'items'], ImmutableOrderedSet(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next); return state.setIn(['mutes', 'items'], ImmutableOrderedSet(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next);
case MUTES_EXPAND_SUCCESS: case MUTES_EXPAND_SUCCESS:
return state.updateIn(['mutes', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next); return state.updateIn(['mutes', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next);
case DIRECTORY_FETCH_SUCCESS: case DIRECTORY_FETCH_SUCCESS:
return state.setIn(['directory', 'items'], ImmutableOrderedSet(action.accounts.map(item => item.id))).setIn(['directory', 'isLoading'], false); return state.setIn(['directory', 'items'], ImmutableOrderedSet(action.accounts.map(item => item.id))).setIn(['directory', 'isLoading'], false);
case DIRECTORY_EXPAND_SUCCESS: case DIRECTORY_EXPAND_SUCCESS:
return state.updateIn(['directory', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['directory', 'isLoading'], false); return state.updateIn(['directory', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['directory', 'isLoading'], false);
case DIRECTORY_FETCH_REQUEST: case DIRECTORY_FETCH_REQUEST:
case DIRECTORY_EXPAND_REQUEST: case DIRECTORY_EXPAND_REQUEST:
return state.setIn(['directory', 'isLoading'], true); return state.setIn(['directory', 'isLoading'], true);
case DIRECTORY_FETCH_FAIL: case DIRECTORY_FETCH_FAIL:
case DIRECTORY_EXPAND_FAIL: case DIRECTORY_EXPAND_FAIL:
return state.setIn(['directory', 'isLoading'], false); return state.setIn(['directory', 'isLoading'], false);
case GROUP_MEMBERS_FETCH_SUCCESS: case GROUP_MEMBERS_FETCH_SUCCESS:
return normalizeList(state, 'groups', action.id, action.accounts, action.next); return normalizeList(state, 'groups', action.id, action.accounts, action.next);
case GROUP_MEMBERS_EXPAND_SUCCESS: case GROUP_MEMBERS_EXPAND_SUCCESS:
return appendToList(state, 'groups', action.id, action.accounts, action.next); return appendToList(state, 'groups', action.id, action.accounts, action.next);
case GROUP_REMOVED_ACCOUNTS_FETCH_SUCCESS: case GROUP_REMOVED_ACCOUNTS_FETCH_SUCCESS:
return normalizeList(state, 'groups_removed_accounts', action.id, action.accounts, action.next); return normalizeList(state, 'groups_removed_accounts', action.id, action.accounts, action.next);
case GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS: case GROUP_REMOVED_ACCOUNTS_EXPAND_SUCCESS:
return appendToList(state, 'groups_removed_accounts', action.id, action.accounts, action.next); return appendToList(state, 'groups_removed_accounts', action.id, action.accounts, action.next);
case GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS: case GROUP_REMOVED_ACCOUNTS_REMOVE_SUCCESS:
return state.updateIn(['groups_removed_accounts', action.groupId, 'items'], list => list.filterNot(item => item === action.id)); return state.updateIn(['groups_removed_accounts', action.groupId, 'items'], list => list.filterNot(item => item === action.id));
case PINNED_ACCOUNTS_FETCH_SUCCESS: case PINNED_ACCOUNTS_FETCH_SUCCESS:
return normalizeList(state, 'pinned', action.id, action.accounts, action.next); return normalizeList(state, 'pinned', action.id, action.accounts, action.next);
case BIRTHDAY_REMINDERS_FETCH_SUCCESS: case BIRTHDAY_REMINDERS_FETCH_SUCCESS:
return state.setIn(['birthday_reminders', action.id], ImmutableOrderedSet(action.accounts.map(item => item.id))); return state.setIn(['birthday_reminders', action.id], ImmutableOrderedSet(action.accounts.map(item => item.id)));
default: default:
return state; return state;
} }
} }

View File

@ -20,29 +20,29 @@ const initialState = ImmutableMap({
export default function verification(state = initialState, action) { export default function verification(state = initialState, action) {
switch (action.type) { switch (action.type) {
case PEPE_FETCH_INSTANCE_SUCCESS: case PEPE_FETCH_INSTANCE_SUCCESS:
return state.set('instance', fromJS(action.instance)); return state.set('instance', fromJS(action.instance));
case FETCH_CHALLENGES_SUCCESS: case FETCH_CHALLENGES_SUCCESS:
return state return state
.set('ageMinimum', action.ageMinimum) .set('ageMinimum', action.ageMinimum)
.set('currentChallenge', action.currentChallenge) .set('currentChallenge', action.currentChallenge)
.set('isLoading', false) .set('isLoading', false)
.set('isComplete', action.isComplete); .set('isComplete', action.isComplete);
case FETCH_TOKEN_SUCCESS: case FETCH_TOKEN_SUCCESS:
return state return state
.set('isLoading', false) .set('isLoading', false)
.set('token', action.value); .set('token', action.value);
case SET_CHALLENGES_COMPLETE: case SET_CHALLENGES_COMPLETE:
return state return state
.set('isLoading', false) .set('isLoading', false)
.set('isComplete', true); .set('isComplete', true);
case SET_NEXT_CHALLENGE: case SET_NEXT_CHALLENGE:
return state return state
.set('currentChallenge', action.challenge) .set('currentChallenge', action.challenge)
.set('isLoading', false); .set('isLoading', false);
case SET_LOADING: case SET_LOADING:
return state.set('isLoading', typeof action.value === 'boolean' ? action.value : true); return state.set('isLoading', typeof action.value === 'boolean' ? action.value : true);
default: default:
return state; return state;
} }
} }

View File

@ -85,17 +85,17 @@ export const findAccountByUsername = (state: RootState, username: string) => {
const toServerSideType = (columnType: string): string => { const toServerSideType = (columnType: string): string => {
switch (columnType) { switch (columnType) {
case 'home': case 'home':
case 'notifications': case 'notifications':
case 'public': case 'public':
case 'thread': case 'thread':
return columnType; return columnType;
default: default:
if (columnType.indexOf('list:') > -1) { if (columnType.indexOf('list:') > -1) {
return 'home'; return 'home';
} else { } else {
return 'public'; // community, account, hashtag return 'public'; // community, account, hashtag
} }
} }
}; };

View File

@ -62,7 +62,7 @@ const cloneNotification = notification => {
let k; let k;
// Object.assign() does not work with notifications // Object.assign() does not work with notifications
for(k in notification) { for (k in notification) {
clone[k] = notification[k]; clone[k] = notification[k];
} }

View File

@ -70,17 +70,17 @@ export const oneEmojiPerAccount = (emojiReacts: ImmutableList<EmojiReact>, me: M
.reverse(); .reverse();
}; };
export const filterEmoji = (emojiReacts: ImmutableList<EmojiReact>, allowedEmoji=ALLOWED_EMOJI): ImmutableList<EmojiReact> => ( export const filterEmoji = (emojiReacts: ImmutableList<EmojiReact>, allowedEmoji = ALLOWED_EMOJI): ImmutableList<EmojiReact> => (
emojiReacts.filter(emojiReact => ( emojiReacts.filter(emojiReact => (
allowedEmoji.includes(emojiReact.get('name')) allowedEmoji.includes(emojiReact.get('name'))
))); )));
export const reduceEmoji = (emojiReacts: ImmutableList<EmojiReact>, favouritesCount: number, favourited: boolean, allowedEmoji=ALLOWED_EMOJI): ImmutableList<EmojiReact> => ( export const reduceEmoji = (emojiReacts: ImmutableList<EmojiReact>, favouritesCount: number, favourited: boolean, allowedEmoji = ALLOWED_EMOJI): ImmutableList<EmojiReact> => (
filterEmoji(sortEmoji(mergeEmoji(mergeEmojiFavourites( filterEmoji(sortEmoji(mergeEmoji(mergeEmojiFavourites(
emojiReacts, favouritesCount, favourited, emojiReacts, favouritesCount, favourited,
))), allowedEmoji)); ))), allowedEmoji));
export const getReactForStatus = (status: any, allowedEmoji=ALLOWED_EMOJI): string | undefined => { export const getReactForStatus = (status: any, allowedEmoji = ALLOWED_EMOJI): string | undefined => {
const result = reduceEmoji( const result = reduceEmoji(
status.getIn(['pleroma', 'emoji_reactions'], ImmutableList()), status.getIn(['pleroma', 'emoji_reactions'], ImmutableList()),
status.get('favourites_count', 0), status.get('favourites_count', 0),

View File

@ -8,8 +8,8 @@ const truncateFilename = (url: string, maxLength: number) => {
if (filename.length <= maxLength) return filename; if (filename.length <= maxLength) return filename;
return [ return [
filename.substr(0, maxLength/2), filename.substr(0, maxLength / 2),
filename.substr(filename.length - maxLength/2), filename.substr(filename.length - maxLength / 2),
].join('…'); ].join('…');
}; };

View File

@ -15,33 +15,33 @@ const _browser_quirks: BrowserCanvasQuirks = {};
// and https://github.com/blueimp/JavaScript-Load-Image/commit/1e4df707821a0afcc11ea0720ee403b8759f3881 // and https://github.com/blueimp/JavaScript-Load-Image/commit/1e4df707821a0afcc11ea0720ee403b8759f3881
const dropOrientationIfNeeded = (orientation: number) => new Promise<number>(resolve => { const dropOrientationIfNeeded = (orientation: number) => new Promise<number>(resolve => {
switch (_browser_quirks['image-orientation-automatic']) { switch (_browser_quirks['image-orientation-automatic']) {
case true: case true:
resolve(1); resolve(1);
break; break;
case false: case false:
resolve(orientation); resolve(orientation);
break; break;
default: default:
// black 2x1 JPEG, with the following meta information set: // black 2x1 JPEG, with the following meta information set:
// - EXIF Orientation: 6 (Rotated 90° CCW) // - EXIF Orientation: 6 (Rotated 90° CCW)
const testImageURL = const testImageURL =
'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' + 'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' +
'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' + 'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' +
'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' + 'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' +
'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/x' + 'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/x' +
'ABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAA' + 'ABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAA' +
'AAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q=='; 'AAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==';
const img = new Image(); const img = new Image();
img.onload = () => { img.onload = () => {
const automatic = (img.width === 1 && img.height === 2); const automatic = (img.width === 1 && img.height === 2);
_browser_quirks['image-orientation-automatic'] = automatic; _browser_quirks['image-orientation-automatic'] = automatic;
resolve(automatic ? 1 : orientation); resolve(automatic ? 1 : orientation);
}; };
img.onerror = () => { img.onerror = () => {
_browser_quirks['image-orientation-automatic'] = false; _browser_quirks['image-orientation-automatic'] = false;
resolve(orientation); resolve(orientation);
}; };
img.src = testImageURL; img.src = testImageURL;
} }
}); });
@ -171,13 +171,13 @@ const processImage = (
} }
switch (orientation) { switch (orientation) {
case 2: context.transform(-1, 0, 0, 1, width, 0); break; case 2: context.transform(-1, 0, 0, 1, width, 0); break;
case 3: context.transform(-1, 0, 0, -1, width, height); break; case 3: context.transform(-1, 0, 0, -1, width, height); break;
case 4: context.transform(1, 0, 0, -1, 0, height); break; case 4: context.transform(1, 0, 0, -1, 0, height); break;
case 5: context.transform(0, 1, 1, 0, 0, 0); break; case 5: context.transform(0, 1, 1, 0, 0, 0); break;
case 6: context.transform(0, 1, -1, 0, height, 0); break; case 6: context.transform(0, 1, -1, 0, height, 0); break;
case 7: context.transform(0, -1, -1, 0, height, width); break; case 7: context.transform(0, -1, -1, 0, height, width); break;
case 8: context.transform(0, -1, 1, 0, 0, width); break; case 8: context.transform(0, -1, 1, 0, 0, width); break;
} }
context.drawImage(img, 0, 0, width, height); context.drawImage(img, 0, 0, width, height);

View File

@ -3,7 +3,7 @@
* @module soapbox/utils/state * @module soapbox/utils/state
*/ */
import { getSoapboxConfig } from'soapbox/actions/soapbox'; import { getSoapboxConfig } from 'soapbox/actions/soapbox';
import * as BuildConfig from 'soapbox/build_config'; import * as BuildConfig from 'soapbox/build_config';
import { isPrerendered } from 'soapbox/precheck'; import { isPrerendered } from 'soapbox/precheck';
import { isURL } from 'soapbox/utils/auth'; import { isURL } from 'soapbox/utils/auth';

View File

@ -26,42 +26,42 @@ module.exports = (api) => {
}; };
switch (env) { switch (env) {
case 'production': case 'production':
config.plugins.push(...[ config.plugins.push(...[
'lodash', 'lodash',
[ [
'transform-react-remove-prop-types', 'transform-react-remove-prop-types',
{ {
mode: 'remove', mode: 'remove',
removeImport: true, removeImport: true,
additionalLibraries: [ additionalLibraries: [
'react-immutable-proptypes', 'react-immutable-proptypes',
], ],
}, },
], ],
'@babel/transform-react-inline-elements', '@babel/transform-react-inline-elements',
[ [
'@babel/transform-runtime', '@babel/transform-runtime',
{ {
helpers: true, helpers: true,
regenerator: false, regenerator: false,
useESModules: true, useESModules: true,
}, },
], ],
]); ]);
break; break;
case 'development': case 'development':
config.plugins.push(...[ config.plugins.push(...[
'@babel/transform-react-jsx-source', '@babel/transform-react-jsx-source',
'@babel/transform-react-jsx-self', '@babel/transform-react-jsx-self',
]); ]);
break; break;
case 'test': case 'test':
config.plugins.push(...[ config.plugins.push(...[
'transform-require-context', 'transform-require-context',
]); ]);
envOptions.modules = 'commonjs'; envOptions.modules = 'commonjs';
break; break;
} }
return config; return config;

Some files were not shown because too many files have changed in this diff Show More