57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
|
import React from 'react';
|
||
|
import Flux from '../lib/flux';
|
||
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
||
|
import Guilds from './Guilds';
|
||
|
import Account from './Account';
|
||
|
import Channel from './Channel';
|
||
|
import Friends from './Friends';
|
||
|
import GuildSidebar from './guild_sidebar/GuildSidebar';
|
||
|
import PrivateChannels from './PrivateChannels';
|
||
|
import RTCConnection from './RTCConnection';
|
||
|
import SelectedChannelStore from '../stores/SelectedChannelStore';
|
||
|
import SelectedGuildStore from '../stores/SelectedGuildStore';
|
||
|
import DelayedSelectionStore from '../stores/DelayedSelectionStore';
|
||
|
|
||
|
import '../styles/channels.styl';
|
||
|
|
||
|
const AppView = React.createClass({
|
||
|
mixins: [
|
||
|
PureRenderMixin,
|
||
|
Flux.LazyStoreListenerMixin(DelayedSelectionStore, SelectedChannelStore, SelectedGuildStore),
|
||
|
],
|
||
|
|
||
|
getInitialState() {
|
||
|
return this.getStateFromStores();
|
||
|
},
|
||
|
|
||
|
getStateFromStores() {
|
||
|
const selectedChannelId = SelectedChannelStore.getChannelId(SelectedGuildStore.getGuildId());
|
||
|
const selectedGuildId = DelayedSelectionStore.getGuildId();
|
||
|
return {
|
||
|
selectedGuildId,
|
||
|
selectedChannelId,
|
||
|
};
|
||
|
},
|
||
|
|
||
|
render() {
|
||
|
const {selectedChannelId, selectedGuildId} = this.state;
|
||
|
return (
|
||
|
<section className="flex-horizontal flex-spacer">
|
||
|
<Guilds />
|
||
|
<div className="flex-vertical channels-wrap">
|
||
|
{selectedGuildId ? <GuildSidebar guildId={selectedGuildId} /> : <PrivateChannels />}
|
||
|
<RTCConnection />
|
||
|
<Account />
|
||
|
</div>
|
||
|
{selectedChannelId ? <Channel /> : <Friends />}
|
||
|
</section>
|
||
|
);
|
||
|
},
|
||
|
});
|
||
|
|
||
|
export default AppView;
|
||
|
|
||
|
|
||
|
|
||
|
// WEBPACK FOOTER //
|
||
|
// ./discord_app/components/AppView.js
|