mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-17 13:14:54 +00:00
Bulk Actions
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { reactive } from 'vue';
|
||||
import axios from 'axios';
|
||||
|
||||
let emails = new Set()
|
||||
export const useEmailSelection = function(){
|
||||
@@ -19,6 +20,16 @@ export const useEmailSelection = function(){
|
||||
this.emails.add(email)
|
||||
})
|
||||
},
|
||||
forSelected(fn){
|
||||
this.emails.forEach(email => {
|
||||
fn(email)
|
||||
axios.put(`http://localhost:3000/emails/${email.id}`, email)
|
||||
})
|
||||
},
|
||||
markRead(){ this.forSelected(e => e.read = true )},
|
||||
markUnread(){ this.forSelected(e => e.read = false )},
|
||||
archive(){ this.forSelected(e => e.archived = true); this.clear();},
|
||||
moveToInbox(){ this.forSelected(e => e.archived = false); this.clear();}
|
||||
})
|
||||
|
||||
return { emailSelection }
|
||||
|
||||
Reference in New Issue
Block a user