|
|
@@ -6,11 +6,11 @@ import { withTranslation } from 'react-i18next';
|
|
|
import UserPictureList from './User/UserPictureList';
|
|
|
import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
|
|
|
-import { toastError } from '~/client/util/apiNotification';
|
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
|
-import PageContainer from '~/client/services/PageContainer';
|
|
|
|
|
|
-class LikeButtons extends React.Component {
|
|
|
+// TODO : user image not displayed in search page. Fix it.
|
|
|
+// task : https://estoc.weseek.co.jp/redmine/issues/81110
|
|
|
+class LegacyLikeButtons extends React.Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
@@ -30,28 +30,19 @@ class LikeButtons extends React.Component {
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
- async handleClick() {
|
|
|
- const { appContainer, pageContainer } = this.props;
|
|
|
- const { isGuestUser } = appContainer;
|
|
|
|
|
|
- if (isGuestUser) {
|
|
|
+ handleClick() {
|
|
|
+ if (this.props.onLikeClicked == null) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- try {
|
|
|
- pageContainer.toggleLike();
|
|
|
- }
|
|
|
- catch (err) {
|
|
|
- toastError(err);
|
|
|
- }
|
|
|
+ this.props.onLikeClicked();
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const { appContainer, pageContainer, t } = this.props;
|
|
|
- const { isGuestUser } = appContainer;
|
|
|
const {
|
|
|
- state: { likers, sumOfLikers, isLiked },
|
|
|
- } = pageContainer;
|
|
|
+ appContainer, likerIds, sumOfLikers, isLiked, t,
|
|
|
+ } = this.props;
|
|
|
+ const { isGuestUser } = appContainer;
|
|
|
|
|
|
return (
|
|
|
<div className="btn-group" role="group" aria-label="Like buttons">
|
|
|
@@ -76,7 +67,7 @@ class LikeButtons extends React.Component {
|
|
|
<Popover placement="bottom" isOpen={this.state.isPopoverOpen} target="po-total-likes" toggle={this.togglePopover} trigger="legacy">
|
|
|
<PopoverBody className="seen-user-popover">
|
|
|
<div className="px-2 text-right user-list-content text-truncate text-muted">
|
|
|
- {likers.length ? <UserPictureList users={likers} /> : t('No users have liked this yet.')}
|
|
|
+ {likerIds.length ? <UserPictureList users={likerIds} /> : t('No users have liked this yet.')}
|
|
|
</div>
|
|
|
</PopoverBody>
|
|
|
</Popover>
|
|
|
@@ -89,14 +80,20 @@ class LikeButtons extends React.Component {
|
|
|
/**
|
|
|
* Wrapper component for using unstated
|
|
|
*/
|
|
|
-const LikeButtonsWrapper = withUnstatedContainers(LikeButtons, [AppContainer, PageContainer]);
|
|
|
+const LegacyLikeButtonsWrapper = withUnstatedContainers(LegacyLikeButtons, [AppContainer]);
|
|
|
|
|
|
-LikeButtons.propTypes = {
|
|
|
+LegacyLikeButtons.propTypes = {
|
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
- pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
|
|
|
-
|
|
|
+ onChangeInvoked: PropTypes.func,
|
|
|
+ pageId: PropTypes.string.isRequired,
|
|
|
+ likerIds: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
+ sumOfLikers: PropTypes.number.isRequired,
|
|
|
+ isLiked: PropTypes.bool.isRequired,
|
|
|
+ onLikeClicked: PropTypes.func,
|
|
|
t: PropTypes.func.isRequired,
|
|
|
- size: PropTypes.string,
|
|
|
+};
|
|
|
+const LikeButtons = (props) => {
|
|
|
+ return <LegacyLikeButtonsWrapper {...props}></LegacyLikeButtonsWrapper>;
|
|
|
};
|
|
|
|
|
|
-export default withTranslation()(LikeButtonsWrapper);
|
|
|
+export default withTranslation()(LikeButtons);
|