mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-29 14:53:41 +01:00
Merge pull request #1736 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
This commit is contained in:
commit
e0c39f9fad
8 changed files with 107 additions and 16 deletions
|
@ -66,13 +66,22 @@ const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, is
|
||||||
|
|
||||||
// Then, try to find the furthest (if properly sorted, oldest) item in the timeline that
|
// Then, try to find the furthest (if properly sorted, oldest) item in the timeline that
|
||||||
// is newer than the most recent fetched one, as it delimits a section comprised of only
|
// is newer than the most recent fetched one, as it delimits a section comprised of only
|
||||||
// items present in `newIds` (or that were deleted from the server, so should be removed
|
// items older or within `newIds` (or that were deleted from the server, so should be removed
|
||||||
// anyway).
|
// anyway).
|
||||||
// Stop the gap *after* that item.
|
// Stop the gap *after* that item.
|
||||||
const firstIndex = oldIds.take(lastIndex).findLastIndex(id => id !== null && compareId(id, newIds.first()) > 0) + 1;
|
const firstIndex = oldIds.take(lastIndex).findLastIndex(id => id !== null && compareId(id, newIds.first()) > 0) + 1;
|
||||||
|
|
||||||
|
let insertedIds = ImmutableOrderedSet(newIds).withMutations(insertedIds => {
|
||||||
|
// It is possible, though unlikely, that the slice we are replacing contains items older
|
||||||
|
// than the elements we got from the API. Get them and add them back at the back of the
|
||||||
|
// slice.
|
||||||
|
const olderIds = oldIds.slice(firstIndex, lastIndex).filter(id => id !== null && compareId(id, newIds.last()) < 0);
|
||||||
|
insertedIds.union(olderIds);
|
||||||
|
|
||||||
// Make sure we aren't inserting duplicates
|
// Make sure we aren't inserting duplicates
|
||||||
let insertedIds = ImmutableOrderedSet(newIds).subtract(oldIds.take(firstIndex), oldIds.skip(lastIndex)).toList();
|
insertedIds.subtract(oldIds.take(firstIndex), oldIds.skip(lastIndex));
|
||||||
|
}).toList();
|
||||||
|
|
||||||
// Finally, insert a gap marker if the data is marked as partial by the server
|
// Finally, insert a gap marker if the data is marked as partial by the server
|
||||||
if (isPartial && (firstIndex === 0 || oldIds.get(firstIndex - 1) !== null)) {
|
if (isPartial && (firstIndex === 0 || oldIds.get(firstIndex - 1) !== null)) {
|
||||||
insertedIds = insertedIds.unshift(null);
|
insertedIds = insertedIds.unshift(null);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import api from '../api';
|
import api, { getLinks } from '../api';
|
||||||
import { importFetchedStatuses } from './importer';
|
import { importFetchedStatuses } from './importer';
|
||||||
|
|
||||||
export const TRENDS_TAGS_FETCH_REQUEST = 'TRENDS_TAGS_FETCH_REQUEST';
|
export const TRENDS_TAGS_FETCH_REQUEST = 'TRENDS_TAGS_FETCH_REQUEST';
|
||||||
|
@ -13,6 +13,10 @@ export const TRENDS_STATUSES_FETCH_REQUEST = 'TRENDS_STATUSES_FETCH_REQUEST';
|
||||||
export const TRENDS_STATUSES_FETCH_SUCCESS = 'TRENDS_STATUSES_FETCH_SUCCESS';
|
export const TRENDS_STATUSES_FETCH_SUCCESS = 'TRENDS_STATUSES_FETCH_SUCCESS';
|
||||||
export const TRENDS_STATUSES_FETCH_FAIL = 'TRENDS_STATUSES_FETCH_FAIL';
|
export const TRENDS_STATUSES_FETCH_FAIL = 'TRENDS_STATUSES_FETCH_FAIL';
|
||||||
|
|
||||||
|
export const TRENDS_STATUSES_EXPAND_REQUEST = 'TRENDS_STATUSES_EXPAND_REQUEST';
|
||||||
|
export const TRENDS_STATUSES_EXPAND_SUCCESS = 'TRENDS_STATUSES_EXPAND_SUCCESS';
|
||||||
|
export const TRENDS_STATUSES_EXPAND_FAIL = 'TRENDS_STATUSES_EXPAND_FAIL';
|
||||||
|
|
||||||
export const fetchTrendingHashtags = () => (dispatch, getState) => {
|
export const fetchTrendingHashtags = () => (dispatch, getState) => {
|
||||||
dispatch(fetchTrendingHashtagsRequest());
|
dispatch(fetchTrendingHashtagsRequest());
|
||||||
|
|
||||||
|
@ -68,11 +72,16 @@ export const fetchTrendingLinksFail = error => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchTrendingStatuses = () => (dispatch, getState) => {
|
export const fetchTrendingStatuses = () => (dispatch, getState) => {
|
||||||
|
if (getState().getIn(['status_lists', 'trending', 'isLoading'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(fetchTrendingStatusesRequest());
|
dispatch(fetchTrendingStatusesRequest());
|
||||||
|
|
||||||
api(getState).get('/api/v1/trends/statuses').then(({ data }) => {
|
api(getState).get('/api/v1/trends/statuses').then(response => {
|
||||||
dispatch(importFetchedStatuses(data));
|
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||||
dispatch(fetchTrendingStatusesSuccess(data));
|
dispatch(importFetchedStatuses(response.data));
|
||||||
|
dispatch(fetchTrendingStatusesSuccess(response.data, next ? next.uri : null));
|
||||||
}).catch(err => dispatch(fetchTrendingStatusesFail(err)));
|
}).catch(err => dispatch(fetchTrendingStatusesFail(err)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,9 +90,10 @@ export const fetchTrendingStatusesRequest = () => ({
|
||||||
skipLoading: true,
|
skipLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchTrendingStatusesSuccess = statuses => ({
|
export const fetchTrendingStatusesSuccess = (statuses, next) => ({
|
||||||
type: TRENDS_STATUSES_FETCH_SUCCESS,
|
type: TRENDS_STATUSES_FETCH_SUCCESS,
|
||||||
statuses,
|
statuses,
|
||||||
|
next,
|
||||||
skipLoading: true,
|
skipLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -93,3 +103,37 @@ export const fetchTrendingStatusesFail = error => ({
|
||||||
skipLoading: true,
|
skipLoading: true,
|
||||||
skipAlert: true,
|
skipAlert: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export const expandTrendingStatuses = () => (dispatch, getState) => {
|
||||||
|
const url = getState().getIn(['status_lists', 'trending', 'next'], null);
|
||||||
|
|
||||||
|
if (url === null || getState().getIn(['status_lists', 'trending', 'isLoading'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(expandTrendingStatusesRequest());
|
||||||
|
|
||||||
|
api(getState).get(url).then(response => {
|
||||||
|
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||||
|
dispatch(importFetchedStatuses(response.data));
|
||||||
|
dispatch(expandTrendingStatusesSuccess(response.data, next ? next.uri : null));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(expandTrendingStatusesFail(error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const expandTrendingStatusesRequest = () => ({
|
||||||
|
type: TRENDS_STATUSES_EXPAND_REQUEST,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const expandTrendingStatusesSuccess = (statuses, next) => ({
|
||||||
|
type: TRENDS_STATUSES_EXPAND_SUCCESS,
|
||||||
|
statuses,
|
||||||
|
next,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const expandTrendingStatusesFail = error => ({
|
||||||
|
type: TRENDS_STATUSES_EXPAND_FAIL,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
|
@ -4,11 +4,13 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import StatusList from 'mastodon/components/status_list';
|
import StatusList from 'mastodon/components/status_list';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { fetchTrendingStatuses } from 'mastodon/actions/trends';
|
import { fetchTrendingStatuses, expandTrendingStatuses } from 'mastodon/actions/trends';
|
||||||
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
statusIds: state.getIn(['status_lists', 'trending', 'items']),
|
statusIds: state.getIn(['status_lists', 'trending', 'items']),
|
||||||
isLoading: state.getIn(['status_lists', 'trending', 'isLoading'], true),
|
isLoading: state.getIn(['status_lists', 'trending', 'isLoading'], true),
|
||||||
|
hasMore: !!state.getIn(['status_lists', 'trending', 'next']),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default @connect(mapStateToProps)
|
export default @connect(mapStateToProps)
|
||||||
|
@ -17,6 +19,7 @@ class Statuses extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
statusIds: ImmutablePropTypes.list,
|
statusIds: ImmutablePropTypes.list,
|
||||||
isLoading: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
|
hasMore: PropTypes.bool,
|
||||||
multiColumn: PropTypes.bool,
|
multiColumn: PropTypes.bool,
|
||||||
dispatch: PropTypes.func.isRequired,
|
dispatch: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
@ -26,8 +29,13 @@ class Statuses extends React.PureComponent {
|
||||||
dispatch(fetchTrendingStatuses());
|
dispatch(fetchTrendingStatuses());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleLoadMore = debounce(() => {
|
||||||
|
const { dispatch } = this.props;
|
||||||
|
dispatch(expandTrendingStatuses());
|
||||||
|
}, 300, { leading: true })
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { isLoading, statusIds, multiColumn } = this.props;
|
const { isLoading, hasMore, statusIds, multiColumn } = this.props;
|
||||||
|
|
||||||
const emptyMessage = <FormattedMessage id='empty_column.explore_statuses' defaultMessage='Nothing is trending right now. Check back later!' />;
|
const emptyMessage = <FormattedMessage id='empty_column.explore_statuses' defaultMessage='Nothing is trending right now. Check back later!' />;
|
||||||
|
|
||||||
|
@ -36,8 +44,9 @@ class Statuses extends React.PureComponent {
|
||||||
trackScroll
|
trackScroll
|
||||||
statusIds={statusIds}
|
statusIds={statusIds}
|
||||||
scrollKey='explore-statuses'
|
scrollKey='explore-statuses'
|
||||||
hasMore={false}
|
hasMore={hasMore}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
onLoadMore={this.handleLoadMore}
|
||||||
emptyMessage={emptyMessage}
|
emptyMessage={emptyMessage}
|
||||||
bindToDocument={!multiColumn}
|
bindToDocument={!multiColumn}
|
||||||
withCounters
|
withCounters
|
||||||
|
|
|
@ -21,6 +21,9 @@ import {
|
||||||
TRENDS_STATUSES_FETCH_REQUEST,
|
TRENDS_STATUSES_FETCH_REQUEST,
|
||||||
TRENDS_STATUSES_FETCH_SUCCESS,
|
TRENDS_STATUSES_FETCH_SUCCESS,
|
||||||
TRENDS_STATUSES_FETCH_FAIL,
|
TRENDS_STATUSES_FETCH_FAIL,
|
||||||
|
TRENDS_STATUSES_EXPAND_REQUEST,
|
||||||
|
TRENDS_STATUSES_EXPAND_SUCCESS,
|
||||||
|
TRENDS_STATUSES_EXPAND_FAIL,
|
||||||
} from '../actions/trends';
|
} from '../actions/trends';
|
||||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
import {
|
import {
|
||||||
|
@ -111,11 +114,15 @@ export default function statusLists(state = initialState, action) {
|
||||||
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 TRENDS_STATUSES_FETCH_REQUEST:
|
case TRENDS_STATUSES_FETCH_REQUEST:
|
||||||
|
case TRENDS_STATUSES_EXPAND_REQUEST:
|
||||||
return state.setIn(['trending', 'isLoading'], true);
|
return state.setIn(['trending', 'isLoading'], true);
|
||||||
case TRENDS_STATUSES_FETCH_FAIL:
|
case TRENDS_STATUSES_FETCH_FAIL:
|
||||||
|
case TRENDS_STATUSES_EXPAND_FAIL:
|
||||||
return state.setIn(['trending', 'isLoading'], false);
|
return state.setIn(['trending', 'isLoading'], false);
|
||||||
case TRENDS_STATUSES_FETCH_SUCCESS:
|
case TRENDS_STATUSES_FETCH_SUCCESS:
|
||||||
return normalizeList(state, 'trending', action.statuses, action.next);
|
return normalizeList(state, 'trending', action.statuses, action.next);
|
||||||
|
case TRENDS_STATUSES_EXPAND_SUCCESS:
|
||||||
|
return appendToList(state, 'trending', 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:
|
||||||
|
|
|
@ -66,13 +66,22 @@ const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, is
|
||||||
|
|
||||||
// Then, try to find the furthest (if properly sorted, oldest) item in the timeline that
|
// Then, try to find the furthest (if properly sorted, oldest) item in the timeline that
|
||||||
// is newer than the most recent fetched one, as it delimits a section comprised of only
|
// is newer than the most recent fetched one, as it delimits a section comprised of only
|
||||||
// items present in `newIds` (or that were deleted from the server, so should be removed
|
// items older or within `newIds` (or that were deleted from the server, so should be removed
|
||||||
// anyway).
|
// anyway).
|
||||||
// Stop the gap *after* that item.
|
// Stop the gap *after* that item.
|
||||||
const firstIndex = oldIds.take(lastIndex).findLastIndex(id => id !== null && compareId(id, newIds.first()) > 0) + 1;
|
const firstIndex = oldIds.take(lastIndex).findLastIndex(id => id !== null && compareId(id, newIds.first()) > 0) + 1;
|
||||||
|
|
||||||
|
let insertedIds = ImmutableOrderedSet(newIds).withMutations(insertedIds => {
|
||||||
|
// It is possible, though unlikely, that the slice we are replacing contains items older
|
||||||
|
// than the elements we got from the API. Get them and add them back at the back of the
|
||||||
|
// slice.
|
||||||
|
const olderIds = oldIds.slice(firstIndex, lastIndex).filter(id => id !== null && compareId(id, newIds.last()) < 0);
|
||||||
|
insertedIds.union(olderIds);
|
||||||
|
|
||||||
// Make sure we aren't inserting duplicates
|
// Make sure we aren't inserting duplicates
|
||||||
let insertedIds = ImmutableOrderedSet(newIds).subtract(oldIds.take(firstIndex), oldIds.skip(lastIndex)).toList();
|
insertedIds.subtract(oldIds.take(firstIndex), oldIds.skip(lastIndex));
|
||||||
|
}).toList();
|
||||||
|
|
||||||
// Finally, insert a gap marker if the data is marked as partial by the server
|
// Finally, insert a gap marker if the data is marked as partial by the server
|
||||||
if (isPartial && (firstIndex === 0 || oldIds.get(firstIndex - 1) !== null)) {
|
if (isPartial && (firstIndex === 0 || oldIds.get(firstIndex - 1) !== null)) {
|
||||||
insertedIds = insertedIds.unshift(null);
|
insertedIds = insertedIds.unshift(null);
|
||||||
|
|
|
@ -7,6 +7,7 @@ class UserMailer < Devise::Mailer
|
||||||
helper :application
|
helper :application
|
||||||
helper :instance
|
helper :instance
|
||||||
helper :statuses
|
helper :statuses
|
||||||
|
helper :formatting
|
||||||
|
|
||||||
helper RoutingHelper
|
helper RoutingHelper
|
||||||
|
|
||||||
|
|
|
@ -95,11 +95,12 @@ Rails.application.configure do
|
||||||
|
|
||||||
config.action_mailer.default_options = {
|
config.action_mailer.default_options = {
|
||||||
from: outgoing_email_address,
|
from: outgoing_email_address,
|
||||||
reply_to: ENV['SMTP_REPLY_TO'],
|
|
||||||
return_path: ENV['SMTP_RETURN_PATH'],
|
|
||||||
message_id: -> { "<#{Mail.random_tag}@#{outgoing_email_domain}>" },
|
message_id: -> { "<#{Mail.random_tag}@#{outgoing_email_domain}>" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.action_mailer.default_options[:reply_to] = ENV['SMTP_REPLY_TO'] if ENV['SMTP_REPLY_TO'].present?
|
||||||
|
config.action_mailer.default_options[:return_path] = ENV['SMTP_RETURN_PATH'] if ENV['SMTP_RETURN_PATH'].present?
|
||||||
|
|
||||||
config.action_mailer.smtp_settings = {
|
config.action_mailer.smtp_settings = {
|
||||||
:port => ENV['SMTP_PORT'],
|
:port => ENV['SMTP_PORT'],
|
||||||
:address => ENV['SMTP_SERVER'],
|
:address => ENV['SMTP_SERVER'],
|
||||||
|
|
|
@ -83,4 +83,15 @@ describe UserMailer, type: :mailer do
|
||||||
include_examples 'localized subject',
|
include_examples 'localized subject',
|
||||||
'devise.mailer.email_changed.subject'
|
'devise.mailer.email_changed.subject'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'warning' do
|
||||||
|
let(:strike) { Fabricate(:account_warning, target_account: receiver.account, text: 'dont worry its just the testsuite', action: 'suspend') }
|
||||||
|
let(:mail) { UserMailer.warning(receiver, strike) }
|
||||||
|
|
||||||
|
it 'renders warning notification' do
|
||||||
|
receiver.update!(locale: nil)
|
||||||
|
expect(mail.body.encoded).to include I18n.t("user_mailer.warning.title.suspend", acct: receiver.account.acct)
|
||||||
|
expect(mail.body.encoded).to include strike.text
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue