fix: removing media should reset sensitive status (#1497)

fixes #1495
This commit is contained in:
Nolan Lawson 2019-09-17 00:19:59 -07:00 committed by GitHub
parent 08992f836a
commit 3e303a444d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 1 deletions

View file

@ -38,5 +38,12 @@ export function deleteMedia (realm, i) {
store.setComposeData(realm, {
media: composeMedia
})
if (!composeMedia.length) {
const contentWarningShown = store.getComposeData(realm, 'contentWarningShown')
const contentWarning = store.getComposeData(realm, 'contentWarning')
store.setComposeData(realm, {
sensitive: contentWarningShown && contentWarning // reset sensitive if the last media is deleted
})
}
scheduleIdleTask(() => store.save())
}

View file

@ -1,5 +1,6 @@
import {
composeInput,
composeContentWarning,
composeInput, composeMediaSensitiveCheckbox, contentWarningButton,
getNthDeleteMediaButton,
getNthMedia,
getNthMediaAltInput,
@ -126,3 +127,32 @@ test('keeps media in local storage', async t => {
.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
})
test('resets sensitive settings when deleting media', async t => {
await loginAsFoobar(t)
await t
.expect(mediaButton.exists).ok()
await (uploadKittenImage(1)())
await t
.click(composeMediaSensitiveCheckbox)
.expect(composeMediaSensitiveCheckbox.checked).ok()
await (uploadKittenImage(2)())
await t
.expect(composeMediaSensitiveCheckbox.checked).ok()
.click(getNthDeleteMediaButton(2))
.expect(getNthMedia(2).exists).notOk()
.expect(composeMediaSensitiveCheckbox.checked).ok()
.click(getNthDeleteMediaButton(1))
.expect(getNthMedia(1).exists).notOk()
await (uploadKittenImage(1)())
await t
.expect(composeMediaSensitiveCheckbox.checked).notOk()
.click(contentWarningButton)
.typeText(composeContentWarning, 'warn warn warn', { paste: true })
.expect(composeMediaSensitiveCheckbox.checked).ok()
.click(getNthDeleteMediaButton(1))
.expect(getNthMedia(1).exists).notOk()
await (uploadKittenImage(1)())
await t
.expect(composeMediaSensitiveCheckbox.checked).ok()
})