mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
Fully implement SetUsername
This commit is contained in:
@@ -43,7 +43,7 @@ export const hideCreateUsernameDialog = () => ({
|
||||
type: actions.HIDE_CREATEUSERNAME_DIALOG
|
||||
});
|
||||
|
||||
export const updateUsername = ({username}) => ({
|
||||
export const updateUsername = (username) => ({
|
||||
type: actions.UPDATE_USERNAME,
|
||||
username
|
||||
});
|
||||
|
||||
@@ -198,6 +198,7 @@ export default function auth (state = initialState, action) {
|
||||
user: {
|
||||
...state.user,
|
||||
username: action.username,
|
||||
lowercaseUsername: action.username.toLowerCase(),
|
||||
}
|
||||
};
|
||||
case actions.VERIFY_EMAIL_FAILURE:
|
||||
@@ -230,7 +231,7 @@ export default function auth (state = initialState, action) {
|
||||
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,
|
||||
|
||||
@@ -234,6 +234,11 @@ export const withRejectUsername = withMutation(
|
||||
})
|
||||
});
|
||||
|
||||
const SetUsernameFragment = gql`
|
||||
fragment Talk_SetUsername on User {
|
||||
username
|
||||
}`;
|
||||
|
||||
export const withChangeUsername = withMutation(
|
||||
gql`
|
||||
mutation ChangeUsername($id: ID!, $username: String!) {
|
||||
@@ -249,6 +254,14 @@ export const withChangeUsername = withMutation(
|
||||
id,
|
||||
username,
|
||||
},
|
||||
update: (proxy) => {
|
||||
const fragmentId = `User_${id}`;
|
||||
const data = {
|
||||
__typename: 'User',
|
||||
username,
|
||||
};
|
||||
proxy.writeFragment({fragment: SetUsernameFragment, id: fragmentId, data});
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
@@ -269,6 +282,14 @@ export const withSetUsername = withMutation(
|
||||
id,
|
||||
username,
|
||||
},
|
||||
update: (proxy) => {
|
||||
const fragmentId = `User_${id}`;
|
||||
const data = {
|
||||
__typename: 'User',
|
||||
username,
|
||||
};
|
||||
proxy.writeFragment({fragment: SetUsernameFragment, id: fragmentId, data});
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user