fix: Add "unfavorite/unboost" label (#1540)
* Add "unfavorite" label. * fixup, also fix Boost/Unboost * fix test
This commit is contained in:
parent
038dc27163
commit
5e150b31df
|
@ -19,7 +19,7 @@
|
||||||
ref:reblogIcon
|
ref:reblogIcon
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
label="Favorite"
|
label={favoriteLabel}
|
||||||
pressable="true"
|
pressable="true"
|
||||||
pressed={favorited}
|
pressed={favorited}
|
||||||
href="#fa-star"
|
href="#fa-star"
|
||||||
|
@ -164,14 +164,14 @@
|
||||||
replyShown ? 'Close reply' : inReplyToId ? 'Reply to thread' : 'Reply'
|
replyShown ? 'Close reply' : inReplyToId ? 'Reply to thread' : 'Reply'
|
||||||
),
|
),
|
||||||
replyIcon: ({ inReplyToId }) => inReplyToId ? '#fa-reply-all' : '#fa-reply',
|
replyIcon: ({ inReplyToId }) => inReplyToId ? '#fa-reply-all' : '#fa-reply',
|
||||||
reblogLabel: ({ visibility }) => {
|
reblogLabel: ({ visibility, reblogged }) => {
|
||||||
switch (visibility) {
|
switch (visibility) {
|
||||||
case 'private':
|
case 'private':
|
||||||
return 'Cannot be boosted because this is followers-only'
|
return 'Cannot be boosted because this is followers-only'
|
||||||
case 'direct':
|
case 'direct':
|
||||||
return 'Cannot be boosted because this is a direct message'
|
return 'Cannot be boosted because this is a direct message'
|
||||||
default:
|
default:
|
||||||
return 'Boost'
|
return reblogged ? 'Unboost' : 'Boost'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reblogIcon: ({ visibility }) => {
|
reblogIcon: ({ visibility }) => {
|
||||||
|
@ -193,6 +193,9 @@
|
||||||
}
|
}
|
||||||
return originalStatus.reblogged
|
return originalStatus.reblogged
|
||||||
},
|
},
|
||||||
|
favoriteLabel: ({ favorited }) => (
|
||||||
|
favorited ? 'Unfavorite' : 'Favorite'
|
||||||
|
),
|
||||||
favorited: ({ originalStatusId, $currentStatusModifications, originalStatus }) => {
|
favorited: ({ originalStatusId, $currentStatusModifications, originalStatus }) => {
|
||||||
if ($currentStatusModifications && originalStatusId in $currentStatusModifications.favorites) {
|
if ($currentStatusModifications && originalStatusId in $currentStatusModifications.favorites) {
|
||||||
return $currentStatusModifications.favorites[originalStatusId]
|
return $currentStatusModifications.favorites[originalStatusId]
|
||||||
|
|
|
@ -15,7 +15,7 @@ test('shows favorites', async t => {
|
||||||
.expect(getUrl()).contains('/statuses/')
|
.expect(getUrl()).contains('/statuses/')
|
||||||
.expect(getFavoritesCount()).eql(2)
|
.expect(getFavoritesCount()).eql(2)
|
||||||
.expect(favoritesCountElement.getAttribute('aria-label')).eql('Favorited 2 times')
|
.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)
|
.click(favoritesCountElement)
|
||||||
.expect(getUrl()).match(/\/statuses\/[^/]+\/favorites/)
|
.expect(getUrl()).match(/\/statuses\/[^/]+\/favorites/)
|
||||||
.expect($('.search-result-account-name').nth(0).innerText).eql('foobar')
|
.expect($('.search-result-account-name').nth(0).innerText).eql('foobar')
|
||||||
|
|
Loading…
Reference in a new issue