Add files
This commit is contained in:
commit
bb80829159
18195 changed files with 2122994 additions and 0 deletions
31
509bba0_unpacked/discord_app/mixins/ComponentDispatchMixin.js
Executable file
31
509bba0_unpacked/discord_app/mixins/ComponentDispatchMixin.js
Executable file
|
@ -0,0 +1,31 @@
|
|||
/* @flow */
|
||||
|
||||
import {ComponentDispatch} from '../utils/ComponentDispatchUtils';
|
||||
|
||||
export default {
|
||||
componentDidMount() {
|
||||
if (typeof this.getSubscriptions !== 'function') {
|
||||
return;
|
||||
}
|
||||
this._subscriptions = this.getSubscriptions();
|
||||
for (const type in this._subscriptions) {
|
||||
if (this._subscriptions.hasOwnProperty(type)) {
|
||||
ComponentDispatch.subscribe(type, this._subscriptions[type]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
for (const type in this._subscriptions) {
|
||||
if (!this._subscriptions.hasOwnProperty(type)) {
|
||||
continue;
|
||||
}
|
||||
ComponentDispatch.unsubscribe(type, this._subscriptions[type]);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
// WEBPACK FOOTER //
|
||||
// ./discord_app/mixins/ComponentDispatchMixin.js
|
71
509bba0_unpacked/discord_app/mixins/PermissionMixin.js
Executable file
71
509bba0_unpacked/discord_app/mixins/PermissionMixin.js
Executable file
|
@ -0,0 +1,71 @@
|
|||
/* @flow */
|
||||
|
||||
import PermissionStore from '../stores/PermissionStore';
|
||||
import ChannelRecord from '../records/ChannelRecord';
|
||||
import GuildRecord from '../records/GuildRecord';
|
||||
import UserRecord from '../records/UserRecord';
|
||||
|
||||
type Context = GuildRecord | ChannelRecord | {channelId: string} | {guildId: string};
|
||||
type Permissions = {[key: string]: number};
|
||||
type State = {
|
||||
__PermissionMixinGuilds: Permissions,
|
||||
__PermissionMixinChannels: Permissions,
|
||||
};
|
||||
|
||||
const PermissionMixin = {
|
||||
getInitialState(): State {
|
||||
return this.getStateFromPermissionStore();
|
||||
},
|
||||
|
||||
componentWillMount() {
|
||||
PermissionStore.addChangeListener(this.permissionStoreDidChange);
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
PermissionStore.removeChangeListener(this.permissionStoreDidChange);
|
||||
},
|
||||
|
||||
permissionStoreDidChange() {
|
||||
if (this.isMounted()) {
|
||||
this.setState(this.getStateFromPermissionStore());
|
||||
}
|
||||
},
|
||||
|
||||
didPermissionsUpdate(nextState: State, channel?: ChannelRecord): boolean {
|
||||
const {__PermissionMixinGuilds, __PermissionMixinChannels} = this.state;
|
||||
if (channel == null) {
|
||||
return (
|
||||
__PermissionMixinGuilds !== nextState.__PermissionMixinGuilds ||
|
||||
__PermissionMixinChannels !== nextState.__PermissionMixinChannels
|
||||
);
|
||||
}
|
||||
const guildId = channel.getGuildId();
|
||||
return (
|
||||
__PermissionMixinChannels[channel.id] !== nextState.__PermissionMixinChannels[channel.id] ||
|
||||
(guildId != null && __PermissionMixinGuilds[guildId] !== nextState.__PermissionMixinGuilds[guildId])
|
||||
);
|
||||
},
|
||||
|
||||
getStateFromPermissionStore(): State {
|
||||
const {guilds, channels} = PermissionStore.getState();
|
||||
return {
|
||||
__PermissionMixinGuilds: guilds,
|
||||
__PermissionMixinChannels: channels,
|
||||
};
|
||||
},
|
||||
|
||||
can(permission: number, context: Context): boolean {
|
||||
return PermissionStore.can(permission, context);
|
||||
},
|
||||
|
||||
canManageUser(permission: number, otherUser: UserRecord | string, guild: GuildRecord): boolean {
|
||||
return PermissionStore.canManageUser(permission, otherUser, guild);
|
||||
},
|
||||
};
|
||||
|
||||
export default PermissionMixin;
|
||||
|
||||
|
||||
|
||||
// WEBPACK FOOTER //
|
||||
// ./discord_app/mixins/PermissionMixin.js
|
20
509bba0_unpacked/discord_app/mixins/PrivateChannelsMixin.js
Executable file
20
509bba0_unpacked/discord_app/mixins/PrivateChannelsMixin.js
Executable file
|
@ -0,0 +1,20 @@
|
|||
import ChannelStore from '../stores/ChannelStore';
|
||||
import PrivateChannelSortStore from '../stores/views/PrivateChannelSortStore';
|
||||
|
||||
export default {
|
||||
getPrivateChannelsStores() {
|
||||
return [ChannelStore, PrivateChannelSortStore];
|
||||
},
|
||||
|
||||
getPrivateChannelsState() {
|
||||
return {
|
||||
channels: ChannelStore.getChannels(),
|
||||
privateChannelIds: PrivateChannelSortStore.getPrivateChannelIds(),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
// WEBPACK FOOTER //
|
||||
// ./discord_app/mixins/PrivateChannelsMixin.js
|
82
509bba0_unpacked/discord_app/mixins/ResultMixin.js
Executable file
82
509bba0_unpacked/discord_app/mixins/ResultMixin.js
Executable file
|
@ -0,0 +1,82 @@
|
|||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import Storage from '../lib/Storage';
|
||||
import {ComponentDispatch} from '../utils/ComponentDispatchUtils';
|
||||
import {ComponentActions} from '../Constants';
|
||||
|
||||
// FIXME: For debugging purposes only
|
||||
const showScore = !!Storage.get('showScore');
|
||||
|
||||
export default {
|
||||
propTypes: {
|
||||
result: React.PropTypes.object.isRequired,
|
||||
selected: React.PropTypes.bool,
|
||||
},
|
||||
|
||||
contextTypes: {
|
||||
selectResult: React.PropTypes.func,
|
||||
focusResult: React.PropTypes.func,
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.selected) {
|
||||
ComponentDispatch.dispatch(ComponentActions.QUICKSWITCHER_RESULT_FOCUS, {
|
||||
node: this._resultNode,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.props.selected) {
|
||||
ComponentDispatch.dispatch(ComponentActions.QUICKSWITCHER_RESULT_FOCUS, {
|
||||
node: this._resultNode,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
handleClick() {
|
||||
this.context.selectResult(this.props.result);
|
||||
},
|
||||
|
||||
handleMouseEnter() {
|
||||
this.context.focusResult(this.props.result);
|
||||
},
|
||||
|
||||
getNode() {
|
||||
return this._resultNode;
|
||||
},
|
||||
|
||||
setRef(resultNode) {
|
||||
this._resultNode = resultNode;
|
||||
},
|
||||
|
||||
renderScore() {
|
||||
if (!showScore) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div className="result-score">
|
||||
{this.props.score}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
render() {
|
||||
const {selected} = this.props;
|
||||
return (
|
||||
<div
|
||||
ref={this.setRef}
|
||||
className={classNames('result', {selected})}
|
||||
onClick={this.handleClick}
|
||||
onMouseEnter={this.handleMouseEnter}>
|
||||
{this.renderScore()}
|
||||
{this.renderResult()}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
// WEBPACK FOOTER //
|
||||
// ./discord_app/mixins/ResultMixin.js
|
21
509bba0_unpacked/discord_app/mixins/web/AuthenticationMixin.js
Executable file
21
509bba0_unpacked/discord_app/mixins/web/AuthenticationMixin.js
Executable file
|
@ -0,0 +1,21 @@
|
|||
import AuthenticationStore from '../../stores/AuthenticationStore';
|
||||
import {Routes} from '../../Constants';
|
||||
|
||||
const AuthenticationMixin = {
|
||||
statics: {
|
||||
Authenticate(nextState, replace) {
|
||||
if (!AuthenticationStore.isAuthenticated()) {
|
||||
replace({
|
||||
pathname: Routes.LOGIN,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default AuthenticationMixin;
|
||||
|
||||
|
||||
|
||||
// WEBPACK FOOTER //
|
||||
// ./discord_app/mixins/web/AuthenticationMixin.js
|
49
509bba0_unpacked/discord_app/mixins/web/ChatRestrictionMixin.js
Executable file
49
509bba0_unpacked/discord_app/mixins/web/ChatRestrictionMixin.js
Executable file
|
@ -0,0 +1,49 @@
|
|||
import React from 'react';
|
||||
import MessageQueue from '../../lib/MessageQueue';
|
||||
import ModalActionCreators from '../../actions/ModalActionCreators';
|
||||
import Alert from '../../components/Alert';
|
||||
import {MAX_MESSAGE_LENGTH} from '../../Constants';
|
||||
import i18n from '../../i18n';
|
||||
|
||||
const ChatRestrictionMixin = {
|
||||
applyChatRestrictions(content) {
|
||||
if (content.length > MAX_MESSAGE_LENGTH) {
|
||||
ModalActionCreators.push(props => {
|
||||
return (
|
||||
<Alert
|
||||
title={i18n.Messages.MESSAGE_TOO_LONG_HEADER}
|
||||
body={i18n.Messages.MESSAGE_TOO_LONG_BODY.format({maxLength: MAX_MESSAGE_LENGTH})}
|
||||
confirmText={i18n.Messages.OKAY}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (MessageQueue.isFull()) {
|
||||
ModalActionCreators.push(props => {
|
||||
return (
|
||||
<Alert
|
||||
title={i18n.Messages.MESSAGE_RATE_LIMITED_HEADER}
|
||||
body={i18n.Messages.MESSAGE_RATE_LIMITED_BODY}
|
||||
confirmText={i18n.Messages.MESSAGE_RATE_LIMITED_BUTTON}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
export default ChatRestrictionMixin;
|
||||
|
||||
|
||||
|
||||
// WEBPACK FOOTER //
|
||||
// ./discord_app/mixins/web/ChatRestrictionMixin.js
|
38
509bba0_unpacked/discord_app/mixins/web/UploadMixin.js
Executable file
38
509bba0_unpacked/discord_app/mixins/web/UploadMixin.js
Executable file
|
@ -0,0 +1,38 @@
|
|||
import UserStore from '../../stores/UserStore';
|
||||
import UploadModalActionCreators from '../../actions/UploadModalActionCreators';
|
||||
import UploadActionCreators from '../../actions/UploadActionCreators';
|
||||
import UploadError from '../../components/warnings/UploadError';
|
||||
import UploadModal from '../../components/UploadModal';
|
||||
import ModalActionCreators from '../../actions/ModalActionCreators';
|
||||
import ModalStore from '../../stores/ModalStore';
|
||||
import i18n from '../../i18n';
|
||||
import * as FileUtils from '../../utils/FileUtils';
|
||||
import '../../styles/upload_premium_promo.styl';
|
||||
|
||||
const UploadMixin = {
|
||||
promptToUpload(files, channelId, backdropInstant = false, requireConfirm = true) {
|
||||
if (FileUtils.anyFileTooLarge(files)) {
|
||||
const user = UserStore.getCurrentUser();
|
||||
ModalActionCreators.push(UploadError, {
|
||||
title: i18n.Messages.UPLOAD_AREA_TOO_LARGE_TITLE,
|
||||
help: i18n.Messages.UPLOAD_AREA_TOO_LARGE_HELP.format({maxSize: FileUtils.sizeString(FileUtils.maxFileSize())}),
|
||||
promo: !user.premium,
|
||||
});
|
||||
} else if (requireConfirm) {
|
||||
UploadModalActionCreators.pushFiles({files, channelId});
|
||||
|
||||
if (!ModalStore.isModalOpen(UploadModal)) {
|
||||
ModalActionCreators.push(UploadModal, {backdropInstant});
|
||||
}
|
||||
} else {
|
||||
UploadActionCreators.instantBatchUpload(channelId, files);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default UploadMixin;
|
||||
|
||||
|
||||
|
||||
// WEBPACK FOOTER //
|
||||
// ./discord_app/mixins/web/UploadMixin.js
|
Loading…
Add table
Add a link
Reference in a new issue