From 307aab820a03d1b226bd7d58e98dfa44d5fe7783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 5 Sep 2018 12:04:23 +0200 Subject: [PATCH 1/2] MOBILE-2567 notifications: Add spiner on notifications mark all as read --- src/addon/notifications/pages/list/list.html | 5 ++- src/addon/notifications/pages/list/list.ts | 36 +++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/addon/notifications/pages/list/list.html b/src/addon/notifications/pages/list/list.html index c75a3d715..05d17c75d 100644 --- a/src/addon/notifications/pages/list/list.html +++ b/src/addon/notifications/pages/list/list.html @@ -9,10 +9,13 @@
- +
diff --git a/src/addon/notifications/pages/list/list.ts b/src/addon/notifications/pages/list/list.ts index 9031abdc0..241a54e09 100644 --- a/src/addon/notifications/pages/list/list.ts +++ b/src/addon/notifications/pages/list/list.ts @@ -37,6 +37,7 @@ export class AddonNotificationsListPage { notificationsLoaded = false; canLoadMore = false; canMarkAllNotificationsAsRead = false; + loadingMarkAllNotificationsAsRead = false; protected readCount = 0; protected unreadCount = 0; @@ -118,15 +119,6 @@ export class AddonNotificationsListPage { this.canLoadMore = true; } - // Check if mark all notifications as read is enabled and there are some to read. - if (this.notificationsProvider.isMarkAllNotificationsAsReadEnabled()) { - promises.push(this.notificationsProvider.getUnreadNotificationsCount().then((unread) => { - this.canMarkAllNotificationsAsRead = unread > 0; - })); - } else { - this.canMarkAllNotificationsAsRead = false; - } - return Promise.all(promises).then(() => { // Mark retrieved notifications as read if they are not. this.markNotificationsAsRead(unread); @@ -141,15 +133,17 @@ export class AddonNotificationsListPage { * Mark all notifications as read. */ markAllNotificationsAsRead(): void { - this.notificationsProvider.markAllNotificationsAsRead().then(() => { + this.loadingMarkAllNotificationsAsRead = true; + this.notificationsProvider.markAllNotificationsAsRead().catch(() => { + // Omit failure. + }).finally(() => { const siteId = this.sitesProvider.getCurrentSiteId(); this.eventsProvider.trigger(AddonNotificationsProvider.READ_CHANGED_EVENT, null, siteId); this.notificationsProvider.getUnreadNotificationsCount().then((unread) => { this.canMarkAllNotificationsAsRead = unread > 0; + this.loadingMarkAllNotificationsAsRead = false; }); - }).catch(() => { - // Omit failure. }); } @@ -159,12 +153,14 @@ export class AddonNotificationsListPage { * @param {any[]} notifications Array of notification objects. */ protected markNotificationsAsRead(notifications: any[]): void { + let promise; + if (notifications.length > 0) { const promises = notifications.map((notification) => { return this.notificationsProvider.markNotificationRead(notification.id); }); - Promise.all(promises).catch(() => { + promise = Promise.all(promises).catch(() => { // Ignore errors. }).finally(() => { this.notificationsProvider.invalidateNotificationsList().finally(() => { @@ -172,7 +168,21 @@ export class AddonNotificationsListPage { this.eventsProvider.trigger(AddonNotificationsProvider.READ_CHANGED_EVENT, null, siteId); }); }); + } else { + promise = Promise.resolve(); } + + promise.finally(() => { + // Check if mark all notifications as read is enabled and there are some to read. + if (this.notificationsProvider.isMarkAllNotificationsAsReadEnabled()) { + this.loadingMarkAllNotificationsAsRead = true; + return this.notificationsProvider.getUnreadNotificationsCount().then((unread) => { + this.canMarkAllNotificationsAsRead = unread > 0; + this.loadingMarkAllNotificationsAsRead = false; + }); + } + this.canMarkAllNotificationsAsRead = false; + }); } /** From 67a1ce676e06c950dcf89cdafcedbeefcc3d8eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 6 Sep 2018 09:28:55 +0200 Subject: [PATCH 2/2] MOBILE-2567 assignment: Add text wrap to some buttons to fit large text --- .../submission/addon-mod-assign-submission.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html b/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html index f8d03552a..61c013a05 100644 --- a/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html +++ b/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html @@ -70,16 +70,16 @@

{{ 'addon.mod_assign.erroreditpluginsnotsupported' | translate }}

@@ -99,7 +99,7 @@ - {{ 'addon.mod_assign.submitassignment' | translate }} + {{ 'addon.mod_assign.submitassignment' | translate }}

{{ 'addon.mod_assign.submitassignment_help' | translate }}