mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 17:41:11 +08:00
Merge pull request #1255 from coralproject/fix-live-status-changes
Fix live status updates
This commit is contained in:
@@ -5,6 +5,11 @@ import {notify} from 'coral-framework/actions/notification';
|
||||
import t from 'coral-framework/services/i18n';
|
||||
import get from 'lodash/get';
|
||||
|
||||
export const updateStatus = (status) => ({
|
||||
type: actions.UPDATE_STATUS,
|
||||
status,
|
||||
});
|
||||
|
||||
export const showSignInDialog = () => ({
|
||||
type: actions.SHOW_SIGNIN_DIALOG,
|
||||
});
|
||||
|
||||
@@ -54,3 +54,4 @@ export const SET_REQUIRE_EMAIL_VERIFICATION = 'SET_REQUIRE_EMAIL_VERIFICATION';
|
||||
export const SET_REDIRECT_URI = 'SET_REDIRECT_URI';
|
||||
|
||||
export const RESET_SIGNIN_DIALOG = 'RESET_SIGNIN_DIALOG';
|
||||
export const UPDATE_STATUS = 'UPDATE_STATUS';
|
||||
|
||||
@@ -21,7 +21,14 @@ import t from 'coral-framework/services/i18n';
|
||||
import PropTypes from 'prop-types';
|
||||
import {setActiveTab} from '../actions/embed';
|
||||
|
||||
const {logout, checkLogin, focusSignInDialog, blurSignInDialog, hideSignInDialog} = authActions;
|
||||
const {
|
||||
logout,
|
||||
checkLogin,
|
||||
focusSignInDialog,
|
||||
blurSignInDialog,
|
||||
hideSignInDialog,
|
||||
updateStatus,
|
||||
} = authActions;
|
||||
const {fetchAssetSuccess} = assetActions;
|
||||
|
||||
class EmbedContainer extends React.Component {
|
||||
@@ -35,20 +42,23 @@ class EmbedContainer extends React.Component {
|
||||
if (props.auth.loggedIn) {
|
||||
const newSubscriptions = [{
|
||||
document: USER_BANNED_SUBSCRIPTION,
|
||||
updateQuery: () => {
|
||||
updateQuery: (_, {subscriptionData: {data: {userBanned: {state}}}}) => {
|
||||
notify('info', t('your_account_has_been_banned'));
|
||||
props.updateStatus(state.status);
|
||||
},
|
||||
},
|
||||
{
|
||||
document: USER_SUSPENDED_SUBSCRIPTION,
|
||||
updateQuery: () => {
|
||||
updateQuery: (_, {subscriptionData: {data: {userSuspended: {state}}}}) => {
|
||||
notify('info', t('your_account_has_been_suspended'));
|
||||
props.updateStatus(state.status);
|
||||
},
|
||||
},
|
||||
{
|
||||
document: USERNAME_REJECTED_SUBSCRIPTION,
|
||||
updateQuery: () => {
|
||||
updateQuery: (_, {subscriptionData: {data: {usernameRejected: {state}}}}) => {
|
||||
notify('info', t('your_username_has_been_rejected'));
|
||||
props.updateStatus(state.status);
|
||||
},
|
||||
}];
|
||||
|
||||
@@ -260,6 +270,7 @@ const mapDispatchToProps = (dispatch) =>
|
||||
focusSignInDialog,
|
||||
blurSignInDialog,
|
||||
hideSignInDialog,
|
||||
updateStatus,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as actions from '../constants/auth';
|
||||
import pym from 'coral-framework/services/pym';
|
||||
import merge from 'lodash/merge';
|
||||
|
||||
const initialState = {
|
||||
isLoading: false,
|
||||
@@ -227,38 +228,15 @@ export default function auth (state = initialState, action) {
|
||||
...state,
|
||||
redirectUri: action.uri,
|
||||
};
|
||||
case 'APOLLO_SUBSCRIPTION_RESULT':
|
||||
|
||||
// @TODO: These don't work anymore because apollo store has been decoupled
|
||||
|
||||
if (action.operationName === 'UserBanned' && state.user.id === action.variables.user_id) {
|
||||
return {
|
||||
...state,
|
||||
user: {
|
||||
...state.user,
|
||||
...action.result.data.userBanned,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (action.operationName === 'UserSuspended' && state.user.id === action.variables.user_id) {
|
||||
return {
|
||||
...state,
|
||||
user: {
|
||||
...state.user,
|
||||
...action.result.data.userSuspended,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (action.operationName === 'UsernameRejected' && state.user.id === action.variables.user_id) {
|
||||
return {
|
||||
...state,
|
||||
user: {
|
||||
...state.user,
|
||||
...action.result.data.usernameRejected,
|
||||
},
|
||||
};
|
||||
}
|
||||
return state;
|
||||
case actions.UPDATE_STATUS: {
|
||||
return {
|
||||
...state,
|
||||
user: {
|
||||
...state.user,
|
||||
status: merge({}, state.user.status, action.status),
|
||||
},
|
||||
};
|
||||
}
|
||||
default :
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user