fix: Add "unfavorite/unboost" label (#1540)

* Add "unfavorite" label.

* fixup, also fix Boost/Unboost

* fix test
This commit is contained in:
Alex Berg 2019-09-26 07:24:05 -05:00 committed by Nolan Lawson
parent 038dc27163
commit 5e150b31df
2 changed files with 7 additions and 4 deletions

View File

@ -19,7 +19,7 @@
ref:reblogIcon
/>
<IconButton
label="Favorite"
label={favoriteLabel}
pressable="true"
pressed={favorited}
href="#fa-star"
@ -164,14 +164,14 @@
replyShown ? 'Close reply' : inReplyToId ? 'Reply to thread' : 'Reply'
),
replyIcon: ({ inReplyToId }) => inReplyToId ? '#fa-reply-all' : '#fa-reply',
reblogLabel: ({ visibility }) => {
reblogLabel: ({ visibility, reblogged }) => {
switch (visibility) {
case 'private':
return 'Cannot be boosted because this is followers-only'
case 'direct':
return 'Cannot be boosted because this is a direct message'
default:
return 'Boost'
return reblogged ? 'Unboost' : 'Boost'
}
},
reblogIcon: ({ visibility }) => {
@ -193,6 +193,9 @@
}
return originalStatus.reblogged
},
favoriteLabel: ({ favorited }) => (
favorited ? 'Unfavorite' : 'Favorite'
),
favorited: ({ originalStatusId, $currentStatusModifications, originalStatus }) => {
if ($currentStatusModifications && originalStatusId in $currentStatusModifications.favorites) {
return $currentStatusModifications.favorites[originalStatusId]

View File

@ -15,7 +15,7 @@ test('shows favorites', async t => {
.expect(getUrl()).contains('/statuses/')
.expect(getFavoritesCount()).eql(2)
.expect(favoritesCountElement.getAttribute('aria-label')).eql('Favorited 2 times')
.expect($('.icon-button[aria-label="Favorite"]').getAttribute('aria-pressed')).eql('true')
.expect($('.icon-button[aria-label="Unfavorite"]').getAttribute('aria-pressed')).eql('true')
.click(favoritesCountElement)
.expect(getUrl()).match(/\/statuses\/[^/]+\/favorites/)
.expect($('.search-result-account-name').nth(0).innerText).eql('foobar')