Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Commit

Permalink
Shows share menu only if firebase has been initialized properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscox committed Mar 22, 2017
1 parent 3818f26 commit 8ef2372
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
12 changes: 12 additions & 0 deletions src/lib/Remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ export class Remote {
return `https://${authDomain}/${this._remoteId}`;
}

private _initialized: boolean = false;

/**
* Returns whether the remote has been initialized with Firebase credentials.
* @readonly
* @return {boolean} Returns true if has Firebase credentials.
*/
get initialized(): boolean {
return this._initialized;
}

/**
* Initializes the remote controller.
*
Expand Down Expand Up @@ -127,6 +138,7 @@ export class Remote {
}

firebase.initializeApp(config);
instance._initialized = Object.keys(config).length !== 0;
}

/**
Expand Down
48 changes: 27 additions & 21 deletions src/ui/OverlayController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { Variable } from "../core/variables/Variable";
* @interface
*/
interface IControllerProps {
remote: Remote;
remote?: Remote;
updateVariable(variable: Variable, selectedValue: any): void;
toggleRemoteEnabled(): void;
variables: Variable[];
Expand Down Expand Up @@ -114,40 +114,46 @@ export class OverlayController extends React.Component<IControllerProps, IContro
updateVariable,
variables
} = this.props;

const { shareMenuIsVisible } = this.state;
const remoteInitialized = remote ? remote.initialized : false;

let shareIcon: string = shareMenuIsVisible ? "up" : "down";
return (
<div className="mdl-card mdl-shadow--6dp">
<div className="mdl-card__title">
<h2 className="mdl-card__title-text">Remixer</h2>
</div>
<OverlayShareMenu
visible={shareMenuIsVisible}
remoteId={remote.remoteId}
remoteUrl={remote.remoteUrl}
isEnabled={remote.isEnabled}
toggleRemoteEnabled={toggleRemoteEnabled}
/>
{remoteInitialized ?
<OverlayShareMenu
visible={shareMenuIsVisible}
remoteId={remote.remoteId}
remoteUrl={remote.remoteUrl}
isEnabled={remote.isEnabled}
toggleRemoteEnabled={toggleRemoteEnabled}
/>
: ""
}
<div className={`mdl-card__actions mdl-card--border`}>
<OverlayVariables
variables={variables}
updateVariable={updateVariable}
/>
</div>
<div className="mdl-card__menu">
{remote.isEnabled ?
<a onClick={this.toggleShareMenu}>SHARED</a>
: ""
}
<button
className="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"
onClick={this.toggleShareMenu}
>
<i className="material-icons">{`keyboard_arrow_${shareIcon}`}</i>
</button>
</div>
{remoteInitialized ?
<div className="mdl-card__menu">
{remote.isEnabled ?
<a onClick={this.toggleShareMenu}>SHARED</a>
: ""
}
<button
className="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"
onClick={this.toggleShareMenu}
>
<i className="material-icons">{`keyboard_arrow_${shareIcon}`}</i>
</button>
</div>
: ""
}
</div>
);
}
Expand Down

0 comments on commit 8ef2372

Please sign in to comment.