2017-06-08_509bba0/509bba0_unpacked_with_node_modules/discord_app/components/AppView.js

57 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-07-26 17:06:20 +00:00
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