Merge pull request #3346 from dpalou/MOBILE-4081

MOBILE-4081 core: Remove some unneeded invalidates
main
Pau Ferrer Ocaña 2022-07-13 11:10:31 +02:00 committed by GitHub
commit 3b0e94be4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -16,8 +16,7 @@ import { Injectable, Type } from '@angular/core';
import { AddonModForum, AddonModForumProvider } from '../forum';
import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
import { CoreConstants, ModPurpose } from '@/core/constants';
import { AddonModForumIndexComponent } from '../../components/index';
@ -115,11 +114,12 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp
data.extraBadge = Translate.instant('core.loading');
data.extraBadgeColor = CoreIonicColorNames.DARK;
await CoreUtils.ignoreErrors(AddonModForum.invalidateForumData(courseId));
try {
// Handle unread posts.
const forum = await AddonModForum.getForum(courseId, moduleId, { siteId });
const forum = await AddonModForum.getForum(courseId, moduleId, {
readingStrategy: CoreSitesReadingStrategy.PREFER_NETWORK,
siteId,
});
data.extraBadgeColor = undefined;
data.extraBadge = forum.unreadpostscount

View File

@ -1041,13 +1041,13 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
* @param courseId Course ID the module belongs to.
* @return Promise resolved when finished.
*/
syncModules(modules: CoreCourseModuleData[], courseId: number): Promise<unknown> {
return Promise.all(modules.map(async (module) => {
await this.syncModule(module, courseId);
async syncModules(modules: CoreCourseModuleData[], courseId: number): Promise<void> {
try {
await Promise.all(modules.map((module) => this.syncModule(module, courseId)));
} finally {
// Invalidate course updates.
await CoreUtils.ignoreErrors(this.invalidateCourseUpdates(courseId));
}));
}
}
/**