From a3d88eba4e3bd25b66d859b97b8e8442a51a03be Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 4 Jun 2019 12:12:15 +0200 Subject: [PATCH 1/3] MOBILE-3039 forum: Fix attachments not downloaded on prefetch --- .../mod/forum/providers/prefetch-handler.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/addon/mod/forum/providers/prefetch-handler.ts b/src/addon/mod/forum/providers/prefetch-handler.ts index 04e3289f8..6241dce19 100644 --- a/src/addon/mod/forum/providers/prefetch-handler.ts +++ b/src/addon/mod/forum/providers/prefetch-handler.ts @@ -122,7 +122,24 @@ export class AddonModForumPrefetchHandler extends CoreCourseActivityPrefetchHand }); }); - return Promise.all(promises); + return Promise.all(promises).then((results) => { + // Each order has returned its own list of posts. Merge all the lists, preventing duplicates. + const posts = [], + postIds = {}; // To make the array unique. + + results.forEach((orderResults) => { + orderResults.forEach((orderResult) => { + orderResult.posts.forEach((post) => { + if (!postIds[post.id]) { + postIds[post.id] = true; + posts.push(post); + } + }); + }); + }); + + return posts; + }); } /** From 3a56fa0e80a37d33bfaf8a24916fd16b287b4c91 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 4 Jun 2019 12:53:11 +0200 Subject: [PATCH 2/3] MOBILE-3039 glossary: Fix edit offline entry --- src/addon/mod/glossary/pages/edit/edit.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/addon/mod/glossary/pages/edit/edit.ts b/src/addon/mod/glossary/pages/edit/edit.ts index 8520727b6..837b0e760 100644 --- a/src/addon/mod/glossary/pages/edit/edit.ts +++ b/src/addon/mod/glossary/pages/edit/edit.ts @@ -88,6 +88,7 @@ export class AddonModGlossaryEditPage implements OnInit { if (entry) { this.entry.concept = entry.concept || ''; this.entry.definition = entry.definition || ''; + this.entry.timecreated = entry.timecreated || 0; this.originalData = { concept: this.entry.concept, From ed35e57e1c70b254836fd5a3c5a7cd0c0b8588dd Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 6 Jun 2019 09:44:05 +0200 Subject: [PATCH 3/3] MOBILE-3039 core: Don't allow disable sound in iOS and Android 8+ --- .../notifications/pages/settings/settings.ts | 3 ++- .../providers/pushnotifications.ts | 10 ++++++++- src/providers/local-notifications.ts | 21 ++++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/addon/notifications/pages/settings/settings.ts b/src/addon/notifications/pages/settings/settings.ts index ed4cabc45..58ab72395 100644 --- a/src/addon/notifications/pages/settings/settings.ts +++ b/src/addon/notifications/pages/settings/settings.ts @@ -55,7 +55,8 @@ export class AddonNotificationsSettingsPage implements OnDestroy { @Optional() private svComponent: CoreSplitViewComponent) { this.notifPrefsEnabled = notificationsProvider.isNotificationPreferencesEnabled(); - this.canChangeSound = localNotificationsProvider.isAvailable() && !appProvider.isDesktop(); + this.canChangeSound = localNotificationsProvider.canDisableSound(); + if (this.canChangeSound) { configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((enabled) => { this.notificationSound = !!enabled; diff --git a/src/core/pushnotifications/providers/pushnotifications.ts b/src/core/pushnotifications/providers/pushnotifications.ts index c61bf7a29..f6b0201d4 100644 --- a/src/core/pushnotifications/providers/pushnotifications.ts +++ b/src/core/pushnotifications/providers/pushnotifications.ts @@ -246,7 +246,15 @@ export class CorePushNotificationsProvider { * @return {Promise} Promise with the push options resolved when done. */ protected getOptions(): Promise { - return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { + let promise; + + if (this.localNotificationsProvider.canDisableSound()) { + promise = this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true); + } else { + promise = Promise.resolve(true); + } + + return promise.then((soundEnabled) => { return { android: { sound: !!soundEnabled, diff --git a/src/providers/local-notifications.ts b/src/providers/local-notifications.ts index 308ffb4c7..ae9de1652 100644 --- a/src/providers/local-notifications.ts +++ b/src/providers/local-notifications.ts @@ -205,6 +205,17 @@ export class CoreLocalNotificationsProvider { }); } + /** + * Check whether sound can be disabled for notifications. + * + * @return {boolean} Whether sound can be disabled for notifications. + */ + canDisableSound(): boolean { + // Only allow disabling sound in Android 7 or lower. In iOS and Android 8+ it can easily be done with system settings. + return this.isAvailable() && !this.appProvider.isDesktop() && this.platform.is('android') && + this.platform.version().major < 8; + } + /** * Create the default channel. It is used to change the name. * @@ -577,7 +588,15 @@ export class CoreLocalNotificationsProvider { return this.localNotifications.cancel(notification.id).finally(() => { if (!triggered) { // Check if sound is enabled for notifications. - return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { + let promise; + + if (this.canDisableSound()) { + promise = this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true); + } else { + promise = Promise.resolve(true); + } + + return promise.then((soundEnabled) => { if (!soundEnabled) { notification.sound = null; } else {