From 85eb0d946376065abad616af0c4a7a901ff64d92 Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 20 Feb 2018 14:08:54 +0100 Subject: [PATCH] Send request on the server to mark a notification as seen. --- .../js/components/notifications/interface.js | 20 +++++++++++++++++++ assets/js/components/notifications/ui.js | 5 +++++ 2 files changed, 25 insertions(+) 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); }