Merge upstream 2.0ish #165
This commit is contained in:
@@ -44,7 +44,7 @@ import {
|
||||
FAVOURITED_STATUSES_EXPAND_SUCCESS,
|
||||
} from '../actions/favourites';
|
||||
import { STORE_HYDRATE } from '../actions/store';
|
||||
import emojify from '../emoji';
|
||||
import emojify from '../features/emoji/emoji';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
import escapeTextContentForBrowser from 'escape-html';
|
||||
|
||||
|
@@ -23,6 +23,10 @@ import {
|
||||
COMPOSE_VISIBILITY_CHANGE,
|
||||
COMPOSE_COMPOSING_CHANGE,
|
||||
COMPOSE_EMOJI_INSERT,
|
||||
COMPOSE_UPLOAD_CHANGE_REQUEST,
|
||||
COMPOSE_UPLOAD_CHANGE_SUCCESS,
|
||||
COMPOSE_UPLOAD_CHANGE_FAIL,
|
||||
COMPOSE_RESET,
|
||||
} from '../actions/compose';
|
||||
import { TIMELINE_DELETE } from '../actions/timelines';
|
||||
import { STORE_HYDRATE } from '../actions/store';
|
||||
@@ -227,6 +231,7 @@ export default function compose(state = initialState, action) {
|
||||
}
|
||||
});
|
||||
case COMPOSE_REPLY_CANCEL:
|
||||
case COMPOSE_RESET:
|
||||
return state.withMutations(map => {
|
||||
map.set('in_reply_to', null);
|
||||
map.set('text', '');
|
||||
@@ -237,15 +242,15 @@ export default function compose(state = initialState, action) {
|
||||
map.set('idempotencyKey', uuid());
|
||||
});
|
||||
case COMPOSE_SUBMIT_REQUEST:
|
||||
case COMPOSE_UPLOAD_CHANGE_REQUEST:
|
||||
return state.set('is_submitting', true);
|
||||
case COMPOSE_SUBMIT_SUCCESS:
|
||||
return clearAll(state);
|
||||
case COMPOSE_SUBMIT_FAIL:
|
||||
case COMPOSE_UPLOAD_CHANGE_FAIL:
|
||||
return state.set('is_submitting', false);
|
||||
case COMPOSE_UPLOAD_REQUEST:
|
||||
return state.withMutations(map => {
|
||||
map.set('is_uploading', true);
|
||||
});
|
||||
return state.set('is_uploading', true);
|
||||
case COMPOSE_UPLOAD_SUCCESS:
|
||||
return appendMedia(state, fromJS(action.media));
|
||||
case COMPOSE_UPLOAD_FAIL:
|
||||
@@ -273,6 +278,16 @@ export default function compose(state = initialState, action) {
|
||||
}
|
||||
case COMPOSE_EMOJI_INSERT:
|
||||
return insertEmoji(state, action.position, action.emoji);
|
||||
case COMPOSE_UPLOAD_CHANGE_SUCCESS:
|
||||
return state
|
||||
.set('is_submitting', false)
|
||||
.update('media_attachments', list => list.map(item => {
|
||||
if (item.get('id') === action.media.id) {
|
||||
return item.set('description', action.media.description);
|
||||
}
|
||||
|
||||
return item;
|
||||
}));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
|
||||
import { TIMELINE_DELETE } from '../actions/timelines';
|
||||
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||
import { TIMELINE_DELETE, TIMELINE_CONTEXT_UPDATE } from '../actions/timelines';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
ancestors: ImmutableMap(),
|
||||
@@ -8,8 +8,8 @@ const initialState = ImmutableMap({
|
||||
});
|
||||
|
||||
const normalizeContext = (state, id, ancestors, descendants) => {
|
||||
const ancestorsIds = ancestors.map(ancestor => ancestor.get('id'));
|
||||
const descendantsIds = descendants.map(descendant => descendant.get('id'));
|
||||
const ancestorsIds = ImmutableList(ancestors.map(ancestor => ancestor.id));
|
||||
const descendantsIds = ImmutableList(descendants.map(descendant => descendant.id));
|
||||
|
||||
return state.withMutations(map => {
|
||||
map.setIn(['ancestors', id], ancestorsIds);
|
||||
@@ -31,12 +31,30 @@ const deleteFromContexts = (state, id) => {
|
||||
return state;
|
||||
};
|
||||
|
||||
const updateContext = (state, status, references) => {
|
||||
return state.update('descendants', map => {
|
||||
references.forEach(parentId => {
|
||||
map = map.update(parentId, ImmutableList(), list => {
|
||||
if (list.includes(status.id)) {
|
||||
return list;
|
||||
}
|
||||
|
||||
return list.push(status.id);
|
||||
});
|
||||
});
|
||||
|
||||
return map;
|
||||
});
|
||||
};
|
||||
|
||||
export default function contexts(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case CONTEXT_FETCH_SUCCESS:
|
||||
return normalizeContext(state, action.id, fromJS(action.ancestors), fromJS(action.descendants));
|
||||
return normalizeContext(state, action.id, action.ancestors, action.descendants);
|
||||
case TIMELINE_DELETE:
|
||||
return deleteFromContexts(state, action.id);
|
||||
case TIMELINE_CONTEXT_UPDATE:
|
||||
return updateContext(state, action.status, action.references);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import { List as ImmutableList } from 'immutable';
|
||||
import { STORE_HYDRATE } from '../actions/store';
|
||||
import { emojiIndex } from 'emoji-mart';
|
||||
import { buildCustomEmojis } from '../emoji';
|
||||
import { search as emojiSearch } from '../features/emoji/emoji_mart_search_light';
|
||||
import { buildCustomEmojis } from '../features/emoji/emoji';
|
||||
|
||||
const initialState = ImmutableList();
|
||||
|
||||
export default function custom_emojis(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case STORE_HYDRATE:
|
||||
emojiIndex.search('', { custom: buildCustomEmojis(action.state.get('custom_emojis', [])) });
|
||||
emojiSearch('', { custom: buildCustomEmojis(action.state.get('custom_emojis', []), action.state.getIn(['meta', 'auto_play_gif'], false)) });
|
||||
return action.state.get('custom_emojis');
|
||||
default:
|
||||
return state;
|
||||
|
@@ -15,7 +15,10 @@ import {
|
||||
NOTIFICATIONS_ENTER_CLEARING_MODE,
|
||||
NOTIFICATIONS_MARK_ALL_FOR_DELETE,
|
||||
} from '../actions/notifications';
|
||||
import { ACCOUNT_BLOCK_SUCCESS } from '../actions/accounts';
|
||||
import {
|
||||
ACCOUNT_BLOCK_SUCCESS,
|
||||
ACCOUNT_MUTE_SUCCESS,
|
||||
} from '../actions/accounts';
|
||||
import { TIMELINE_DELETE } from '../actions/timelines';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
|
||||
@@ -151,6 +154,7 @@ export default function notifications(state = initialState, action) {
|
||||
case NOTIFICATIONS_EXPAND_SUCCESS:
|
||||
return appendNormalizedNotifications(state, action.notifications, action.next);
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
return filterNotifications(state, action.relationship);
|
||||
case NOTIFICATIONS_CLEAR:
|
||||
return state.set('items', ImmutableList()).set('next', null);
|
||||
|
@@ -1,13 +1,18 @@
|
||||
import { SETTING_CHANGE } from '../actions/settings';
|
||||
import { SETTING_CHANGE, SETTING_SAVE } from '../actions/settings';
|
||||
import { COLUMN_ADD, COLUMN_REMOVE, COLUMN_MOVE } from '../actions/columns';
|
||||
import { STORE_HYDRATE } from '../actions/store';
|
||||
import { EMOJI_USE } from '../actions/emojis';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
import uuid from '../uuid';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
saved: true,
|
||||
|
||||
onboarded: false,
|
||||
layout: 'auto',
|
||||
|
||||
skinTone: 1,
|
||||
|
||||
home: ImmutableMap({
|
||||
shows: ImmutableMap({
|
||||
reblog: true,
|
||||
@@ -73,21 +78,35 @@ const moveColumn = (state, uuid, direction) => {
|
||||
newColumns = columns.splice(index, 1);
|
||||
newColumns = newColumns.splice(newIndex, 0, columns.get(index));
|
||||
|
||||
return state.set('columns', newColumns);
|
||||
return state
|
||||
.set('columns', newColumns)
|
||||
.set('saved', false);
|
||||
};
|
||||
|
||||
const updateFrequentEmojis = (state, emoji) => state.update('frequentlyUsedEmojis', ImmutableMap(), map => map.update(emoji.id, 0, count => count + 1)).set('saved', false);
|
||||
|
||||
export default function settings(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case STORE_HYDRATE:
|
||||
return hydrate(state, action.state.get('settings'));
|
||||
case SETTING_CHANGE:
|
||||
return state.setIn(action.key, action.value);
|
||||
return state
|
||||
.setIn(action.key, action.value)
|
||||
.set('saved', false);
|
||||
case COLUMN_ADD:
|
||||
return state.update('columns', list => list.push(fromJS({ id: action.id, uuid: uuid(), params: action.params })));
|
||||
return state
|
||||
.update('columns', list => list.push(fromJS({ id: action.id, uuid: uuid(), params: action.params })))
|
||||
.set('saved', false);
|
||||
case COLUMN_REMOVE:
|
||||
return state.update('columns', list => list.filterNot(item => item.get('uuid') === action.uuid));
|
||||
return state
|
||||
.update('columns', list => list.filterNot(item => item.get('uuid') === action.uuid))
|
||||
.set('saved', false);
|
||||
case COLUMN_MOVE:
|
||||
return moveColumn(state, action.uuid, action.direction);
|
||||
case EMOJI_USE:
|
||||
return updateFrequentEmojis(state, action.emoji);
|
||||
case SETTING_SAVE:
|
||||
return state.set('saved', true);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import {
|
||||
} from '../actions/timelines';
|
||||
import {
|
||||
ACCOUNT_BLOCK_SUCCESS,
|
||||
ACCOUNT_MUTE_SUCCESS,
|
||||
} from '../actions/accounts';
|
||||
import {
|
||||
NOTIFICATIONS_UPDATE,
|
||||
@@ -38,7 +39,7 @@ import {
|
||||
PINNED_STATUSES_FETCH_SUCCESS,
|
||||
} from '../actions/pin_statuses';
|
||||
import { SEARCH_FETCH_SUCCESS } from '../actions/search';
|
||||
import emojify from '../emoji';
|
||||
import emojify from '../features/emoji/emoji';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
import escapeTextContentForBrowser from 'escape-html';
|
||||
|
||||
@@ -57,9 +58,10 @@ const normalizeStatus = (state, status) => {
|
||||
normalStatus.reblog = status.reblog.id;
|
||||
}
|
||||
|
||||
const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
||||
const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
||||
|
||||
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
|
||||
obj[`:${emoji.shortcode}:`] = emoji.url;
|
||||
obj[`:${emoji.shortcode}:`] = emoji;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
@@ -138,6 +140,7 @@ export default function statuses(state = initialState, action) {
|
||||
case TIMELINE_DELETE:
|
||||
return deleteStatus(state, action.id, action.references);
|
||||
case ACCOUNT_BLOCK_SUCCESS:
|
||||
case ACCOUNT_MUTE_SUCCESS:
|
||||
return filterStatuses(state, action.relationship);
|
||||
default:
|
||||
return state;
|
||||
|
Reference in New Issue
Block a user