fix: fix notification m/p keyboard shortcuts (#907)

fixes #905
This commit is contained in:
Nolan Lawson 2019-01-19 23:52:39 -08:00 committed by GitHub
parent c1f6c1582d
commit 74ab056f18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 4 deletions

View file

@ -203,12 +203,12 @@
goto(`/statuses/${originalStatusId}`) goto(`/statuses/${originalStatusId}`)
}, },
openAuthorProfile () { openAuthorProfile () {
let { originalAccountId } = this.get() let { accountForShortcut } = this.get()
goto(`/accounts/${originalAccountId}`) goto(`/accounts/${accountForShortcut.id}`)
}, },
async mentionAuthor () { async mentionAuthor () {
let { originalAccount } = this.get() let { accountForShortcut } = this.get()
await composeNewStatusMentioning(originalAccount) await composeNewStatusMentioning(accountForShortcut)
} }
}, },
computed: { computed: {
@ -222,6 +222,7 @@
accountId: ({ account }) => account.id, accountId: ({ account }) => account.id,
originalAccount: ({ originalStatus }) => originalStatus.account, originalAccount: ({ originalStatus }) => originalStatus.account,
originalAccountId: ({ originalAccount }) => originalAccount.id, originalAccountId: ({ originalAccount }) => originalAccount.id,
accountForShortcut: ({ originalAccount, notification }) => notification ? notification.account : originalAccount,
visibility: ({ originalStatus }) => originalStatus.visibility, visibility: ({ originalStatus }) => originalStatus.visibility,
plainTextContent: ({ content }) => htmlToPlainText(content), plainTextContent: ({ content }) => htmlToPlainText(content),
plainTextContentLength: ({ plainTextContent }) => measureText(plainTextContent), plainTextContentLength: ({ plainTextContent }) => measureText(plainTextContent),

View file

@ -56,3 +56,33 @@ test('Shortcut m toggles mention in a follow notification', async t => {
.click(closeDialogButton) .click(closeDialogButton)
.expect(modalDialog.exists).notOk() .expect(modalDialog.exists).notOk()
}) })
test('Shortcut p refers to booster in a boost notification', async t => {
let idx = 1 // "@admin boosted your status"
await loginAsFoobar(t)
await t
.expect(getUrl()).eql('http://localhost:4002/')
.click(notificationsNavButton)
.expect(getUrl()).contains('/notifications')
.expect(getNthStatus(0).exists).ok({ timeout: 30000 })
.pressKey('j '.repeat(idx + 1))
.expect(getNthStatus(idx).hasClass('status-active')).ok()
.pressKey('p')
.expect(getUrl()).contains('/accounts/1')
})
test('Shortcut m refers to favoriter in a favorite notification', async t => {
let idx = 0 // "@admin favorited your status"
await loginAsFoobar(t)
await t
.expect(getUrl()).eql('http://localhost:4002/')
.click(notificationsNavButton)
.expect(getUrl()).contains('/notifications')
.expect(getNthStatus(0).exists).ok({ timeout: 30000 })
.pressKey('j '.repeat(idx + 1))
.expect(getNthStatus(idx).hasClass('status-active')).ok()
.pressKey('m')
.expect(composeModalInput.value).eql('@admin ')
.click(closeDialogButton)
.expect(modalDialog.exists).notOk()
})