mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 11:04:05 +08:00
feat: hide profile tab when not logged in
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
} from "talk-ui/components";
|
||||
|
||||
import { PropTypesOf } from "talk-ui/types";
|
||||
import IfLoggedInContainer from "../containers/IfLoggedInContainer";
|
||||
import CommentsPaneContainer from "../tabs/comments/containers/CommentsPaneContainer";
|
||||
import ProfileQuery from "../tabs/profile/queries/ProfileQuery";
|
||||
import * as styles from "./App.css";
|
||||
@@ -29,9 +30,11 @@ const CommentsTab: StatelessComponent<PropTypesOf<typeof Tab>> = props => (
|
||||
);
|
||||
|
||||
const MyProfileTab: StatelessComponent<PropTypesOf<typeof Tab>> = props => (
|
||||
<Localized id="general-app-myProfileTab">
|
||||
<Tab {...props}>My Profile</Tab>
|
||||
</Localized>
|
||||
<IfLoggedInContainer>
|
||||
<Localized id="general-app-myProfileTab">
|
||||
<Tab {...props}>My Profile</Tab>
|
||||
</Localized>
|
||||
</IfLoggedInContainer>
|
||||
);
|
||||
|
||||
const App: StatelessComponent<AppProps> = props => {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import React, { Component } from "react";
|
||||
|
||||
import { graphql, QueryRenderer } from "talk-framework/lib/relay";
|
||||
import { IfLoggedInContainerQuery as QueryTypes } from "talk-stream/__generated__/IfLoggedInContainerQuery.graphql";
|
||||
|
||||
class IfLoggedInContainer extends Component {
|
||||
public render() {
|
||||
return (
|
||||
<QueryRenderer<QueryTypes>
|
||||
query={graphql`
|
||||
query IfLoggedInContainerQuery {
|
||||
me {
|
||||
id
|
||||
}
|
||||
}
|
||||
`}
|
||||
render={({ error, props }) => {
|
||||
if (error) {
|
||||
return <div>{error.message}</div>;
|
||||
}
|
||||
|
||||
if (props && props.me) {
|
||||
return <>{this.props.children}</>;
|
||||
}
|
||||
|
||||
return null;
|
||||
}}
|
||||
variables={{}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default IfLoggedInContainer;
|
||||
@@ -4,8 +4,8 @@ import { StatelessComponent } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
|
||||
import { createManaged } from "talk-framework/lib/bootstrap";
|
||||
import AppContainer from "talk-stream/containers/AppContainer";
|
||||
|
||||
import AppContainer from "./containers/AppContainer";
|
||||
import {
|
||||
OnPostMessageAuthError,
|
||||
OnPostMessageSetAuthToken,
|
||||
|
||||
Reference in New Issue
Block a user