Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/addon/mod/forum/providers/prefetch-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/addon/mod/glossary/pages/edit/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/addon/notifications/pages/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion src/core/pushnotifications/providers/pushnotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,15 @@ export class CorePushNotificationsProvider {
* @return {Promise<PushOptions>} Promise with the push options resolved when done.
*/
protected getOptions(): Promise<PushOptions> {
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,
Expand Down
21 changes: 20 additions & 1 deletion src/providers/local-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 {
Expand Down