eslint: enforce spacing of imports (and infix ops)
This commit is contained in:
parent
2ebf735884
commit
ae01b845de
82 changed files with 109 additions and 107 deletions
|
@ -65,7 +65,9 @@ module.exports = {
|
|||
],
|
||||
'comma-style': ['warn', 'last'],
|
||||
'space-before-function-paren': ['error', 'never'],
|
||||
'space-infix-ops': 'error',
|
||||
'space-in-parens': ['error', 'never'],
|
||||
'keyword-spacing': 'error',
|
||||
'consistent-return': 'error',
|
||||
'dot-notation': 'error',
|
||||
eqeqeq: 'error',
|
||||
|
|
|
@ -67,7 +67,7 @@ export function createFilter(intl, phrase, expires_at, context, whole_word, irre
|
|||
export function deleteFilter(intl, id) {
|
||||
return (dispatch, getState) => {
|
||||
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(snackbar.success(intl.formatMessage(messages.removed)));
|
||||
}).catch(error => {
|
||||
|
|
|
@ -46,7 +46,7 @@ export const fetchInstance = createAsyncThunk<void, void, { state: RootState }>(
|
|||
dispatch(fetchNodeinfo());
|
||||
}
|
||||
return instance;
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return rejectWithValue(e);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -51,7 +51,7 @@ export function connectTimelineStream(timelineId, path, pollingRefresh = null, a
|
|||
},
|
||||
|
||||
onReceive(data) {
|
||||
switch(data.event) {
|
||||
switch (data.event) {
|
||||
case 'update':
|
||||
dispatch(processTimelineUpdate(timelineId, JSON.parse(data.payload), accept));
|
||||
break;
|
||||
|
|
|
@ -108,7 +108,7 @@ export default class AutosuggestInput extends ImmutablePureComponent {
|
|||
return;
|
||||
}
|
||||
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'Escape':
|
||||
if (suggestions.size === 0 || suggestionsHidden) {
|
||||
document.querySelector('.ui').parentElement.focus();
|
||||
|
|
|
@ -97,7 +97,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
|
|||
return;
|
||||
}
|
||||
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'Escape':
|
||||
if (suggestions.size === 0 || suggestionsHidden) {
|
||||
document.querySelector('.ui').parentElement.focus();
|
||||
|
|
|
@ -95,25 +95,25 @@ class DropdownMenu extends React.PureComponent<IDropdownMenu, IDropdownMenuState
|
|||
const index = items.indexOf(document.activeElement as any);
|
||||
let element = null;
|
||||
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'ArrowDown':
|
||||
element = items[index+1] || items[0];
|
||||
element = items[index + 1] || items[0];
|
||||
break;
|
||||
case 'ArrowUp':
|
||||
element = items[index-1] || items[items.length-1];
|
||||
element = items[index - 1] || items[items.length - 1];
|
||||
break;
|
||||
case 'Tab':
|
||||
if (e.shiftKey) {
|
||||
element = items[index-1] || items[items.length-1];
|
||||
element = items[index - 1] || items[items.length - 1];
|
||||
} else {
|
||||
element = items[index+1] || items[0];
|
||||
element = items[index + 1] || items[0];
|
||||
}
|
||||
break;
|
||||
case 'Home':
|
||||
element = items[0];
|
||||
break;
|
||||
case 'End':
|
||||
element = items[items.length-1];
|
||||
element = items[items.length - 1];
|
||||
break;
|
||||
case 'Escape':
|
||||
this.props.onClose();
|
||||
|
@ -312,7 +312,7 @@ class Dropdown extends React.PureComponent<IDropdown, IDropdownState> {
|
|||
}
|
||||
|
||||
handleButtonKeyDown: React.EventHandler<React.KeyboardEvent> = (e) => {
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case ' ':
|
||||
case 'Enter':
|
||||
this.handleMouseDown(e);
|
||||
|
@ -321,7 +321,7 @@ class Dropdown extends React.PureComponent<IDropdown, IDropdownState> {
|
|||
}
|
||||
|
||||
handleKeyPress: React.EventHandler<React.KeyboardEvent<HTMLButtonElement>> = (e) => {
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case ' ':
|
||||
case 'Enter':
|
||||
this.handleClick(e);
|
||||
|
|
|
@ -56,12 +56,12 @@ class FilterBar extends React.PureComponent {
|
|||
const index = items.indexOf(document.activeElement);
|
||||
let element = null;
|
||||
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'ArrowRight':
|
||||
element = items[index+1] || items[0];
|
||||
element = items[index + 1] || items[0];
|
||||
break;
|
||||
case 'ArrowLeft':
|
||||
element = items[index-1] || items[items.length-1];
|
||||
element = items[index - 1] || items[items.length - 1];
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 FaviconService from 'soapbox/utils/favicon_service';
|
||||
|
|
|
@ -337,7 +337,7 @@ class MediaGallery extends React.PureComponent {
|
|||
const aspectRatio = media.getIn([0, 'meta', 'original', 'aspect']);
|
||||
|
||||
const getHeight = () => {
|
||||
if (!aspectRatio) return width*9/16;
|
||||
if (!aspectRatio) return width * 9 / 16;
|
||||
if (isPanoramic(aspectRatio)) return Math.floor(width / maximumAspectRatio);
|
||||
if (isPortrait(aspectRatio)) return Math.floor(width / minimumAspectRatio);
|
||||
return Math.floor(width / aspectRatio);
|
||||
|
|
|
@ -143,7 +143,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
|
|||
<Link to='/' onClick={onClose}>
|
||||
{logo ? (
|
||||
<img alt='Logo' src={logo} className='h-5 w-auto cursor-pointer' />
|
||||
): (
|
||||
) : (
|
||||
<Icon
|
||||
alt='Logo'
|
||||
src={require('@tabler/icons/icons/home.svg')}
|
||||
|
|
|
@ -673,7 +673,7 @@ class StatusActionBar extends ImmutablePureComponent<IStatusActionBar, IStatusAc
|
|||
count={emojiReactCount}
|
||||
/>
|
||||
</EmojiButtonWrapper>
|
||||
): (
|
||||
) : (
|
||||
<StatusActionButton
|
||||
title={intl.formatMessage(messages.favourite)}
|
||||
icon={require('@tabler/icons/icons/heart.svg')}
|
||||
|
|
|
@ -85,7 +85,7 @@ class Audio extends React.PureComponent {
|
|||
|
||||
_setDimensions() {
|
||||
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) {
|
||||
this.props.cacheWidth(width);
|
||||
|
@ -412,7 +412,7 @@ class Audio extends React.PureComponent {
|
|||
}
|
||||
|
||||
handleKeyDown = e => {
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'k':
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
|
|
@ -40,7 +40,7 @@ export default class Visualizer {
|
|||
getTickPoints(count) {
|
||||
const coords = [];
|
||||
|
||||
for(let i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
const rad = Math.PI * 2 * i / count;
|
||||
coords.push({ x: Math.cos(rad), y: -Math.sin(rad) });
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ const CaptchaField: React.FC<ICaptchaField> = ({
|
|||
onFetch = noOp,
|
||||
onFetchFail = noOp,
|
||||
onClick = noOp,
|
||||
refreshInterval = 5*60*1000, // 5 minutes, Pleroma default
|
||||
refreshInterval = 5 * 60 * 1000, // 5 minutes, Pleroma default
|
||||
idempotencyKey,
|
||||
}) => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
@ -71,7 +71,7 @@ const CaptchaField: React.FC<ICaptchaField> = ({
|
|||
};
|
||||
}, [idempotencyKey]);
|
||||
|
||||
switch(captcha.get('type')) {
|
||||
switch (captcha.get('type')) {
|
||||
case 'native':
|
||||
return (
|
||||
<div>
|
||||
|
|
|
@ -132,7 +132,7 @@ class ChatBox extends ImmutablePureComponent {
|
|||
|
||||
onUploadProgress = (e) => {
|
||||
const { loaded, total } = e;
|
||||
this.setState({ uploadProgress: loaded/total });
|
||||
this.setState({ uploadProgress: loaded / total });
|
||||
}
|
||||
|
||||
handleFiles = (files) => {
|
||||
|
@ -193,7 +193,7 @@ class ChatBox extends ImmutablePureComponent {
|
|||
<div className='chat-box' onMouseOver={this.handleHover}>
|
||||
<ChatMessageList chatMessageIds={chatMessageIds} chatId={chatId} />
|
||||
{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__send'>
|
||||
{this.renderActionButton()}
|
||||
|
|
|
@ -314,11 +314,11 @@ class ChatMessageList extends ImmutablePureComponent {
|
|||
return (
|
||||
<div className='chat-messages' ref={this.setRef}>
|
||||
{chatMessages.reduce((acc, curr, idx) => {
|
||||
const lastMessage = chatMessages.get(idx-1);
|
||||
const lastMessage = chatMessages.get(idx - 1);
|
||||
|
||||
if (lastMessage) {
|
||||
const key = `${curr.get('id')}_divider`;
|
||||
switch(timeChange(lastMessage, curr)) {
|
||||
switch (timeChange(lastMessage, curr)) {
|
||||
case 'today':
|
||||
acc.push(this.renderDivider(key, intl.formatMessage(messages.today)));
|
||||
break;
|
||||
|
|
|
@ -55,7 +55,7 @@ class PrivacyDropdownMenu extends React.PureComponent {
|
|||
});
|
||||
let element = null;
|
||||
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'Escape':
|
||||
this.props.onClose();
|
||||
break;
|
||||
|
@ -211,7 +211,7 @@ class PrivacyDropdown extends React.PureComponent {
|
|||
}
|
||||
|
||||
handleKeyDown = e => {
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'Escape':
|
||||
this.handleClose();
|
||||
break;
|
||||
|
@ -225,7 +225,7 @@ class PrivacyDropdown extends React.PureComponent {
|
|||
}
|
||||
|
||||
handleButtonKeyDown = (e) => {
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case ' ':
|
||||
case 'Enter':
|
||||
this.handleMouseDown();
|
||||
|
|
|
@ -158,7 +158,7 @@ class Upload extends ImmutablePureComponent {
|
|||
className={classNames('compose-form__upload-thumbnail', `${mediaType}`)}
|
||||
style={{
|
||||
transform: `scale(${scale})`,
|
||||
backgroundImage: mediaType === 'image' ? `url(${media.get('preview_url')})`: null,
|
||||
backgroundImage: mediaType === 'image' ? `url(${media.get('preview_url')})` : null,
|
||||
backgroundPosition: `${x}% ${y}%` }}
|
||||
>
|
||||
<div className={classNames('compose-form__upload__actions', { active })}>
|
||||
|
|
|
@ -177,8 +177,8 @@ export const urlRegex = (function() {
|
|||
'(?:' +
|
||||
'#{validGeneralUrlPathChars}*' +
|
||||
'(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*' +
|
||||
'#{validUrlPathEndingChars}'+
|
||||
')|(?:@#{validGeneralUrlPathChars}+\/)'+
|
||||
'#{validUrlPathEndingChars}' +
|
||||
')|(?:@#{validGeneralUrlPathChars}+\/)' +
|
||||
')', 'i');
|
||||
regexen.validUrlQueryChars = /[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i;
|
||||
regexen.validUrlQueryEndingChars = /[a-z0-9_&=#\/]/i;
|
||||
|
|
|
@ -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' />}
|
||||
>
|
||||
<Toggle
|
||||
checked={account ? hidesNetwork(account): false}
|
||||
checked={account ? hidesNetwork(account) : false}
|
||||
onChange={handleHideNetworkChange}
|
||||
/>
|
||||
</ListItem>
|
||||
|
|
|
@ -22,7 +22,7 @@ const moneyFormat = (amount: number): string => (
|
|||
currency: 'usd',
|
||||
notation: 'compact',
|
||||
})
|
||||
.format(amount/100)
|
||||
.format(amount / 100)
|
||||
);
|
||||
|
||||
const FundingPanel: React.FC = () => {
|
||||
|
@ -59,7 +59,7 @@ const FundingPanel: React.FC = () => {
|
|||
<div className='funding-panel__ratio'>
|
||||
<Text>{ratioText}</Text>
|
||||
</div>
|
||||
<ProgressBar progress={amount/goal} />
|
||||
<ProgressBar progress={amount / goal} />
|
||||
<div className='funding-panel__description'>
|
||||
<Text>{goalText}</Text>
|
||||
</div>
|
||||
|
|
|
@ -57,7 +57,7 @@ class MediaModal extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
handleKeyDown = (e) => {
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'ArrowLeft':
|
||||
this.handlePrevClick();
|
||||
e.preventDefault();
|
||||
|
|
|
@ -20,7 +20,7 @@ const UploadArea: React.FC<IUploadArea> = ({ active, onClose }) => {
|
|||
const keyCode = e.keyCode;
|
||||
|
||||
if (active) {
|
||||
switch(keyCode) {
|
||||
switch (keyCode) {
|
||||
case 27:
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
|
|
@ -290,7 +290,7 @@ class Video extends React.PureComponent {
|
|||
handleKeyDown = e => {
|
||||
const frameTime = 1 / 25;
|
||||
|
||||
switch(e.key) {
|
||||
switch (e.key) {
|
||||
case 'k':
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
@ -505,7 +505,7 @@ class Video extends React.PureComponent {
|
|||
|
||||
if (inline && containerWidth) {
|
||||
width = containerWidth;
|
||||
const minSize = containerWidth / (16/9);
|
||||
const minSize = containerWidth / (16 / 9);
|
||||
|
||||
if (isPanoramic(aspectRatio)) {
|
||||
height = Math.max(Math.floor(containerWidth / maximumAspectRatio), minSize);
|
||||
|
|
|
@ -93,7 +93,7 @@ const addTags = (
|
|||
);
|
||||
|
||||
tags.forEach(tag => {
|
||||
switch(tag) {
|
||||
switch (tag) {
|
||||
case 'verified':
|
||||
state.setIn([id, 'verified'], true);
|
||||
break;
|
||||
|
@ -118,7 +118,7 @@ const removeTags = (
|
|||
);
|
||||
|
||||
tags.forEach(tag => {
|
||||
switch(tag) {
|
||||
switch (tag) {
|
||||
case 'verified':
|
||||
state.setIn([id, 'verified'], false);
|
||||
break;
|
||||
|
@ -243,7 +243,7 @@ const setSuggested = (state: State, accountIds: Array<string>, isSuggested: bool
|
|||
};
|
||||
|
||||
export default function accounts(state: State = initialState, action: AnyAction): State {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ACCOUNT_IMPORT:
|
||||
return fixAccount(state, action.account);
|
||||
case ACCOUNTS_IMPORT:
|
||||
|
|
|
@ -36,7 +36,7 @@ const updateFollowCounters = (state, counterUpdates) => {
|
|||
const initialState = ImmutableMap();
|
||||
|
||||
export default function accountsCounters(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ACCOUNT_IMPORT:
|
||||
return normalizeAccount(state, action.account);
|
||||
case ACCOUNTS_IMPORT:
|
||||
|
|
|
@ -20,7 +20,7 @@ const importAccount = (state, account) => {
|
|||
};
|
||||
|
||||
export default function accounts_meta(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ME_FETCH_SUCCESS:
|
||||
case ME_PATCH_SUCCESS:
|
||||
return importAccount(state, fromJS(action.me));
|
||||
|
|
|
@ -137,7 +137,7 @@ function handleReportDiffs(state: State, reports: APIReport[]) {
|
|||
// hence the need for a new function.
|
||||
return state.withMutations(state => {
|
||||
reports.forEach(report => {
|
||||
switch(report.state) {
|
||||
switch (report.state) {
|
||||
case 'open':
|
||||
state.update('openReports', orderedSet => orderedSet.add(report.id));
|
||||
break;
|
||||
|
@ -159,7 +159,7 @@ const importConfigs = (state: State, configs: any): 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_UPDATE_SUCCESS:
|
||||
return importConfigs(state, action.configs);
|
||||
|
|
|
@ -36,7 +36,7 @@ const importItems = (state, items, total) => {
|
|||
};
|
||||
|
||||
export default function admin_log(state = ReducerRecord(), action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ADMIN_LOG_FETCH_SUCCESS:
|
||||
return importItems(state, action.items, action.total);
|
||||
default:
|
||||
|
|
|
@ -40,7 +40,7 @@ const deleteAlert = (state: State, alert: PlainAlert): State => {
|
|||
};
|
||||
|
||||
export default function alerts(state: State = ImmutableList<Alert>(), action: AnyAction): State {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ALERT_SHOW:
|
||||
return importAlert(state, action);
|
||||
case ALERT_DISMISS:
|
||||
|
|
|
@ -20,7 +20,7 @@ const initialState = ImmutableMap({
|
|||
});
|
||||
|
||||
export default function aliasesReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ALIASES_FETCH_SUCCESS:
|
||||
return state
|
||||
.setIn(['aliases', 'items'], action.value);
|
||||
|
|
|
@ -282,7 +282,7 @@ const deleteForbiddenToken = (state, error, token) => {
|
|||
};
|
||||
|
||||
const reducer = (state, action) => {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case AUTH_APP_CREATED:
|
||||
return state.set('app', fromJS(action.app));
|
||||
case AUTH_APP_AUTHORIZED:
|
||||
|
|
|
@ -18,7 +18,7 @@ const importBackups = (state, backups) => {
|
|||
};
|
||||
|
||||
export default function backups(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case BACKUPS_FETCH_SUCCESS:
|
||||
case BACKUPS_CREATE_SUCCESS:
|
||||
return importBackups(state, fromJS(action.backups));
|
||||
|
|
|
@ -51,7 +51,7 @@ const replaceMessage = (state: State, chatId: string, oldId: string, newId: stri
|
|||
};
|
||||
|
||||
export default function chatMessageLists(state = initialState, action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case CHAT_MESSAGE_SEND_REQUEST:
|
||||
return updateList(state, action.chatId, [action.uuid]);
|
||||
case CHATS_FETCH_SUCCESS:
|
||||
|
|
|
@ -37,7 +37,7 @@ const importLastMessages = (state: State, chats: APIEntities) =>
|
|||
const initialState: State = ImmutableMap();
|
||||
|
||||
export default function chatMessages(state = initialState, action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case CHAT_MESSAGE_SEND_REQUEST:
|
||||
return importMessage(state, fromJS({
|
||||
id: action.uuid, // Make fake message to get overriden later
|
||||
|
|
|
@ -55,7 +55,7 @@ const importChats = (state: State, chats: APIEntities, next?: string) =>
|
|||
});
|
||||
|
||||
export default function chats(state: State = ReducerRecord(), action: AnyAction): State {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case CHATS_FETCH_REQUEST:
|
||||
case CHATS_EXPAND_REQUEST:
|
||||
return state.set('isLoading', true);
|
||||
|
|
|
@ -283,7 +283,7 @@ const updateSetting = (state, path, value) => {
|
|||
};
|
||||
|
||||
export default function compose(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case COMPOSE_MOUNT:
|
||||
return state.set('mounted', state.get('mounted') + 1);
|
||||
case COMPOSE_UNMOUNT:
|
||||
|
|
|
@ -141,7 +141,7 @@ const deletePendingStatus = (state, { in_reply_to_id }, idempotencyKey) => {
|
|||
};
|
||||
|
||||
export default function replies(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
return filterContexts(state, action.relationship, action.statuses);
|
||||
|
|
|
@ -13,7 +13,7 @@ const initialState = ImmutableMap({
|
|||
});
|
||||
|
||||
export default function domainLists(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case DOMAIN_BLOCKS_FETCH_SUCCESS:
|
||||
return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.domains)).setIn(['blocks', 'next'], action.next);
|
||||
case DOMAIN_BLOCKS_EXPAND_SUCCESS:
|
||||
|
|
|
@ -16,7 +16,7 @@ const importFilters = (_state: State, filters: unknown): State => {
|
|||
};
|
||||
|
||||
export default function filters(state: State = ImmutableList<Filter>(), action: AnyAction): State {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case FILTERS_FETCH_SUCCESS:
|
||||
return importFilters(state, action.filters);
|
||||
default:
|
||||
|
|
|
@ -22,7 +22,7 @@ const initialState = ImmutableMap({
|
|||
});
|
||||
|
||||
export default function groupEditorReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case GROUP_EDITOR_RESET:
|
||||
return initialState;
|
||||
case GROUP_EDITOR_SETUP:
|
||||
|
|
|
@ -13,7 +13,7 @@ const normalizeList = (state, type, id, groups) => {
|
|||
};
|
||||
|
||||
export default function groupLists(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case GROUPS_FETCH_SUCCESS:
|
||||
return normalizeList(state, action.tab, action.id, action.groups);
|
||||
default:
|
||||
|
|
|
@ -15,7 +15,7 @@ const normalizeRelationships = (state, relationships) => {
|
|||
const initialState = ImmutableMap();
|
||||
|
||||
export default function group_relationships(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case GROUP_JOIN_SUCCESS:
|
||||
case GROUP_LEAVE_SUCCESS:
|
||||
return normalizeRelationship(state, action.relationship);
|
||||
|
|
|
@ -20,7 +20,7 @@ const normalizeGroups = (state, groups) => {
|
|||
};
|
||||
|
||||
export default function groups(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case GROUP_FETCH_SUCCESS:
|
||||
case GROUP_UPDATE_SUCCESS:
|
||||
return normalizeGroup(state, action.group);
|
||||
|
|
|
@ -16,7 +16,7 @@ type State = ImmutableMap<string, ReturnType<typeof HistoryRecord>>;
|
|||
const initialState: State = ImmutableMap();
|
||||
|
||||
export default function history(state: State = initialState, action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case HISTORY_FETCH_REQUEST:
|
||||
return state.update(action.statusId, HistoryRecord(), history => history!.withMutations(map => {
|
||||
map.set('loading', true);
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
const initialState = ImmutableMap();
|
||||
|
||||
export default function identityProofsReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST:
|
||||
return state.set('isLoading', true);
|
||||
case IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL:
|
||||
|
|
|
@ -152,7 +152,7 @@ const logOut = (state: any = StateRecord()): ReturnType<typeof appReducer> => {
|
|||
};
|
||||
|
||||
const rootReducer: typeof appReducer = (state, action) => {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case AUTH_LOGGED_OUT:
|
||||
return appReducer(logOut(state), action);
|
||||
default:
|
||||
|
|
|
@ -111,7 +111,7 @@ const handleInstanceFetchFail = (state: typeof initialState, error: Record<strin
|
|||
};
|
||||
|
||||
export default function instance(state = initialState, action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case PLEROMA_PRELOAD_IMPORT:
|
||||
return preloadImport(state, action, '/api/v1/instance');
|
||||
case rememberInstance.fulfilled.type:
|
||||
|
|
|
@ -26,7 +26,7 @@ const ReducerRecord = ImmutableRecord({
|
|||
type State = ReturnType<typeof ReducerRecord>;
|
||||
|
||||
export default function listAdderReducer(state: State = ReducerRecord(), action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case LIST_ADDER_RESET:
|
||||
return ReducerRecord();
|
||||
case LIST_ADDER_SETUP:
|
||||
|
|
|
@ -46,7 +46,7 @@ const ReducerRecord = ImmutableRecord({
|
|||
type State = ReturnType<typeof ReducerRecord>;
|
||||
|
||||
export default function listEditorReducer(state: State = ReducerRecord(), action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case LIST_EDITOR_RESET:
|
||||
return ReducerRecord();
|
||||
case LIST_EDITOR_SETUP:
|
||||
|
|
|
@ -30,7 +30,7 @@ const importLists = (state: State, lists: APIEntities) => {
|
|||
};
|
||||
|
||||
export default function lists(state: State = initialState, action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case LIST_FETCH_SUCCESS:
|
||||
case LIST_CREATE_SUCCESS:
|
||||
case LIST_UPDATE_SUCCESS:
|
||||
|
|
|
@ -25,7 +25,7 @@ const handleForbidden = (state: Me, error: AxiosError) => {
|
|||
};
|
||||
|
||||
export default function me(state: Me = initialState, action: AnyAction): Me {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ME_FETCH_SUCCESS:
|
||||
case ME_PATCH_SUCCESS:
|
||||
return action.me.id;
|
||||
|
|
|
@ -11,7 +11,7 @@ const ReducerRecord = ImmutableRecord({
|
|||
});
|
||||
|
||||
export default function meta(state = ReducerRecord(), action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case fetchInstance.rejected.type:
|
||||
if (action.payload.response?.status === 404) {
|
||||
return state.set('instance_fetch_failed', true);
|
||||
|
|
|
@ -5,7 +5,7 @@ import { MODAL_OPEN, MODAL_CLOSE } from '../actions/modals';
|
|||
const initialState = ImmutableList();
|
||||
|
||||
export default function modal(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case MODAL_OPEN:
|
||||
return state.push({ modalType: action.modalType, modalProps: action.modalProps });
|
||||
case MODAL_CLOSE:
|
||||
|
|
|
@ -183,7 +183,7 @@ const importMarker = (state, marker) => {
|
|||
};
|
||||
|
||||
export default function notifications(state = ReducerRecord(), action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case NOTIFICATIONS_EXPAND_REQUEST:
|
||||
return state.set('isLoading', true);
|
||||
case NOTIFICATIONS_EXPAND_FAIL:
|
||||
|
|
|
@ -11,7 +11,7 @@ const initialState: OnboardingState = {
|
|||
};
|
||||
|
||||
export default function onboarding(state: OnboardingState = initialState, action: OnboardingActions): OnboardingState {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ONBOARDING_START:
|
||||
return { ...state, needsOnboarding: true };
|
||||
case ONBOARDING_END:
|
||||
|
|
|
@ -39,7 +39,7 @@ const normalizePatronAccount = (state: State, account: Record<string, any>) => {
|
|||
};
|
||||
|
||||
export default function patron(state = ReducerRecord(), action: AnyAction) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case PATRON_INSTANCE_FETCH_SUCCESS:
|
||||
return state.set('instance', PatronInstanceRecord(ImmutableMap(fromJS(action.instance))));
|
||||
case PATRON_ACCOUNT_FETCH_SUCCESS:
|
||||
|
|
|
@ -14,7 +14,7 @@ const deleteStatus = (state, idempotencyKey) => state.delete(idempotencyKey);
|
|||
const initialState = ImmutableMap();
|
||||
|
||||
export default function pending_statuses(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case STATUS_CREATE_REQUEST:
|
||||
return importStatus(state, fromJS(action.params), action.idempotencyKey);
|
||||
case STATUS_CREATE_SUCCESS:
|
||||
|
|
|
@ -30,7 +30,7 @@ const importPolls = (state: State, polls: Array<APIEntity>) => {
|
|||
const initialState: State = ImmutableMap();
|
||||
|
||||
export default function polls(state: State = initialState, action: AnyAction): State {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case POLLS_IMPORT:
|
||||
return importPolls(state, action.polls);
|
||||
default:
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
const initialState = ImmutableMap();
|
||||
|
||||
export default function profileHoverCard(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case PROFILE_HOVER_CARD_OPEN:
|
||||
return ImmutableMap({
|
||||
ref: action.ref,
|
||||
|
|
|
@ -17,7 +17,7 @@ const initialState = ImmutableMap({
|
|||
});
|
||||
|
||||
export default function push_subscriptions(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case SET_SUBSCRIPTION:
|
||||
return state
|
||||
.set('subscription', new ImmutableMap({
|
||||
|
|
|
@ -64,7 +64,7 @@ const importPleromaAccounts = (state, accounts) => {
|
|||
};
|
||||
|
||||
const followStateToRelationship = followState => {
|
||||
switch(followState) {
|
||||
switch (followState) {
|
||||
case 'follow_pending':
|
||||
return { following: false, requested: true };
|
||||
case 'follow_accept':
|
||||
|
@ -84,7 +84,7 @@ const updateFollowRelationship = (state, id, followState) => {
|
|||
const initialState = ImmutableMap();
|
||||
|
||||
export default function relationships(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ACCOUNT_IMPORT:
|
||||
return importPleromaAccount(state, action.account);
|
||||
case ACCOUNTS_IMPORT:
|
||||
|
|
|
@ -26,7 +26,7 @@ const initialState = ImmutableMap({
|
|||
});
|
||||
|
||||
export default function reports(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case REPORT_INIT:
|
||||
return state.withMutations(map => {
|
||||
map.setIn(['new', 'isSubmitting'], false);
|
||||
|
|
|
@ -22,7 +22,7 @@ const deleteStatus = (state, id) => state.delete(id);
|
|||
const initialState = ImmutableMap();
|
||||
|
||||
export default function scheduled_statuses(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case STATUS_IMPORT:
|
||||
case STATUS_CREATE_SUCCESS:
|
||||
return importStatus(state, action.status);
|
||||
|
|
|
@ -77,7 +77,7 @@ const handleSubmitted = (state, value) => {
|
|||
};
|
||||
|
||||
export default function search(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case SEARCH_CHANGE:
|
||||
return state.set('value', action.value);
|
||||
case SEARCH_CLEAR:
|
||||
|
|
|
@ -38,7 +38,7 @@ const disableMfa = (state, method) => {
|
|||
};
|
||||
|
||||
export default function security(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case FETCH_TOKENS_SUCCESS:
|
||||
return state.set('tokens', fromJS(action.tokens));
|
||||
case REVOKE_TOKEN_SUCCESS:
|
||||
|
|
|
@ -29,7 +29,7 @@ const importSettings = (state, account) => {
|
|||
};
|
||||
|
||||
export default function settings(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case ME_FETCH_SUCCESS:
|
||||
return importSettings(state, action.me);
|
||||
case NOTIFICATIONS_FILTER_SET:
|
||||
|
|
|
@ -11,7 +11,7 @@ const initialState: State = {
|
|||
};
|
||||
|
||||
export default function sidebar(state: State = initialState, action: AnyAction): State {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case SIDEBAR_OPEN:
|
||||
return { sidebarOpen: true };
|
||||
case SIDEBAR_CLOSE:
|
||||
|
|
|
@ -52,7 +52,7 @@ const importSoapboxConfig = (state, soapboxConfig, host) => {
|
|||
};
|
||||
|
||||
export default function soapbox(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case PLEROMA_PRELOAD_IMPORT:
|
||||
return preloadImport(state, action);
|
||||
case SOAPBOX_CONFIG_REMEMBER_SUCCESS:
|
||||
|
|
|
@ -97,7 +97,7 @@ const removeOneFromList = (state, listType, status) => {
|
|||
};
|
||||
|
||||
export default function statusLists(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case FAVOURITED_STATUSES_FETCH_REQUEST:
|
||||
case FAVOURITED_STATUSES_EXPAND_REQUEST:
|
||||
return setLoading(state, 'favourites', true);
|
||||
|
|
|
@ -194,7 +194,7 @@ const simulateFavourite = (
|
|||
const initialState: State = ImmutableMap();
|
||||
|
||||
export default function statuses(state = initialState, action: AnyAction): State {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case STATUS_IMPORT:
|
||||
return importStatus(state, action.status, action.expandSpoilers);
|
||||
case STATUSES_IMPORT:
|
||||
|
|
|
@ -49,7 +49,7 @@ const dismissAccounts = (state, accountIds) => {
|
|||
};
|
||||
|
||||
export default function suggestionsReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case SUGGESTIONS_FETCH_REQUEST:
|
||||
case SUGGESTIONS_V2_FETCH_REQUEST:
|
||||
return state.set('isLoading', true);
|
||||
|
|
|
@ -233,7 +233,7 @@ const timelineDisconnect = (state, timelineId) => {
|
|||
};
|
||||
|
||||
const getTimelinesByVisibility = visibility => {
|
||||
switch(visibility) {
|
||||
switch (visibility) {
|
||||
case 'direct':
|
||||
return ['direct'];
|
||||
case 'public':
|
||||
|
@ -299,7 +299,7 @@ const handleExpandFail = (state, timelineId) => {
|
|||
};
|
||||
|
||||
export default function timelines(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case STATUS_CREATE_REQUEST:
|
||||
if (action.params.scheduled_at) return state;
|
||||
return importPendingStatus(state, action.params, action.idempotencyKey);
|
||||
|
|
|
@ -20,7 +20,7 @@ const importStatuses = (state, statuses) => {
|
|||
};
|
||||
|
||||
export default function trending_statuses(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case TRENDING_STATUSES_FETCH_REQUEST:
|
||||
return state.set('isLoading', true);
|
||||
case TRENDING_STATUSES_FETCH_SUCCESS:
|
||||
|
|
|
@ -12,7 +12,7 @@ const initialState = ImmutableMap({
|
|||
});
|
||||
|
||||
export default function trendsReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case TRENDS_FETCH_REQUEST:
|
||||
return state.set('isLoading', true);
|
||||
case TRENDS_FETCH_SUCCESS:
|
||||
|
|
|
@ -82,7 +82,7 @@ const normalizeFollowRequest = (state, notification) => {
|
|||
};
|
||||
|
||||
export default function userLists(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
switch (action.type) {
|
||||
case FOLLOWERS_FETCH_SUCCESS:
|
||||
return normalizeList(state, 'followers', action.id, action.accounts, action.next);
|
||||
case FOLLOWERS_EXPAND_SUCCESS:
|
||||
|
|
|
@ -62,7 +62,7 @@ const cloneNotification = notification => {
|
|||
let k;
|
||||
|
||||
// Object.assign() does not work with notifications
|
||||
for(k in notification) {
|
||||
for (k in notification) {
|
||||
clone[k] = notification[k];
|
||||
}
|
||||
|
||||
|
|
|
@ -70,17 +70,17 @@ export const oneEmojiPerAccount = (emojiReacts: ImmutableList<EmojiReact>, me: M
|
|||
.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 => (
|
||||
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(
|
||||
emojiReacts, favouritesCount, favourited,
|
||||
))), allowedEmoji));
|
||||
|
||||
export const getReactForStatus = (status: any, allowedEmoji=ALLOWED_EMOJI): string | undefined => {
|
||||
export const getReactForStatus = (status: any, allowedEmoji = ALLOWED_EMOJI): string | undefined => {
|
||||
const result = reduceEmoji(
|
||||
status.getIn(['pleroma', 'emoji_reactions'], ImmutableList()),
|
||||
status.get('favourites_count', 0),
|
||||
|
|
|
@ -8,8 +8,8 @@ const truncateFilename = (url: string, maxLength: number) => {
|
|||
if (filename.length <= maxLength) return filename;
|
||||
|
||||
return [
|
||||
filename.substr(0, maxLength/2),
|
||||
filename.substr(filename.length - maxLength/2),
|
||||
filename.substr(0, maxLength / 2),
|
||||
filename.substr(filename.length - maxLength / 2),
|
||||
].join('…');
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @module soapbox/utils/state
|
||||
*/
|
||||
|
||||
import { getSoapboxConfig } from'soapbox/actions/soapbox';
|
||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||
import * as BuildConfig from 'soapbox/build_config';
|
||||
import { isPrerendered } from 'soapbox/precheck';
|
||||
import { isURL } from 'soapbox/utils/auth';
|
||||
|
|
|
@ -2,7 +2,7 @@ require('dotenv').config();
|
|||
|
||||
const { NODE_ENV } = process.env;
|
||||
|
||||
switch(NODE_ENV) {
|
||||
switch (NODE_ENV) {
|
||||
case 'development':
|
||||
case 'production':
|
||||
case 'test':
|
||||
|
|
Loading…
Reference in a new issue