Fix some more JS linting issues (#2211)
* Minor refactor and linting fixup in `flavours/glitch/actions/accounts.js` This is some added boilerplate but it's much more consistent with the remaining of the code, and avoids the linting issue. * Fix missing /privacy-policy link in DM warning because of wrongly-named import * Fix unnecessary import * Fix regexp in flavours/glitch/utils/hashtag.jspull/2212/head
parent
de74acbe0c
commit
16c5354b8c
|
@ -81,7 +81,10 @@ export const PINNED_ACCOUNTS_FETCH_REQUEST = 'PINNED_ACCOUNTS_FETCH_REQUEST';
|
||||||
export const PINNED_ACCOUNTS_FETCH_SUCCESS = 'PINNED_ACCOUNTS_FETCH_SUCCESS';
|
export const PINNED_ACCOUNTS_FETCH_SUCCESS = 'PINNED_ACCOUNTS_FETCH_SUCCESS';
|
||||||
export const PINNED_ACCOUNTS_FETCH_FAIL = 'PINNED_ACCOUNTS_FETCH_FAIL';
|
export const PINNED_ACCOUNTS_FETCH_FAIL = 'PINNED_ACCOUNTS_FETCH_FAIL';
|
||||||
|
|
||||||
export const PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_READY = 'PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_READY';
|
export const PINNED_ACCOUNTS_SUGGESTIONS_FETCH_REQUEST = 'PINNED_ACCOUNTS_SUGGESTIONS_FETCH_REQUEST';
|
||||||
|
export const PINNED_ACCOUNTS_SUGGESTIONS_FETCH_SUCCESS = 'PINNED_ACCOUNTS_SUGGESTIONS_FETCH_SUCCESS';
|
||||||
|
export const PINNED_ACCOUNTS_SUGGESTIONS_FETCH_FAIL = 'PINNED_ACCOUNTS_SUGGESTIONS_FETCH_FAIL';
|
||||||
|
|
||||||
export const PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR = 'PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR';
|
export const PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR = 'PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR';
|
||||||
export const PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CHANGE = 'PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CHANGE';
|
export const PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CHANGE = 'PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CHANGE';
|
||||||
|
|
||||||
|
@ -841,6 +844,8 @@ export function fetchPinnedAccountsFail(error) {
|
||||||
|
|
||||||
export function fetchPinnedAccountsSuggestions(q) {
|
export function fetchPinnedAccountsSuggestions(q) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
|
dispatch(fetchPinnedAccountsSuggestionsRequest());
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
q,
|
q,
|
||||||
resolve: false,
|
resolve: false,
|
||||||
|
@ -850,19 +855,32 @@ export function fetchPinnedAccountsSuggestions(q) {
|
||||||
|
|
||||||
api(getState).get('/api/v1/accounts/search', { params }).then(response => {
|
api(getState).get('/api/v1/accounts/search', { params }).then(response => {
|
||||||
dispatch(importFetchedAccounts(response.data));
|
dispatch(importFetchedAccounts(response.data));
|
||||||
dispatch(fetchPinnedAccountsSuggestionsReady(q, response.data));
|
dispatch(fetchPinnedAccountsSuggestionsSuccess(q, response.data));
|
||||||
});
|
}).catch(err => dispatch(fetchPinnedAccountsSuggestionsFail(err)));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchPinnedAccountsSuggestionsReady(query, accounts) {
|
export function fetchPinnedAccountsSuggestionsRequest() {
|
||||||
return {
|
return {
|
||||||
type: PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_READY,
|
type: PINNED_ACCOUNTS_SUGGESTIONS_FETCH_REQUEST,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchPinnedAccountsSuggestionsSuccess(query, accounts) {
|
||||||
|
return {
|
||||||
|
type: PINNED_ACCOUNTS_SUGGESTIONS_FETCH_SUCCESS,
|
||||||
query,
|
query,
|
||||||
accounts,
|
accounts,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fetchPinnedAccountsSuggestionsFail(error) {
|
||||||
|
return {
|
||||||
|
type: PINNED_ACCOUNTS_SUGGESTIONS_FETCH_FAIL,
|
||||||
|
error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function clearPinnedAccountsSuggestions() {
|
export function clearPinnedAccountsSuggestions() {
|
||||||
return {
|
return {
|
||||||
type: PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR,
|
type: PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR,
|
||||||
|
|
|
@ -10,7 +10,6 @@ import Icon from 'flavours/glitch/components/icon';
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
import IconButton from 'flavours/glitch/components/icon_button';
|
||||||
import Avatar from 'flavours/glitch/components/avatar';
|
import Avatar from 'flavours/glitch/components/avatar';
|
||||||
import Button from 'flavours/glitch/components/button';
|
import Button from 'flavours/glitch/components/button';
|
||||||
import { NavLink } from 'react-router-dom';
|
|
||||||
import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container';
|
import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container';
|
||||||
import AccountNoteContainer from '../containers/account_note_container';
|
import AccountNoteContainer from '../containers/account_note_container';
|
||||||
import FollowRequestNoteContainer from '../containers/follow_request_note_container';
|
import FollowRequestNoteContainer from '../containers/follow_request_note_container';
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Warning from '../components/warning';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { me } from 'flavours/glitch/initial_state';
|
import { me } from 'flavours/glitch/initial_state';
|
||||||
import { profileLink, termsLink } from 'flavours/glitch/utils/backend_links';
|
import { profileLink, privacyPolicyLink } from 'flavours/glitch/utils/backend_links';
|
||||||
|
|
||||||
const buildHashtagRE = () => {
|
const buildHashtagRE = () => {
|
||||||
try {
|
try {
|
||||||
|
@ -49,7 +49,7 @@ const WarningWrapper = ({ needsLockWarning, hashtagWarning, directMessageWarning
|
||||||
if (directMessageWarning) {
|
if (directMessageWarning) {
|
||||||
const message = (
|
const message = (
|
||||||
<span>
|
<span>
|
||||||
<FormattedMessage id='compose_form.encryption_warning' defaultMessage='Posts on Mastodon are not end-to-end encrypted. Do not share any dangerous information over Mastodon.' /> {!!termsLink && <a href={termsLink} target='_blank'><FormattedMessage id='compose_form.direct_message_warning_learn_more' defaultMessage='Learn more' /></a>}
|
<FormattedMessage id='compose_form.encryption_warning' defaultMessage='Posts on Mastodon are not end-to-end encrypted. Do not share any dangerous information over Mastodon.' /> {!!privacyPolicyLink && <a href={privacyPolicyLink} target='_blank'><FormattedMessage id='compose_form.direct_message_warning_learn_more' defaultMessage='Learn more' /></a>}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
PINNED_ACCOUNTS_FETCH_REQUEST,
|
PINNED_ACCOUNTS_FETCH_REQUEST,
|
||||||
PINNED_ACCOUNTS_FETCH_SUCCESS,
|
PINNED_ACCOUNTS_FETCH_SUCCESS,
|
||||||
PINNED_ACCOUNTS_FETCH_FAIL,
|
PINNED_ACCOUNTS_FETCH_FAIL,
|
||||||
PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_READY,
|
PINNED_ACCOUNTS_SUGGESTIONS_FETCH_SUCCESS,
|
||||||
PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR,
|
PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR,
|
||||||
PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CHANGE,
|
PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CHANGE,
|
||||||
ACCOUNT_PIN_SUCCESS,
|
ACCOUNT_PIN_SUCCESS,
|
||||||
|
@ -38,10 +38,10 @@ export default function listEditorReducer(state = initialState, action) {
|
||||||
map.set('loaded', true);
|
map.set('loaded', true);
|
||||||
map.set('items', ImmutableList(action.accounts.map(item => item.id)));
|
map.set('items', ImmutableList(action.accounts.map(item => item.id)));
|
||||||
}));
|
}));
|
||||||
|
case PINNED_ACCOUNTS_SUGGESTIONS_FETCH_SUCCESS:
|
||||||
|
return state.setIn(['suggestions', 'items'], ImmutableList(action.accounts.map(item => item.id)));
|
||||||
case PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CHANGE:
|
case PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CHANGE:
|
||||||
return state.setIn(['suggestions', 'value'], action.value);
|
return state.setIn(['suggestions', 'value'], action.value);
|
||||||
case PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_READY:
|
|
||||||
return state.setIn(['suggestions', 'items'], ImmutableList(action.accounts.map(item => item.id)));
|
|
||||||
case PINNED_ACCOUNTS_EDITOR_SUGGESTIONS_CLEAR:
|
case PINNED_ACCOUNTS_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());
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export function recoverHashtags (recognizedTags, text) {
|
export function recoverHashtags (recognizedTags, text) {
|
||||||
return recognizedTags.map(tag => {
|
return recognizedTags.map(tag => {
|
||||||
const re = new RegExp(`(?:^|[^/)\w])#(${tag.name})`, 'i');
|
const re = new RegExp(`(?:^|[^/)\\w])#(${tag.name})`, 'i');
|
||||||
const matched_hashtag = text.match(re);
|
const matched_hashtag = text.match(re);
|
||||||
return matched_hashtag ? matched_hashtag[1] : null;
|
return matched_hashtag ? matched_hashtag[1] : null;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue