Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
Make VcsData null check compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-shatskyi committed Jun 2, 2016
1 parent 7fce4a8 commit 0a91182
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/plugins/GitWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class GitWatcher extends EventEmitter {
const status: VcsStatus = changes.length ? "dirty" : "clean";

const data: VcsData = {
isRepository: true,
branch: head,
status: status,
};
Expand Down
4 changes: 2 additions & 2 deletions src/views/2_SessionComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
}

interface State {
vcsData: VcsData;
vcsData: VcsData | undefined;
}

export class SessionComponent extends React.Component<Props, State> {
Expand All @@ -24,7 +24,7 @@ export class SessionComponent extends React.Component<Props, State> {
super(props);

this.state = {
vcsData: {isRepository: false},
vcsData: undefined,
};
}

Expand Down
27 changes: 13 additions & 14 deletions src/views/StatusLineComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@ const CurrentDirectory = ({currentWorkingDirectory}: { currentWorkingDirectory:
{currentWorkingDirectory}
</div>;

const VcsDataComponent = ({data}: { data: VcsData }) => {
if (!data.isRepository) {
/* tslint:disable:no-null-keyword */
return null;
}

return (
<div style={css.statusLine.vcsData}>
<div style={css.statusLine.status(data.status)}>
<span style={css.statusLine.icon} dangerouslySetInnerHTML={{__html: fontAwesome.codeFork}}/>
{data.branch}
const VcsDataComponent = ({data}: { data: VcsData | undefined }) => {
if (data) {
return (
<div style={css.statusLine.vcsData}>
<div style={css.statusLine.status(data.status)}>
<span style={css.statusLine.icon} dangerouslySetInnerHTML={{__html: fontAwesome.codeFork}}/>
{data.branch}
</div>
</div>
</div>
);
);
} else {
return <div></div>;
}
};

export const StatusLineComponent = ({currentWorkingDirectory, vcsData}: { currentWorkingDirectory: string; vcsData: VcsData }) =>
export const StatusLineComponent = ({currentWorkingDirectory, vcsData}: { currentWorkingDirectory: string; vcsData: VcsData | undefined }) =>
<div style={css.statusLine.itself}>
<CurrentDirectory currentWorkingDirectory={currentWorkingDirectory}/>
<VcsDataComponent data={vcsData}/>
Expand Down
5 changes: 2 additions & 3 deletions typings/Interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ interface PartialRowColumn {
type VcsStatus = "dirty" | "clean";

interface VcsData {
isRepository: boolean;
branch?: string;
status?: VcsStatus;
branch: string;
status: VcsStatus;
}

interface Margins {
Expand Down

0 comments on commit 0a91182

Please sign in to comment.