Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 56e4245

Browse files
authored
Merge pull request #3406 from withspectrum/2.4.15
2.4.15
2 parents 97c99ba + 954d778 commit 56e4245

File tree

15 files changed

+484
-300
lines changed

15 files changed

+484
-300
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Spectrum",
3-
"version": "2.4.14",
3+
"version": "2.4.15",
44
"license": "BSD-3-Clause",
55
"devDependencies": {
66
"babel-cli": "^6.24.1",

src/components/chatInput/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class ChatInput extends React.Component<Props, State> {
257257
// decorators that are passed to the editor are removed from the editor
258258
// state
259259
setTimeout(() => {
260-
this.editor && this.editor.focus();
260+
this.editor && this.editor.focus && this.editor.focus();
261261
}, 0);
262262
};
263263

@@ -400,7 +400,7 @@ class ChatInput extends React.Component<Props, State> {
400400
// refocus the input
401401
setTimeout(() => {
402402
clear();
403-
this.editor && this.editor.focus();
403+
this.editor && this.editor.focus && this.editor.focus();
404404
});
405405

406406
return 'handled';

src/components/chatInput/input.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Props = {
3333
networkDisabled: boolean,
3434
children?: React$Node,
3535
hasAttachment?: boolean,
36+
code?: boolean,
3637
};
3738

3839
type State = {
@@ -88,6 +89,7 @@ class Input extends React.Component<Props, State> {
8889
networkDisabled,
8990
children,
9091
hasAttachment,
92+
code,
9193
...rest
9294
} = this.props;
9395
const { plugins } = this.state;

src/components/draft-js-plugins-editor/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,20 @@ class AndroidFallbackInput extends React.Component<Props, FallbackState> {
6060
};
6161

6262
render() {
63+
const {
64+
editorState,
65+
editorRef,
66+
stripPastedStyles,
67+
customStyleMap,
68+
handleReturn,
69+
editorKey,
70+
...rest
71+
} = this.props;
6372
return (
6473
<div className="DraftEditor-root">
6574
<div className="DraftEditor-editorContainer">
6675
<Textarea
67-
{...this.props}
76+
{...rest}
6877
value={this.state.value}
6978
onChange={this.onChange}
7079
className={'DraftEditor-content ' + (this.props.className || '')}

src/components/icons/index.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/threadLikes/index.js

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// @flow
2-
import React from 'react';
2+
import * as React from 'react';
3+
import { connect } from 'react-redux';
4+
import type { Dispatch } from 'redux';
35
import compose from 'recompose/compose';
46
import type { GetThreadType } from 'shared/graphql/queries/thread/getThread';
57
import addThreadReactionMutation from 'shared/graphql/mutations/thread/addThreadReaction';
68
import removeThreadReactionMutation from 'shared/graphql/mutations/thread/removeThreadReaction';
9+
import { openModal } from 'src/actions/modals';
710

811
import { IconButton } from 'src/components/buttons';
912
import Icon from 'src/components/icons';
@@ -13,40 +16,58 @@ type LikeButtonProps = {
1316
thread: GetThreadType,
1417
addThreadReaction: Function,
1518
removeThreadReaction: Function,
19+
currentUser: ?Object,
20+
dispatch: Dispatch<Object>,
1621
};
1722

18-
const LikeButtonPure = (props: LikeButtonProps) => {
19-
const { thread } = props;
20-
const { hasReacted, count } = thread.reactions;
23+
class LikeButtonPure extends React.Component<LikeButtonProps> {
24+
handleClick = () => {
25+
const { thread, dispatch, currentUser } = this.props;
2126

22-
const addThreadReaction = () => {
23-
const { thread, addThreadReaction } = props;
27+
if (!currentUser || !currentUser.id) {
28+
return dispatch(openModal('CHAT_INPUT_LOGIN_MODAL', {}));
29+
}
30+
31+
const { hasReacted } = thread.reactions;
32+
return hasReacted ? this.removeThreadReaction() : this.addThreadReaction();
33+
};
34+
35+
addThreadReaction = () => {
36+
const { thread, addThreadReaction } = this.props;
2437
const input = { threadId: thread.id };
2538
return addThreadReaction({ input });
2639
};
2740

28-
const removeThreadReaction = () => {
29-
const { thread, removeThreadReaction } = props;
41+
removeThreadReaction = () => {
42+
const { thread, removeThreadReaction } = this.props;
3043
const input = { threadId: thread.id };
3144
return removeThreadReaction({ input });
3245
};
3346

34-
return (
35-
<LikeButtonWrapper hasReacted={hasReacted}>
36-
<IconButton
37-
glyph={hasReacted ? 'thumbsup-fill' : 'thumbsup'}
38-
tipText={hasReacted ? 'Unlike thread' : 'Like thread'}
39-
tipLocation={'bottom-left'}
40-
onClick={
41-
hasReacted ? () => removeThreadReaction() : () => addThreadReaction()
42-
}
43-
/>
44-
<CurrentCount>{count}</CurrentCount>
45-
</LikeButtonWrapper>
46-
);
47-
};
47+
render() {
48+
const { thread } = this.props;
49+
const { hasReacted, count } = thread.reactions;
50+
51+
return (
52+
<LikeButtonWrapper hasReacted={hasReacted}>
53+
<IconButton
54+
glyph={hasReacted ? 'thumbsup-fill' : 'thumbsup'}
55+
tipText={hasReacted ? 'Unlike thread' : 'Like thread'}
56+
tipLocation={'bottom-left'}
57+
onClick={this.handleClick}
58+
/>
59+
<CurrentCount>{count}</CurrentCount>
60+
</LikeButtonWrapper>
61+
);
62+
}
63+
}
4864

65+
const map = state => ({
66+
currentUser: state.users.currentUser,
67+
});
4968
export const LikeButton = compose(
69+
// $FlowFixMe
70+
connect(map),
5071
addThreadReactionMutation,
5172
removeThreadReactionMutation
5273
)(LikeButtonPure);
@@ -63,7 +84,12 @@ export const LikeCount = (props: LikeCountProps) => {
6384
if (count > 0) {
6485
return (
6586
<LikeCountWrapper active={active}>
66-
<Icon glyph={'thumbsup-fill'} size={24} />
87+
<Icon
88+
glyph={'thumbsup-fill'}
89+
size={24}
90+
tipText={`${count} likes`}
91+
tipLocation={'top-right'}
92+
/>
6793
<CurrentCount>{count}</CurrentCount>
6894
</LikeCountWrapper>
6995
);

src/components/threadLikes/style.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ export const LikeButtonWrapper = styled(LikeWrapper)`
2929
}
3030
3131
${CurrentCount} {
32-
margin-left: 4px;
32+
margin-right: 8px;
3333
font-weight: 500;
3434
color: ${props =>
3535
props.hasReacted ? props.theme.text.default : props.theme.text.alt};
3636
}
3737
`;
3838

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

0 commit comments

Comments
 (0)