remove status from group ui
This commit is contained in:
parent
caaa9253d6
commit
62b1707a85
|
@ -47,6 +47,10 @@ export const GROUP_REMOVED_ACCOUNTS_CREATE_REQUEST = 'GROUP_REMOVED_ACCOUNTS_CRE
|
|||
export const GROUP_REMOVED_ACCOUNTS_CREATE_SUCCESS = 'GROUP_REMOVED_ACCOUNTS_CREATE_SUCCESS';
|
||||
export const GROUP_REMOVED_ACCOUNTS_CREATE_FAIL = 'GROUP_REMOVED_ACCOUNTS_CREATE_FAIL';
|
||||
|
||||
export const GROUP_REMOVE_STATUS_REQUEST = 'GROUP_REMOVE_STATUS_REQUEST';
|
||||
export const GROUP_REMOVE_STATUS_SUCCESS = 'GROUP_REMOVE_STATUS_SUCCESS';
|
||||
export const GROUP_REMOVE_STATUS_FAIL = 'GROUP_REMOVE_STATUS_FAIL';
|
||||
|
||||
export const fetchGroup = id => (dispatch, getState) => {
|
||||
if (!me) return;
|
||||
|
||||
|
@ -478,4 +482,43 @@ export function createRemovedAccountFail(groupId, id, error) {
|
|||
id,
|
||||
error,
|
||||
};
|
||||
};
|
||||
|
||||
export function groupRemoveStatus(groupId, id) {
|
||||
return (dispatch, getState) => {
|
||||
if (!me) return;
|
||||
|
||||
dispatch(groupRemoveStatusRequest(groupId, id));
|
||||
|
||||
api(getState).delete(`/api/v1/groups/${groupId}/statuses/${id}`).then(response => {
|
||||
dispatch(groupRemoveStatusSuccess(groupId, id));
|
||||
}).catch(error => {
|
||||
dispatch(groupRemoveStatusFail(groupId, id, error));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export function groupRemoveStatusRequest(groupId, id) {
|
||||
return {
|
||||
type: GROUP_REMOVE_STATUS_REQUEST,
|
||||
groupId,
|
||||
id,
|
||||
};
|
||||
};
|
||||
|
||||
export function groupRemoveStatusSuccess(groupId, id) {
|
||||
return {
|
||||
type: GROUP_REMOVE_STATUS_SUCCESS,
|
||||
groupId,
|
||||
id,
|
||||
};
|
||||
};
|
||||
|
||||
export function groupRemoveStatusFail(groupId, id, error) {
|
||||
return {
|
||||
type: GROUP_REMOVE_STATUS_FAIL,
|
||||
groupId,
|
||||
id,
|
||||
error,
|
||||
};
|
||||
};
|
|
@ -38,6 +38,7 @@ const messages = defineMessages({
|
|||
admin_status: { id: 'status.admin_status', defaultMessage: 'Open this status in the moderation interface' },
|
||||
copy: { id: 'status.copy', defaultMessage: 'Copy link to status' },
|
||||
group_remove_account: { id: 'status.remove_account_from_group', defaultMessage: 'Remove account from group' },
|
||||
group_remove_post: { id: 'status.remove_post_from_group', defaultMessage: 'Remove status from group' },
|
||||
});
|
||||
|
||||
class StatusActionBar extends ImmutablePureComponent {
|
||||
|
@ -174,6 +175,12 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
this.props.onGroupRemoveAccount(status.get('group_id'), status.getIn(['account', 'id']));
|
||||
}
|
||||
|
||||
handleGroupRemovePost = () => {
|
||||
const { status } = this.props;
|
||||
|
||||
this.props.onGroupRemoveStatus(status.get('group_id'), status.get('id'));
|
||||
}
|
||||
|
||||
_makeMenu = (publicStatus) => {
|
||||
const { status, intl, withDismiss, withGroupAdmin } = this.props;
|
||||
const mutingConversation = status.get('muted');
|
||||
|
@ -226,6 +233,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
if (withGroupAdmin) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.group_remove_account), action: this.handleGroupRemoveAccount });
|
||||
menu.push({ text: intl.formatMessage(messages.group_remove_post), action: this.handleGroupRemovePost });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,10 @@ import { openModal } from '../actions/modal';
|
|||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||
import { boostModal, deleteModal } from '../initial_state';
|
||||
import { showAlertForError } from '../actions/alerts';
|
||||
import { createRemovedAccount } from '../actions/groups';
|
||||
import {
|
||||
createRemovedAccount,
|
||||
groupRemoveStatus
|
||||
} from '../actions/groups';
|
||||
|
||||
const messages = defineMessages({
|
||||
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||||
|
@ -178,6 +181,10 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
dispatch(createRemovedAccount(groupId, accountId));
|
||||
},
|
||||
|
||||
onGroupRemoveStatus(groupId, statusId) {
|
||||
dispatch(groupRemoveStatus(groupId, statusId));
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Status));
|
||||
|
|
|
@ -63,7 +63,7 @@ class GroupTimeline extends React.PureComponent {
|
|||
const { columnId, group, relationships, account } = this.props;
|
||||
const { id } = this.props.params;
|
||||
|
||||
if (typeof group === 'undefined') {
|
||||
if (typeof group === 'undefined' || !relationships) {
|
||||
return (
|
||||
<Column>
|
||||
<LoadingIndicator />
|
||||
|
@ -79,7 +79,7 @@ class GroupTimeline extends React.PureComponent {
|
|||
|
||||
return (
|
||||
<div>
|
||||
{relationships && relationships.get('member') && (
|
||||
{relationships.get('member') && (
|
||||
<div className='timeline-compose-block'>
|
||||
<div className='timeline-compose-block__avatar'>
|
||||
<Avatar account={account} size={46} />
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
} from '../actions/accounts';
|
||||
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||
import compareId from '../compare_id';
|
||||
import { GROUP_REMOVE_STATUS_SUCCESS } from '../actions/groups';
|
||||
|
||||
const initialState = ImmutableMap();
|
||||
|
||||
|
@ -143,6 +144,10 @@ const filterTimeline = (timeline, state, relationship, statuses) =>
|
|||
statuses.getIn([statusId, 'account']) === relationship.id
|
||||
));
|
||||
|
||||
const removeStatusFromGroup = (state, groupId, statusId) => {
|
||||
return state.updateIn([`group:${groupId}`, 'items'], list => list.filterNot(item => item === statusId));
|
||||
};
|
||||
|
||||
export default function timelines(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case TIMELINE_EXPAND_REQUEST:
|
||||
|
@ -177,6 +182,8 @@ export default function timelines(state = initialState, action) {
|
|||
initialTimeline,
|
||||
map => map.set('online', false).update('items', items => items.first() ? items.unshift(null) : items)
|
||||
);
|
||||
case GROUP_REMOVE_STATUS_SUCCESS:
|
||||
return removeStatusFromGroup(state, action.groupId, action.id)
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue