Send request on the server to mark a notification as seen.

This commit is contained in:
Pierre 2018-02-20 14:08:54 +01:00
parent 53de79040a
commit 85eb0d9463
2 changed files with 25 additions and 0 deletions

View File

@ -38,4 +38,24 @@ ComunicWeb.components.notifications.interface = {
}, },
/**
* Mark a notification as seen
*
* @param {number} id The ID of the notification to mark as seen
* @param {boolean} delete_similar Specify if the similar notifications
* associated to the user have to be delete too
* @param {function} callback (Optionnal)
*/
mark_seen: function(id, delete_similar, callback){
//Perform an API request
var apiURI = "notifications/mark_seen";
var params = {
notifID: id,
delete_similar: delete_similar
};
ComunicWeb.common.api.makeAPIrequest(apiURI, params, false, callback);
},
} }

View File

@ -53,8 +53,13 @@ ComunicWeb.components.notifications.ui = {
//Create notification action //Create notification action
var action = function(){ var action = function(){
//Mark the notification as seen
ComunicWeb.components.notifications.interface.mark_seen(data.id, true);
//Process specific action
if(data.on_elem_type = "post"){ if(data.on_elem_type = "post"){
//Open associated post page
openPage("post/" + data.on_elem_id); openPage("post/" + data.on_elem_id);
} }