MOBILE-3320 core: Fix bugs with concat(), like notes sync

main
Dani Palou 2021-06-02 16:16:22 +02:00
parent 7c2867fedc
commit dd2eb1fc97
5 changed files with 8 additions and 12 deletions

View File

@ -546,12 +546,12 @@ export class AddonCalendarHelperProvider {
const site = await CoreSites.getSite(siteId);
const fetchTimestarts: number[] = [];
const invalidateTimestarts: number[] = [];
const promises: Promise<unknown>[] = [];
let promises: Promise<unknown>[] = [];
// Always fetch upcoming events.
promises.push(AddonCalendar.getUpcomingEvents(undefined, undefined, true, site.id));
promises.concat(events.map(async (eventData) => {
promises = promises.concat(events.map(async (eventData) => {
if (eventData.repeated <= 1) {
// Not repeated.

View File

@ -48,13 +48,13 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe
try {
const forum = await AddonModForum.getForum(courseId, module.id);
const files = this.getIntroFilesFromInstance(module, forum);
let files = this.getIntroFilesFromInstance(module, forum);
// Get posts.
const posts = await this.getPostsForPrefetch(forum, { cmId: module.id });
// Add posts attachments and embedded files.
files.concat(this.getPostsFiles(posts));
files = files.concat(this.getPostsFiles(posts));
return files;
} catch (error) {

View File

@ -573,7 +573,6 @@ class AddonModGlossaryEntriesManager extends CorePageItemsListManager<EntryItem>
*/
setOnlineEntries(onlineEntries: AddonModGlossaryEntry[], hasMoreItems: boolean = false): void {
this.setItems((<EntryItem[]> this.offlineEntries).concat(onlineEntries), hasMoreItems);
this.onlineEntries.concat(onlineEntries);
}
/**
@ -583,7 +582,6 @@ class AddonModGlossaryEntriesManager extends CorePageItemsListManager<EntryItem>
*/
setOfflineEntries(offlineEntries: AddonModGlossaryOfflineEntry[]): void {
this.setItems((<EntryItem[]> offlineEntries).concat(this.onlineEntries), this.hasMoreItems);
this.offlineEntries = offlineEntries;
}
/**

View File

@ -62,12 +62,10 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR
]);
// Get all the courses to be synced.
const courseIds: number[] = [];
let courseIds: number[] = [];
notesArray.forEach((notes: (AddonNotesDeletedDBRecord | AddonNotesDBRecord)[]) => {
const courseIds = notes.map((note) => note.courseid);
courseIds.concat(courseIds);
}, []);
courseIds = courseIds.concat(notes.map((note) => note.courseid));
});
CoreUtils.uniqueArray(courseIds);

View File

@ -24,7 +24,7 @@ export function buildTabMainRoutes(injector: Injector, mainRoute: Route): Routes
mainRoute.path = mainRoute.path || '';
mainRoute.children = mainRoute.children || [];
mainRoute.children.concat(routes.children);
mainRoute.children = mainRoute.children.concat(routes.children);
return [
mainRoute,