Merge tag 'v2.9.3' into instance_only_statuses
This commit is contained in:
@ -199,6 +199,12 @@ const expandMentions = status => {
|
||||
return fragment.innerHTML;
|
||||
};
|
||||
|
||||
const expiresInFromExpiresAt = expires_at => {
|
||||
if (!expires_at) return 24 * 3600;
|
||||
const delta = (new Date(expires_at).getTime() - Date.now()) / 1000;
|
||||
return [300, 1800, 3600, 21600, 86400, 259200, 604800].find(expires_in => expires_in >= delta) || 24 * 3600;
|
||||
};
|
||||
|
||||
export default function compose(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case STORE_HYDRATE:
|
||||
@ -228,6 +234,7 @@ export default function compose(state = initialState, action) {
|
||||
}
|
||||
});
|
||||
case COMPOSE_SPOILER_TEXT_CHANGE:
|
||||
if (!state.get('spoiler')) return state;
|
||||
return state
|
||||
.set('spoiler_text', action.text)
|
||||
.set('idempotencyKey', uuid());
|
||||
@ -363,7 +370,7 @@ export default function compose(state = initialState, action) {
|
||||
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,
|
||||
expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -8,6 +8,8 @@ import {
|
||||
CONVERSATIONS_UPDATE,
|
||||
CONVERSATIONS_READ,
|
||||
} from '../actions/conversations';
|
||||
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'mastodon/actions/accounts';
|
||||
import { DOMAIN_BLOCK_SUCCESS } from 'mastodon/actions/domain_blocks';
|
||||
import compareId from '../compare_id';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
@ -74,6 +76,10 @@ const expandNormalizedConversations = (state, conversations, next, isLoadingRece
|
||||
});
|
||||
};
|
||||
|
||||
const filterConversations = (state, accountIds) => {
|
||||
return state.update('items', list => list.filterNot(item => item.get('accounts').some(accountId => accountIds.includes(accountId))));
|
||||
};
|
||||
|
||||
export default function conversations(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case CONVERSATIONS_FETCH_REQUEST:
|
||||
@ -96,6 +102,11 @@ export default function conversations(state = initialState, action) {
|
||||
|
||||
return item;
|
||||
}));
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
return filterConversations(state, [action.relationship.id]);
|
||||
case DOMAIN_BLOCK_SUCCESS:
|
||||
return filterConversations(state, action.accounts);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ export default function modal(state = initialState, action) {
|
||||
case MODAL_OPEN:
|
||||
return { modalType: action.modalType, modalProps: action.modalProps };
|
||||
case MODAL_CLOSE:
|
||||
return initialState;
|
||||
return (action.modalType === undefined || action.modalType === state.modalType) ? initialState : state;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
ACCOUNT_BLOCK_SUCCESS,
|
||||
ACCOUNT_MUTE_SUCCESS,
|
||||
} from '../actions/accounts';
|
||||
import { DOMAIN_BLOCK_SUCCESS } from 'mastodon/actions/domain_blocks';
|
||||
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import compareId from '../compare_id';
|
||||
@ -77,8 +78,8 @@ const expandNormalizedNotifications = (state, notifications, next) => {
|
||||
});
|
||||
};
|
||||
|
||||
const filterNotifications = (state, relationship) => {
|
||||
return state.update('items', list => list.filterNot(item => item !== null && item.get('account') === relationship.id));
|
||||
const filterNotifications = (state, accountIds) => {
|
||||
return state.update('items', list => list.filterNot(item => item !== null && accountIds.includes(item.get('account'))));
|
||||
};
|
||||
|
||||
const updateTop = (state, top) => {
|
||||
@ -108,9 +109,11 @@ export default function notifications(state = initialState, action) {
|
||||
case NOTIFICATIONS_EXPAND_SUCCESS:
|
||||
return expandNormalizedNotifications(state, action.notifications, action.next);
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
return filterNotifications(state, action.relationship);
|
||||
return filterNotifications(state, [action.relationship.id]);
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
return action.relationship.muting_notifications ? filterNotifications(state, action.relationship) : state;
|
||||
return action.relationship.muting_notifications ? filterNotifications(state, [action.relationship.id]) : state;
|
||||
case DOMAIN_BLOCK_SUCCESS:
|
||||
return filterNotifications(state, action.accounts);
|
||||
case NOTIFICATIONS_CLEAR:
|
||||
return state.set('items', ImmutableList()).set('hasMore', false);
|
||||
case TIMELINE_DELETE:
|
||||
|
@ -16,6 +16,7 @@ const initialState = ImmutableMap({
|
||||
submitted: false,
|
||||
hidden: false,
|
||||
results: ImmutableMap(),
|
||||
searchTerm: '',
|
||||
});
|
||||
|
||||
export default function search(state = initialState, action) {
|
||||
@ -40,7 +41,7 @@ export default function search(state = initialState, action) {
|
||||
accounts: ImmutableList(action.results.accounts.map(item => item.id)),
|
||||
statuses: ImmutableList(action.results.statuses.map(item => item.id)),
|
||||
hashtags: fromJS(action.results.hashtags),
|
||||
})).set('submitted', true);
|
||||
})).set('submitted', true).set('searchTerm', action.searchTerm);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import {
|
||||
SUGGESTIONS_FETCH_FAIL,
|
||||
SUGGESTIONS_DISMISS,
|
||||
} from '../actions/suggestions';
|
||||
import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'mastodon/actions/accounts';
|
||||
import { DOMAIN_BLOCK_SUCCESS } from 'mastodon/actions/domain_blocks';
|
||||
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
@ -24,6 +26,11 @@ export default function suggestionsReducer(state = initialState, action) {
|
||||
return state.set('isLoading', false);
|
||||
case SUGGESTIONS_DISMISS:
|
||||
return state.update('items', list => list.filterNot(id => id === action.id));
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
return state.update('items', list => list.filterNot(id => id === action.relationship.id));
|
||||
case DOMAIN_BLOCK_SUCCESS:
|
||||
return state.update('items', list => list.filterNot(id => action.accounts.includes(id)));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
Reference in New Issue
Block a user