Move up and down with j and k

This commit is contained in:
Jeffrey Biles
2020-03-18 17:29:21 -07:00
parent f1f0a502b2
commit a6320cebce
2 changed files with 18 additions and 4 deletions

View File

@@ -21,7 +21,7 @@
<portal target="#modal-portal">
<ModalView v-if="!!openedEmail" :closeModal="() => {openedEmail = null;}">
<MailView :email="openedEmail" />
<MailView :email="openedEmail" @changeEmail="changeEmail" />
</ModalView>
</portal>
</table>
@@ -41,10 +41,17 @@
let openEmail = function(email) {
openedEmail.value = email;
openedEmail.value.read = true;
if(email) {
openedEmail.value.read = true;
}
}
return {format, emailSelection, openedEmail, openEmail}
let changeEmail = function({amount}){
let index = emails.findIndex(e => e == openedEmail.value);
openEmail(emails[index + amount])
}
return {format, emailSelection, openedEmail, openEmail, changeEmail}
},
props: {
emails: {

View File

@@ -8,8 +8,15 @@
<script>
import marked from 'marked';
import { useKeydown } from '../composition/useKeydown';
export default {
setup({email}) {
setup({email}, {emit}) {
useKeydown([
{key: 'k', fn: () => emit('changeEmail', {amount: -1})},
{key: 'j', fn: () => emit('changeEmail', {amount: 1})}
])
let emailMarkdown = marked(email.body);
return {
emailMarkdown