Ignore own updates

This commit is contained in:
Chi Vinh Le
2018-01-18 16:08:46 +01:00
parent cc320cf80a
commit 5f3da9a09a
4 changed files with 24 additions and 6 deletions
@@ -11,7 +11,7 @@ import { viewUserDetail } from '../../../actions/userDetail';
import { getDefinitionName } from 'coral-framework/utils';
import { appendNewNodes } from 'plugin-api/beta/client/utils';
import update from 'immutability-helper';
import { handleFlaggedUserChange, cleanUpDangling } from '../graphql';
import { handleFlaggedUsernameChange, cleanUpDangling } from '../graphql';
import { notify } from 'coral-framework/actions/notification';
import { isFlaggedUserDangling } from '../utils';
@@ -39,7 +39,7 @@ class FlaggedAccountsContainer extends Component {
prev,
{ subscriptionData: { data: { usernameFlagged: user } } }
) => {
return handleFlaggedUserChange(prev, user, () => {
return handleFlaggedUsernameChange(prev, user, () => {
this.props.notify('info', `user ${user.username} flagged`);
});
},
@@ -50,7 +50,7 @@ class FlaggedAccountsContainer extends Component {
prev,
{ subscriptionData: { data: { usernameApproved: user } } }
) => {
return handleFlaggedUserChange(prev, user, () => {
return handleFlaggedUsernameChange(prev, user, () => {
this.props.notify('info', `user ${user.username} approved`);
});
},
@@ -61,7 +61,7 @@ class FlaggedAccountsContainer extends Component {
prev,
{ subscriptionData: { data: { usernameRejected: user } } }
) => {
return handleFlaggedUserChange(prev, user, () => {
return handleFlaggedUsernameChange(prev, user, () => {
this.props.notify('info', `user ${user.username} rejected`);
});
},
@@ -72,7 +72,7 @@ class FlaggedAccountsContainer extends Component {
prev,
{ subscriptionData: { data: { usernameChanged: user } } }
) => {
return handleFlaggedUserChange(prev, user, () => {
return handleFlaggedUsernameChange(prev, user, () => {
this.props.notify('info', `user ${user.username} changed`);
});
},
@@ -22,6 +22,13 @@ export default withFragments({
status {
username {
status
history {
status
assigned_by {
id
}
created_at
}
}
banned {
status
@@ -66,7 +66,16 @@ export function cleanUpDangling(root) {
* @param {function} notify callback to show notification
* @return {Object} next state of the store
*/
export function handleFlaggedUserChange(root, user, notify) {
export function handleFlaggedUsernameChange(root, user, notify) {
// Check if change came from current user, if so ignore it.
const lastChange =
user.state.status.username.history[
user.state.status.username.history.length - 1
];
if (lastChange.assigned_by.id === root.me.id) {
return root;
}
if (!hasFlaggedUser(root, user)) {
switch (user.state.status.username.status) {
case 'SET':
+2
View File
@@ -209,9 +209,11 @@ const UserSchema = new Schema(
delete ret.__v;
delete ret._id;
delete ret.password;
/*
delete ret.status.username.history;
delete ret.status.banned.history;
delete ret.status.suspension.history;
*/
delete ret.tokens;
},
},