From 7ba385236a3046e576af50d5a681b5cb6cb36945 Mon Sep 17 00:00:00 2001 From: noellabo Date: Mon, 28 Sep 2020 12:09:22 +0900 Subject: [PATCH] Add quote and bookmark button in PiP --- .../picture_in_picture/components/footer.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/features/picture_in_picture/components/footer.js b/app/javascript/mastodon/features/picture_in_picture/components/footer.js index 1d78c741a..0052f3826 100644 --- a/app/javascript/mastodon/features/picture_in_picture/components/footer.js +++ b/app/javascript/mastodon/features/picture_in_picture/components/footer.js @@ -5,10 +5,10 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import IconButton from 'mastodon/components/icon_button'; import classNames from 'classnames'; -import { me, boostModal } from 'mastodon/initial_state'; +import { me, boostModal, show_quote_button } from 'mastodon/initial_state'; import { defineMessages, injectIntl } from 'react-intl'; import { replyCompose, quoteCompose } from 'mastodon/actions/compose'; -import { reblog, favourite, unreblog, unfavourite } from 'mastodon/actions/interactions'; +import { reblog, favourite, bookmark, unreblog, unfavourite, unbookmark } from 'mastodon/actions/interactions'; import { makeGetStatus } from 'mastodon/selectors'; import { initBoostModal } from 'mastodon/actions/boosts'; import { openModal } from 'mastodon/actions/modal'; @@ -23,6 +23,7 @@ const messages = defineMessages({ cannot_quote: { id: 'status.cannot_quote', defaultMessage: 'This post cannot be quoted' }, quote: { id: 'status.quote', defaultMessage: 'Quote' }, favourite: { id: 'status.favourite', defaultMessage: 'Favourite' }, + bookmark: { id: 'status.bookmark', defaultMessage: 'Bookmark' }, replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' }, replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' }, quoteConfirm: { id: 'confirmations.quote.confirm', defaultMessage: 'Quote' }, @@ -127,6 +128,16 @@ class Footer extends ImmutablePureComponent { router.history.push(`/statuses/${status.get('id')}`); } + handleBookmarkClick = () => { + const { dispatch, status } = this.props; + + if (status.get('bookmarked')) { + dispatch(unbookmark(status)); + } else { + dispatch(bookmark(status)); + } + } + _performQuote = () => { const { dispatch, status, onClose } = this.props; const { router } = this.context; @@ -158,6 +169,10 @@ class Footer extends ImmutablePureComponent { const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); const reblogPrivate = status.getIn(['account', 'id']) === me && status.get('visibility') === 'private'; + const expires_at = status.get('expires_at') + const expires_date = expires_at && new Date(expires_at) + const expired = expires_date && expires_date.getTime() < intl.now() + let replyIcon, replyTitle; if (status.get('in_reply_to_id', null) === null) { @@ -185,7 +200,8 @@ class Footer extends ImmutablePureComponent { - + {show_quote_button && } + {withOpenButton && } );