diff --git a/db.json b/db.json index 3d8859e..2d5002a 100644 --- a/db.json +++ b/db.json @@ -25,7 +25,7 @@ "body": "First of all, lets congratulate Kia King Ishii on joining the Vue.js core team! 🎉 He has been doing an incredible job building vuex-orm and will now focus on working on the next versions of Vuex.\n\nSpeaking of which – Vuex v4.0.0-alpha.1 has just been released! This is the version of Vuex that will work with Vue 3.0 but keep the familiar API you know from the current version.", "sentAt": "2020-03-18T18:25:43.511Z", "archived": false, - "read": false + "read": true }, { "id": 4, @@ -33,7 +33,7 @@ "subject": "'Vue 3 Release Roadmap' + 6 more must-read articles from this week", "body": "Newsletter Issue #161", "sentAt": "2020-03-24T18:25:43.511Z", - "archived": false, + "archived": true, "read": true } ] diff --git a/src/components/MailTable.vue b/src/components/MailTable.vue index 1ac70cc..4069cdd 100644 --- a/src/components/MailTable.vue +++ b/src/components/MailTable.vue @@ -4,7 +4,7 @@ - + @@ -47,13 +49,21 @@ } } - function changeEmail(emails, {amount, toggleArchive, closeModal}){ + function changeEmail(emails, {amount, toggleArchive, closeModal, toggleRead}){ let index = emails.findIndex(e => e == openedEmail.value); if(toggleArchive) { emails[index].archived = !emails[index].archived } + if(toggleRead) { emails[index].read = !emails[index].read } + + if(toggleArchive || toggleRead) { + axios.put(`http://localhost:3000/emails/${emails[index].id}`, emails[index]) + } + if(closeModal) { openedEmail.value = null; return null; } - openEmail(emails[index + amount]) + if(amount) { + openEmail(emails[index + amount]) + } } return {format, emailSelection, openedEmail, openEmail, changeEmail} diff --git a/src/components/MailView.vue b/src/components/MailView.vue index fa13859..b2fc98a 100644 --- a/src/components/MailView.vue +++ b/src/components/MailView.vue @@ -4,7 +4,7 @@ - +

Subject: {{email.subject}}

@@ -25,7 +25,7 @@ let goNewerAndArchive = () => emit('changeEmail', {amount: -1, toggleArchive: true}) let goOlderAndArchive = () => emit('changeEmail', {amount: 1, toggleArchive: true}) let toggleArchive = () => emit('changeEmail', {toggleArchive: true, closeModal: true}) - let toggleRead = (email) => { email.read = !email.read } + let toggleRead = () => { emit('changeEmail', {toggleRead: true}) } useKeydown([ {key: 'k', fn: goNewer},