*
* @param {Number} contextId
* @param {Array} notificationList
+ * @param {Boolean} userLoggedIn
*/
-export const init = (contextId, notificationList) => {
+export const init = (contextId, notificationList, userLoggedIn) => {
currentContextId = contextId;
// Setup the message target region if it isn't setup already
// Add provided notifications.
addNotifications(notificationList);
- // Perform an initial poll for any new notifications.
- fetchNotifications();
+ // If the user is not logged in then we can not fetch anything for them.
+ if (userLoggedIn) {
+ // Perform an initial poll for any new notifications.
+ fetchNotifications();
+ }
};
// To maintain backwards compatability we export default here.
if (!empty($this->page->context->id)) {
$this->page->requires->js_call_amd('core/notification', 'init', array(
$this->page->context->id,
- \core\notification::fetch_as_array($this)
+ \core\notification::fetch_as_array($this),
+ isloggedin()
));
}
$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);