diff --git a/assets/js/components/notifications/dropdown.js b/assets/js/components/notifications/dropdown.js index 06621545..667632f2 100644 --- a/assets/js/components/notifications/dropdown.js +++ b/assets/js/components/notifications/dropdown.js @@ -82,9 +82,18 @@ ComunicWeb.components.notifications.dropdown = { * * @param {HTMLElement} list The notifications list to refresh */ - refresh: function(list){ + refresh_list: function(list){ - //Perform a request on the database + //Perform a request on the API + ComunicWeb.components.notifications.interface.get_list_unread(function(result){ + + //Check for errors + if(result.error){ + ComunicWeb.common.notificationSystem.showNotification("An error occured while trying to retrieve notifications list !", "danger"); + return; + } + + }); }, } \ No newline at end of file diff --git a/assets/js/components/notifications/interface.js b/assets/js/components/notifications/interface.js index a4437b68..822db3b8 100644 --- a/assets/js/components/notifications/interface.js +++ b/assets/js/components/notifications/interface.js @@ -20,6 +20,22 @@ ComunicWeb.components.notifications.interface = { //Perform the request ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); - } + }, + + /** + * Get the list of unread notifications + * + * @param {function} callback + */ + get_list_unread: function(callback){ + + //Perform API request + var apiURI = "notifications/get_list_unread"; + var params = {}; + + //Perform the request + ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); + + }, } \ No newline at end of file