Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/chatInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class ChatInput extends React.Component<Props, State> {
// decorators that are passed to the editor are removed from the editor
// state
setTimeout(() => {
this.editor && this.editor.focus();
this.editor && this.editor.focus && this.editor.focus();
}, 0);
};

Expand Down Expand Up @@ -400,7 +400,7 @@ class ChatInput extends React.Component<Props, State> {
// refocus the input
setTimeout(() => {
clear();
this.editor && this.editor.focus();
this.editor && this.editor.focus && this.editor.focus();
});

return 'handled';
Expand Down
2 changes: 2 additions & 0 deletions src/components/chatInput/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Props = {
networkDisabled: boolean,
children?: React$Node,
hasAttachment?: boolean,
code?: boolean,
};

type State = {
Expand Down Expand Up @@ -88,6 +89,7 @@ class Input extends React.Component<Props, State> {
networkDisabled,
children,
hasAttachment,
code,
...rest
} = this.props;
const { plugins } = this.state;
Expand Down
11 changes: 10 additions & 1 deletion src/components/draft-js-plugins-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@ class AndroidFallbackInput extends React.Component<Props, FallbackState> {
};

render() {
const {
editorState,
editorRef,
stripPastedStyles,
customStyleMap,
handleReturn,
editorKey,
...rest
} = this.props;
return (
<div className="DraftEditor-root">
<div className="DraftEditor-editorContainer">
<Textarea
{...this.props}
{...rest}
value={this.state.value}
onChange={this.onChange}
className={'DraftEditor-content ' + (this.props.className || '')}
Expand Down
5 changes: 4 additions & 1 deletion src/components/icons/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 49 additions & 23 deletions src/components/threadLikes/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// @flow
import React from 'react';
import * as React from 'react';
import { connect } from 'react-redux';
import type { Dispatch } from 'redux';
import compose from 'recompose/compose';
import type { GetThreadType } from 'shared/graphql/queries/thread/getThread';
import addThreadReactionMutation from 'shared/graphql/mutations/thread/addThreadReaction';
import removeThreadReactionMutation from 'shared/graphql/mutations/thread/removeThreadReaction';
import { openModal } from 'src/actions/modals';

import { IconButton } from 'src/components/buttons';
import Icon from 'src/components/icons';
Expand All @@ -13,40 +16,58 @@ type LikeButtonProps = {
thread: GetThreadType,
addThreadReaction: Function,
removeThreadReaction: Function,
currentUser: ?Object,
dispatch: Dispatch<Object>,
};

const LikeButtonPure = (props: LikeButtonProps) => {
const { thread } = props;
const { hasReacted, count } = thread.reactions;
class LikeButtonPure extends React.Component<LikeButtonProps> {
handleClick = () => {
const { thread, dispatch, currentUser } = this.props;

const addThreadReaction = () => {
const { thread, addThreadReaction } = props;
if (!currentUser || !currentUser.id) {
return dispatch(openModal('CHAT_INPUT_LOGIN_MODAL', {}));
}

const { hasReacted } = thread.reactions;
return hasReacted ? this.removeThreadReaction() : this.addThreadReaction();
};

addThreadReaction = () => {
const { thread, addThreadReaction } = this.props;
const input = { threadId: thread.id };
return addThreadReaction({ input });
};

const removeThreadReaction = () => {
const { thread, removeThreadReaction } = props;
removeThreadReaction = () => {
const { thread, removeThreadReaction } = this.props;
const input = { threadId: thread.id };
return removeThreadReaction({ input });
};

return (
<LikeButtonWrapper hasReacted={hasReacted}>
<IconButton
glyph={hasReacted ? 'thumbsup-fill' : 'thumbsup'}
tipText={hasReacted ? 'Unlike thread' : 'Like thread'}
tipLocation={'bottom-left'}
onClick={
hasReacted ? () => removeThreadReaction() : () => addThreadReaction()
}
/>
<CurrentCount>{count}</CurrentCount>
</LikeButtonWrapper>
);
};
render() {
const { thread } = this.props;
const { hasReacted, count } = thread.reactions;

return (
<LikeButtonWrapper hasReacted={hasReacted}>
<IconButton
glyph={hasReacted ? 'thumbsup-fill' : 'thumbsup'}
tipText={hasReacted ? 'Unlike thread' : 'Like thread'}
tipLocation={'bottom-left'}
onClick={this.handleClick}
/>
<CurrentCount>{count}</CurrentCount>
</LikeButtonWrapper>
);
}
}

const map = state => ({
currentUser: state.users.currentUser,
});
export const LikeButton = compose(
// $FlowFixMe
connect(map),
addThreadReactionMutation,
removeThreadReactionMutation
)(LikeButtonPure);
Expand All @@ -63,7 +84,12 @@ export const LikeCount = (props: LikeCountProps) => {
if (count > 0) {
return (
<LikeCountWrapper active={active}>
<Icon glyph={'thumbsup-fill'} size={24} />
<Icon
glyph={'thumbsup-fill'}
size={24}
tipText={`${count} likes`}
tipLocation={'top-right'}
/>
<CurrentCount>{count}</CurrentCount>
</LikeCountWrapper>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/threadLikes/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ export const LikeButtonWrapper = styled(LikeWrapper)`
}

${CurrentCount} {
margin-left: 4px;
margin-right: 8px;
font-weight: 500;
color: ${props =>
props.hasReacted ? props.theme.text.default : props.theme.text.alt};
}
`;

export const LikeCountWrapper = styled(LikeWrapper)`
margin-right: 8px;
color: ${props =>
props.active ? props.theme.text.reverse : props.theme.text.alt};
`;
Loading