Merge tag 'v3.2.0' into hometown-dev
This commit is contained in:
@ -14,6 +14,10 @@ import {
|
||||
COMPOSE_UPLOAD_FAIL,
|
||||
COMPOSE_UPLOAD_UNDO,
|
||||
COMPOSE_UPLOAD_PROGRESS,
|
||||
THUMBNAIL_UPLOAD_REQUEST,
|
||||
THUMBNAIL_UPLOAD_SUCCESS,
|
||||
THUMBNAIL_UPLOAD_FAIL,
|
||||
THUMBNAIL_UPLOAD_PROGRESS,
|
||||
COMPOSE_SUGGESTIONS_CLEAR,
|
||||
COMPOSE_SUGGESTIONS_READY,
|
||||
COMPOSE_SUGGESTION_SELECT,
|
||||
@ -62,6 +66,8 @@ const initialState = ImmutableMap({
|
||||
is_changing_upload: false,
|
||||
is_uploading: false,
|
||||
progress: 0,
|
||||
isUploadingThumbnail: false,
|
||||
thumbnailProgress: 0,
|
||||
media_attachments: ImmutableList(),
|
||||
pending_media_attachments: 0,
|
||||
poll: null,
|
||||
@ -342,6 +348,22 @@ export default function compose(state = initialState, action) {
|
||||
return removeMedia(state, action.media_id);
|
||||
case COMPOSE_UPLOAD_PROGRESS:
|
||||
return state.set('progress', Math.round((action.loaded / action.total) * 100));
|
||||
case THUMBNAIL_UPLOAD_REQUEST:
|
||||
return state.set('isUploadingThumbnail', true);
|
||||
case THUMBNAIL_UPLOAD_PROGRESS:
|
||||
return state.set('thumbnailProgress', Math.round((action.loaded / action.total) * 100));
|
||||
case THUMBNAIL_UPLOAD_FAIL:
|
||||
return state.set('isUploadingThumbnail', false);
|
||||
case THUMBNAIL_UPLOAD_SUCCESS:
|
||||
return state
|
||||
.set('isUploadingThumbnail', false)
|
||||
.update('media_attachments', list => list.map(item => {
|
||||
if (item.get('id') === action.media.id) {
|
||||
return fromJS(action.media);
|
||||
}
|
||||
|
||||
return item;
|
||||
}));
|
||||
case COMPOSE_MENTION:
|
||||
return state.withMutations(map => {
|
||||
map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' '));
|
||||
|
@ -4,14 +4,14 @@ import {
|
||||
DROPDOWN_MENU_CLOSE,
|
||||
} from '../actions/dropdown_menu';
|
||||
|
||||
const initialState = Immutable.Map({ openId: null, placement: null, keyboard: false });
|
||||
const initialState = Immutable.Map({ openId: null, placement: null, keyboard: false, scroll_key: null });
|
||||
|
||||
export default function dropdownMenu(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
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, scroll_key: action.scroll_key });
|
||||
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).set('scroll_key', null) : state;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import identity_proofs from './identity_proofs';
|
||||
import trends from './trends';
|
||||
import missed_updates from './missed_updates';
|
||||
import announcements from './announcements';
|
||||
import markers from './markers';
|
||||
|
||||
const reducers = {
|
||||
announcements,
|
||||
@ -73,6 +74,7 @@ const reducers = {
|
||||
polls,
|
||||
trends,
|
||||
missed_updates,
|
||||
markers,
|
||||
};
|
||||
|
||||
export default combineReducers(reducers);
|
||||
|
25
app/javascript/mastodon/reducers/markers.js
Normal file
25
app/javascript/mastodon/reducers/markers.js
Normal file
@ -0,0 +1,25 @@
|
||||
import {
|
||||
MARKERS_SUBMIT_SUCCESS,
|
||||
} from '../actions/markers';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
home: '0',
|
||||
notifications: '0',
|
||||
});
|
||||
|
||||
import { Map as ImmutableMap } from 'immutable';
|
||||
|
||||
export default function markers(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case MARKERS_SUBMIT_SUCCESS:
|
||||
if (action.home) {
|
||||
state = state.set('home', action.home);
|
||||
}
|
||||
if (action.notifications) {
|
||||
state = state.set('notifications', action.notifications);
|
||||
}
|
||||
return state;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
@ -17,6 +17,9 @@ import {
|
||||
DOMAIN_BLOCK_SUCCESS,
|
||||
DOMAIN_UNBLOCK_SUCCESS,
|
||||
} from '../actions/domain_blocks';
|
||||
import {
|
||||
ACCOUNT_NOTE_SUBMIT_SUCCESS,
|
||||
} from '../actions/account_notes';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
|
||||
const normalizeRelationship = (state, relationship) => state.set(relationship.id, fromJS(relationship));
|
||||
@ -57,6 +60,7 @@ export default function relationships(state = initialState, action) {
|
||||
case ACCOUNT_UNMUTE_SUCCESS:
|
||||
case ACCOUNT_PIN_SUCCESS:
|
||||
case ACCOUNT_UNPIN_SUCCESS:
|
||||
case ACCOUNT_NOTE_SUBMIT_SUCCESS:
|
||||
return normalizeRelationship(state, action.relationship);
|
||||
case RELATIONSHIPS_FETCH_SUCCESS:
|
||||
return normalizeRelationships(state, action.relationships);
|
||||
|
@ -63,16 +63,16 @@ const initialState = ImmutableMap({
|
||||
mutes: ImmutableMap(),
|
||||
});
|
||||
|
||||
const normalizeList = (state, type, id, accounts, next) => {
|
||||
return state.setIn([type, id], ImmutableMap({
|
||||
const normalizeList = (state, path, accounts, next) => {
|
||||
return state.setIn(path, ImmutableMap({
|
||||
next,
|
||||
items: ImmutableList(accounts.map(item => item.id)),
|
||||
isLoading: false,
|
||||
}));
|
||||
};
|
||||
|
||||
const appendToList = (state, type, id, accounts, next) => {
|
||||
return state.updateIn([type, id], map => {
|
||||
const appendToList = (state, path, accounts, next) => {
|
||||
return state.updateIn(path, map => {
|
||||
return map.set('next', next).set('isLoading', false).update('items', list => list.concat(accounts.map(item => item.id)));
|
||||
});
|
||||
};
|
||||
@ -86,9 +86,9 @@ const normalizeFollowRequest = (state, notification) => {
|
||||
export default function userLists(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
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:
|
||||
return appendToList(state, 'followers', action.id, action.accounts, action.next);
|
||||
return appendToList(state, ['followers', action.id], action.accounts, action.next);
|
||||
case FOLLOWERS_FETCH_REQUEST:
|
||||
case FOLLOWERS_EXPAND_REQUEST:
|
||||
return state.setIn(['followers', action.id, 'isLoading'], true);
|
||||
@ -96,9 +96,9 @@ export default function userLists(state = initialState, action) {
|
||||
case FOLLOWERS_EXPAND_FAIL:
|
||||
return state.setIn(['followers', action.id, 'isLoading'], false);
|
||||
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:
|
||||
return appendToList(state, 'following', action.id, action.accounts, action.next);
|
||||
return appendToList(state, ['following', action.id], action.accounts, action.next);
|
||||
case FOLLOWING_FETCH_REQUEST:
|
||||
case FOLLOWING_EXPAND_REQUEST:
|
||||
return state.setIn(['following', action.id, 'isLoading'], true);
|
||||
@ -112,9 +112,9 @@ export default function userLists(state = initialState, action) {
|
||||
case NOTIFICATIONS_UPDATE:
|
||||
return action.notification.type === 'follow_request' ? normalizeFollowRequest(state, action.notification) : state;
|
||||
case FOLLOW_REQUESTS_FETCH_SUCCESS:
|
||||
return state.setIn(['follow_requests', 'items'], ImmutableList(action.accounts.map(item => item.id))).setIn(['follow_requests', 'next'], action.next).setIn(['follow_requests', 'isLoading'], false);
|
||||
return normalizeList(state, ['follow_requests'], action.accounts, action.next);
|
||||
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).setIn(['follow_requests', 'isLoading'], false);
|
||||
return appendToList(state, ['follow_requests'], action.accounts, action.next);
|
||||
case FOLLOW_REQUESTS_FETCH_REQUEST:
|
||||
case FOLLOW_REQUESTS_EXPAND_REQUEST:
|
||||
return state.setIn(['follow_requests', 'isLoading'], true);
|
||||
@ -125,9 +125,9 @@ export default function userLists(state = initialState, action) {
|
||||
case FOLLOW_REQUEST_REJECT_SUCCESS:
|
||||
return state.updateIn(['follow_requests', 'items'], list => list.filterNot(item => item === action.id));
|
||||
case BLOCKS_FETCH_SUCCESS:
|
||||
return state.setIn(['blocks', 'items'], ImmutableList(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next);
|
||||
return normalizeList(state, ['blocks'], action.accounts, action.next);
|
||||
case BLOCKS_EXPAND_SUCCESS:
|
||||
return state.updateIn(['blocks', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['blocks', 'next'], action.next);
|
||||
return appendToList(state, ['blocks'], action.accounts, action.next);
|
||||
case BLOCKS_FETCH_REQUEST:
|
||||
case BLOCKS_EXPAND_REQUEST:
|
||||
return state.setIn(['blocks', 'isLoading'], true);
|
||||
@ -135,9 +135,9 @@ export default function userLists(state = initialState, action) {
|
||||
case BLOCKS_EXPAND_FAIL:
|
||||
return state.setIn(['blocks', 'isLoading'], false);
|
||||
case MUTES_FETCH_SUCCESS:
|
||||
return state.setIn(['mutes', 'items'], ImmutableList(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next);
|
||||
return normalizeList(state, ['mutes'], action.accounts, action.next);
|
||||
case MUTES_EXPAND_SUCCESS:
|
||||
return state.updateIn(['mutes', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['mutes', 'next'], action.next);
|
||||
return appendToList(state, ['mutes'], action.accounts, action.next);
|
||||
case MUTES_FETCH_REQUEST:
|
||||
case MUTES_EXPAND_REQUEST:
|
||||
return state.setIn(['mutes', 'isLoading'], true);
|
||||
@ -145,9 +145,9 @@ export default function userLists(state = initialState, action) {
|
||||
case MUTES_EXPAND_FAIL:
|
||||
return state.setIn(['mutes', 'isLoading'], false);
|
||||
case DIRECTORY_FETCH_SUCCESS:
|
||||
return state.setIn(['directory', 'items'], ImmutableList(action.accounts.map(item => item.id))).setIn(['directory', 'isLoading'], false);
|
||||
return normalizeList(state, ['directory'], action.accounts, action.next);
|
||||
case DIRECTORY_EXPAND_SUCCESS:
|
||||
return state.updateIn(['directory', 'items'], list => list.concat(action.accounts.map(item => item.id))).setIn(['directory', 'isLoading'], false);
|
||||
return appendToList(state, ['directory'], action.accounts, action.next);
|
||||
case DIRECTORY_FETCH_REQUEST:
|
||||
case DIRECTORY_EXPAND_REQUEST:
|
||||
return state.setIn(['directory', 'isLoading'], true);
|
||||
|
Reference in New Issue
Block a user