diff --git a/assets/js/components/notifications/interface.js b/assets/js/components/notifications/interface.js index 822db3b8..3d6f7d6f 100644 --- a/assets/js/components/notifications/interface.js +++ b/assets/js/components/notifications/interface.js @@ -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); + + }, } \ No newline at end of file diff --git a/assets/js/components/notifications/ui.js b/assets/js/components/notifications/ui.js index 7c802351..7d346d79 100644 --- a/assets/js/components/notifications/ui.js +++ b/assets/js/components/notifications/ui.js @@ -53,8 +53,13 @@ ComunicWeb.components.notifications.ui = { //Create notification action 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"){ + //Open associated post page openPage("post/" + data.on_elem_id); }