mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 17:45:56 +08:00
Fix login issues
This commit is contained in:
@@ -22,10 +22,9 @@ const {fetchAssetSuccess} = assetActions;
|
||||
class EmbedContainer extends React.Component {
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.root.me && !nextProps.root.me) {
|
||||
if (this.props.auth.loggedIn !== nextProps.auth.loggedIn) {
|
||||
|
||||
// Refetch because on logout `excludeIgnored` becomes `false`.
|
||||
// TODO: logout via mutation and obsolete this?
|
||||
// Refetch after login/logout.
|
||||
this.props.data.refetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -205,10 +205,6 @@ const fragments = {
|
||||
}
|
||||
me {
|
||||
status
|
||||
ignoredUsers {
|
||||
id
|
||||
username
|
||||
}
|
||||
}
|
||||
...${getDefinitionName(Comment.fragments.root)}
|
||||
}
|
||||
|
||||
@@ -126,14 +126,14 @@ const extension = {
|
||||
|
||||
// TODO: don't rely on refetching.
|
||||
refetchQueries: [
|
||||
'EmbedQuery', 'myIgnoredUsers',
|
||||
'EmbedQuery', 'EmbedStreamProfileQuery',
|
||||
],
|
||||
}),
|
||||
StopIgnoringUser: () => ({
|
||||
|
||||
// TODO: don't rely on refetching.
|
||||
refetchQueries: [
|
||||
'EmbedQuery', 'myIgnoredUsers',
|
||||
'EmbedQuery', 'EmbedStreamProfileQuery',
|
||||
],
|
||||
}),
|
||||
PostComment: ({
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import {gql} from 'react-apollo';
|
||||
import client from 'coral-framework/services/client';
|
||||
import I18n from '../../coral-framework/modules/i18n/i18n';
|
||||
import translations from './../translations';
|
||||
const lang = new I18n(translations);
|
||||
@@ -7,30 +5,6 @@ import * as actions from '../constants/auth';
|
||||
import coralApi, {base} from '../helpers/response';
|
||||
import {pym} from 'coral-framework';
|
||||
|
||||
const ME_QUERY = gql`
|
||||
query Me {
|
||||
me {
|
||||
status
|
||||
comments {
|
||||
id
|
||||
body
|
||||
asset {
|
||||
id
|
||||
title
|
||||
url
|
||||
}
|
||||
created_at
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
function fetchMe() {
|
||||
return client.query({
|
||||
fetchPolicy: 'network-only',
|
||||
query: ME_QUERY});
|
||||
}
|
||||
|
||||
// Dialog Actions
|
||||
export const showSignInDialog = () => (dispatch) => {
|
||||
const signInPopUp = window.open(
|
||||
@@ -50,7 +24,6 @@ export const showSignInDialog = () => (dispatch) => {
|
||||
signInPopUp.onunload = () => {
|
||||
if (loaded) {
|
||||
dispatch(checkLogin());
|
||||
fetchMe();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -223,7 +196,6 @@ export const logout = () => (dispatch) => {
|
||||
return coralApi('/auth', {method: 'DELETE'})
|
||||
.then(() => {
|
||||
dispatch(logOutSuccess());
|
||||
fetchMe();
|
||||
})
|
||||
.catch((error) => dispatch(logOutFailure(error)));
|
||||
};
|
||||
|
||||
@@ -26,6 +26,14 @@ class ProfileContainer extends Component {
|
||||
this.handleTabChange = this.handleTabChange.bind(this);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.auth.loggedIn !== nextProps.auth.loggedIn) {
|
||||
|
||||
// Refetch after login/logout.
|
||||
this.props.data.refetch();
|
||||
}
|
||||
}
|
||||
|
||||
handleTabChange(tab) {
|
||||
this.setState({
|
||||
activeTab: tab
|
||||
@@ -33,7 +41,7 @@ class ProfileContainer extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const {asset, data, showSignInDialog, myIgnoredUsersData, stopIgnoringUser} = this.props;
|
||||
const {asset, data, showSignInDialog, stopIgnoringUser} = this.props;
|
||||
const {me} = this.props.data;
|
||||
|
||||
if (data.loading) {
|
||||
@@ -56,12 +64,12 @@ class ProfileContainer extends Component {
|
||||
}
|
||||
|
||||
{
|
||||
myIgnoredUsersData.me.ignoredUsers && myIgnoredUsersData.me.ignoredUsers.length
|
||||
me.ignoredUsers && me.ignoredUsers.length
|
||||
? (
|
||||
<div>
|
||||
<h3>Ignored users</h3>
|
||||
<IgnoredUsers
|
||||
users={myIgnoredUsersData.me.ignoredUsers}
|
||||
users={me.ignoredUsers}
|
||||
stopIgnoring={stopIgnoringUser}
|
||||
/>
|
||||
</div>
|
||||
@@ -87,32 +95,22 @@ class ProfileContainer extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
const withMyIgnoredUsersQuery = graphql(gql`
|
||||
query myIgnoredUsers {
|
||||
myIgnoredUsers {
|
||||
id,
|
||||
username,
|
||||
}
|
||||
}`, {
|
||||
props: ({data}) => {
|
||||
return ({
|
||||
myIgnoredUsersData: data
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const withMyCommentHistoryQuery = graphql(gql`
|
||||
query myCommentHistory {
|
||||
const withQuery = graphql(gql`
|
||||
query EmbedStreamProfileQuery {
|
||||
me {
|
||||
ignoredUsers {
|
||||
id,
|
||||
username,
|
||||
}
|
||||
comments {
|
||||
id
|
||||
body
|
||||
asset {
|
||||
id
|
||||
body
|
||||
asset {
|
||||
id
|
||||
title
|
||||
url
|
||||
}
|
||||
created_at
|
||||
title
|
||||
url
|
||||
}
|
||||
created_at
|
||||
}
|
||||
}
|
||||
}`);
|
||||
@@ -128,7 +126,6 @@ const mapDispatchToProps = (dispatch) =>
|
||||
|
||||
export default compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withMyCommentHistoryQuery,
|
||||
withMyIgnoredUsersQuery,
|
||||
withStopIgnoringUser,
|
||||
withQuery,
|
||||
)(ProfileContainer);
|
||||
|
||||
Reference in New Issue
Block a user