diff --git a/client/coral-embed-stream/src/containers/Embed.js b/client/coral-embed-stream/src/containers/Embed.js index 12c11c4e4..0ea577530 100644 --- a/client/coral-embed-stream/src/containers/Embed.js +++ b/client/coral-embed-stream/src/containers/Embed.js @@ -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(); } diff --git a/client/coral-embed-stream/src/containers/Stream.js b/client/coral-embed-stream/src/containers/Stream.js index 6a31f6f7e..daac49c51 100644 --- a/client/coral-embed-stream/src/containers/Stream.js +++ b/client/coral-embed-stream/src/containers/Stream.js @@ -205,10 +205,6 @@ const fragments = { } me { status - ignoredUsers { - id - username - } } ...${getDefinitionName(Comment.fragments.root)} } diff --git a/client/coral-embed-stream/src/graphql/index.js b/client/coral-embed-stream/src/graphql/index.js index 30db0cb39..5ab1f0c37 100644 --- a/client/coral-embed-stream/src/graphql/index.js +++ b/client/coral-embed-stream/src/graphql/index.js @@ -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: ({ diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 29057a6e3..93f889be2 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -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))); }; diff --git a/client/coral-settings/containers/ProfileContainer.js b/client/coral-settings/containers/ProfileContainer.js index b0b258f92..2d103fedb 100644 --- a/client/coral-settings/containers/ProfileContainer.js +++ b/client/coral-settings/containers/ProfileContainer.js @@ -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 ? (