fix: fix polls with content warnings (#1768)
* fix: fix polls with content warnings fixes #1766 * fixup
This commit is contained in:
parent
a4820a2792
commit
dacd9dcc5b
|
@ -21,7 +21,7 @@
|
||||||
{#if !showContent}
|
{#if !showContent}
|
||||||
<StatusMentions {...params} />
|
<StatusMentions {...params} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if content && (showContent || contentPreloaded)}
|
{#if content && (showContent || preloadHiddenContent)}
|
||||||
<StatusContent {...params} shown={showContent}/>
|
<StatusContent {...params} shown={showContent}/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if showCard }
|
{#if showCard }
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
{#if showMedia }
|
{#if showMedia }
|
||||||
<StatusMediaAttachments {...params} on:recalculateHeight />
|
<StatusMediaAttachments {...params} on:recalculateHeight />
|
||||||
{/if}
|
{/if}
|
||||||
{#if showPoll}
|
{#if showPoll && (showContent || preloadHiddenContent)}
|
||||||
<StatusPoll {...params} />
|
<StatusPoll {...params} shown={showContent} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if isStatusInOwnThread}
|
{#if isStatusInOwnThread}
|
||||||
<StatusDetails {...params} {...timestampParams} />
|
<StatusDetails {...params} {...timestampParams} />
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
scheduleIdleTask(() => {
|
scheduleIdleTask(() => {
|
||||||
// Perf optimization: lazily load the StatusContent when the user is idle so that
|
// Perf optimization: lazily load the StatusContent when the user is idle so that
|
||||||
// it's fast when they click the "show more" button
|
// it's fast when they click the "show more" button
|
||||||
this.set({ contentPreloaded: true })
|
this.set({ preloadHiddenContent: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
data: () => ({
|
data: () => ({
|
||||||
notification: undefined,
|
notification: undefined,
|
||||||
replyVisibility: undefined,
|
replyVisibility: undefined,
|
||||||
contentPreloaded: false,
|
preloadHiddenContent: false,
|
||||||
enableShortcuts: null
|
enableShortcuts: null
|
||||||
}),
|
}),
|
||||||
store: () => store,
|
store: () => store,
|
||||||
|
|
|
@ -65,6 +65,11 @@
|
||||||
border: 1px solid var(--main-border);
|
border: 1px solid var(--main-border);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
transition: opacity 0.2s linear;
|
transition: opacity 0.2s linear;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.poll.shown {
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.poll.status-in-own-thread {
|
.poll.status-in-own-thread {
|
||||||
|
@ -309,12 +314,13 @@
|
||||||
),
|
),
|
||||||
formDisabled: ({ choices }) => !choices.length,
|
formDisabled: ({ choices }) => !choices.length,
|
||||||
votesText: ({ votesCount }) => `${votesCount} ${votesCount === 1 ? 'vote' : 'votes'}`,
|
votesText: ({ votesCount }) => `${votesCount} ${votesCount === 1 ? 'vote' : 'votes'}`,
|
||||||
computedClass: ({ isStatusInNotification, isStatusInOwnThread, loading }) => (
|
computedClass: ({ isStatusInNotification, isStatusInOwnThread, loading, shown }) => (
|
||||||
classname(
|
classname(
|
||||||
'poll',
|
'poll',
|
||||||
isStatusInNotification && 'status-in-notification',
|
isStatusInNotification && 'status-in-notification',
|
||||||
isStatusInOwnThread && 'status-in-own-thread',
|
isStatusInOwnThread && 'status-in-own-thread',
|
||||||
loading && 'poll-loading'
|
loading && 'poll-loading',
|
||||||
|
shown && 'shown'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
@ -71,8 +71,8 @@ export async function updateUserDisplayNameAs (username, displayName) {
|
||||||
return updateCredentials(instanceName, users[username].accessToken, { display_name: displayName })
|
return updateCredentials(instanceName, users[username].accessToken, { display_name: displayName })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createPollAs (username, content, options, multiple) {
|
export async function createPollAs (username, content, options, multiple, spoilerText) {
|
||||||
return postStatus(instanceName, users[username].accessToken, content, null, null, false, null, 'public', {
|
return postStatus(instanceName, users[username].accessToken, content, null, null, false, spoilerText, 'public', {
|
||||||
options,
|
options,
|
||||||
multiple,
|
multiple,
|
||||||
expires_in: POLL_EXPIRY_DEFAULT
|
expires_in: POLL_EXPIRY_DEFAULT
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
sleep,
|
sleep,
|
||||||
getNthStatusPollRefreshButton,
|
getNthStatusPollRefreshButton,
|
||||||
getNthStatusPollVoteCount,
|
getNthStatusPollVoteCount,
|
||||||
getNthStatusRelativeDate, getUrl, goBack
|
getNthStatusRelativeDate, getUrl, goBack, getNthStatusSpoiler, getNthShowOrHideButton
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { loginAsFoobar } from '../roles'
|
import { loginAsFoobar } from '../roles'
|
||||||
import { createPollAs, voteOnPollAs } from '../serverActions'
|
import { createPollAs, voteOnPollAs } from '../serverActions'
|
||||||
|
@ -105,3 +105,19 @@ test('Poll results refresh everywhere', async t => {
|
||||||
.expect(getNthStatusPollResult(1, 2).innerText).eql('0% no')
|
.expect(getNthStatusPollResult(1, 2).innerText).eql('0% no')
|
||||||
.expect(getNthStatusPollVoteCount(1).innerText).eql('1 vote')
|
.expect(getNthStatusPollVoteCount(1).innerText).eql('1 vote')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Polls with content warnings', async t => {
|
||||||
|
await createPollAs('admin', 'hidden poll!', ['oui', 'non'], false, 'this poll is hidden')
|
||||||
|
await sleep(2000)
|
||||||
|
await loginAsFoobar(t)
|
||||||
|
await t
|
||||||
|
.expect(getNthStatusSpoiler(1).innerText).contains('this poll is hidden')
|
||||||
|
.expect(getNthStatusPollForm(1).visible).notOk()
|
||||||
|
.expect(getNthStatusContent(1).visible).notOk()
|
||||||
|
.click(getNthShowOrHideButton(1))
|
||||||
|
.expect(getNthStatusPollForm(1).visible).ok()
|
||||||
|
.expect(getNthStatusContent(1).visible).ok()
|
||||||
|
.click(getNthShowOrHideButton(1))
|
||||||
|
.expect(getNthStatusPollForm(1).visible).notOk()
|
||||||
|
.expect(getNthStatusContent(1).visible).notOk()
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue