MOBILE-4653 sync: Decouple Sync services from related main service
This commit is contained in:
		
							parent
							
								
									40b200d6da
								
							
						
					
					
						commit
						1eb548e47b
					
				@ -39,7 +39,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
 | 
			
		||||
import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper';
 | 
			
		||||
import { AddonModAssignSubmissionDelegate } from './submission-delegate';
 | 
			
		||||
import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
 | 
			
		||||
import { ADDON_MOD_ASSIGN_AUTO_SYNCED, ADDON_MOD_ASSIGN_COMPONENT } from '../constants';
 | 
			
		||||
import { ADDON_MOD_ASSIGN_AUTO_SYNCED, ADDON_MOD_ASSIGN_COMPONENT, ADDON_MOD_ASSIGN_MANUAL_SYNCED } from '../constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Service to sync assigns.
 | 
			
		||||
@ -535,7 +535,7 @@ export type AddonModAssignSyncResult = CoreSyncResult & {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_ASSIGN_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModAssignAutoSyncData = {
 | 
			
		||||
    assignId: number;
 | 
			
		||||
@ -544,9 +544,23 @@ export type AddonModAssignAutoSyncData = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to MANUAL_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_ASSIGN_MANUAL_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModAssignManualSyncData = AddonModAssignAutoSyncData & {
 | 
			
		||||
    context: string;
 | 
			
		||||
    submitId?: number;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_ASSIGN_MANUAL_SYNCED]: AddonModAssignManualSyncData;
 | 
			
		||||
        [ADDON_MOD_ASSIGN_AUTO_SYNCED]: AddonModAssignAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -30,17 +30,14 @@ import { AddonModAssignSubmissionDelegate } from './submission-delegate';
 | 
			
		||||
import { CoreComments } from '@features/comments/services/comments';
 | 
			
		||||
import { AddonModAssignSubmissionFormatted } from './assign-helper';
 | 
			
		||||
import { CoreWSError } from '@classes/errors/wserror';
 | 
			
		||||
import { AddonModAssignAutoSyncData, AddonModAssignManualSyncData } from './assign-sync';
 | 
			
		||||
import { CoreFormFields } from '@singletons/form';
 | 
			
		||||
import { CoreFileHelper } from '@services/file-helper';
 | 
			
		||||
import { CoreIonicColorNames } from '@singletons/colors';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import { ContextLevel, CoreCacheUpdateFrequency } from '@/core/constants';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_ASSIGN_AUTO_SYNCED,
 | 
			
		||||
    ADDON_MOD_ASSIGN_COMPONENT,
 | 
			
		||||
    ADDON_MOD_ASSIGN_GRADED_EVENT,
 | 
			
		||||
    ADDON_MOD_ASSIGN_MANUAL_SYNCED,
 | 
			
		||||
    ADDON_MOD_ASSIGN_STARTED_EVENT,
 | 
			
		||||
    ADDON_MOD_ASSIGN_SUBMISSION_REMOVED_EVENT,
 | 
			
		||||
    ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT,
 | 
			
		||||
@ -60,8 +57,6 @@ declare module '@singletons/events' {
 | 
			
		||||
        [ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT]: AddonModAssignSubmittedForGradingEventData;
 | 
			
		||||
        [ADDON_MOD_ASSIGN_GRADED_EVENT]: AddonModAssignGradedEventData;
 | 
			
		||||
        [ADDON_MOD_ASSIGN_STARTED_EVENT]: AddonModAssignStartedEventData;
 | 
			
		||||
        [ADDON_MOD_ASSIGN_MANUAL_SYNCED]: AddonModAssignManualSyncData;
 | 
			
		||||
        [ADDON_MOD_ASSIGN_AUTO_SYNCED]: AddonModAssignAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -28,6 +28,19 @@ import { AddonModChoiceOffline } from './choice-offline';
 | 
			
		||||
import { AddonModChoicePrefetchHandler } from './handlers/prefetch';
 | 
			
		||||
import { ADDON_MOD_CHOICE_AUTO_SYNCED, ADDON_MOD_CHOICE_COMPONENT } from '../constants';
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_CHOICE_AUTO_SYNCED]: AddonModChoiceAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Service to sync choices.
 | 
			
		||||
 */
 | 
			
		||||
@ -220,7 +233,7 @@ export const AddonModChoiceSync = makeSingleton(AddonModChoiceSyncProvider);
 | 
			
		||||
export type AddonModChoiceSyncResult = CoreSyncResult;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_CHOICE_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModChoiceAutoSyncData = {
 | 
			
		||||
    choiceId: number;
 | 
			
		||||
 | 
			
		||||
@ -24,9 +24,8 @@ import { CoreUtils } from '@services/utils/utils';
 | 
			
		||||
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
 | 
			
		||||
import { makeSingleton, Translate } from '@singletons';
 | 
			
		||||
import { AddonModChoiceOffline } from './choice-offline';
 | 
			
		||||
import { AddonModChoiceAutoSyncData } from './choice-sync';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import { ADDON_MOD_CHOICE_AUTO_SYNCED, ADDON_MOD_CHOICE_COMPONENT, AddonModChoiceShowResults } from '../constants';
 | 
			
		||||
import { ADDON_MOD_CHOICE_COMPONENT, AddonModChoiceShowResults } from '../constants';
 | 
			
		||||
import { CoreCacheUpdateFrequency } from '@/core/constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -602,16 +601,3 @@ export type AddonModChoiceSubmitChoiceResponseWSParams = {
 | 
			
		||||
    choiceid: number; // Choice instance id.
 | 
			
		||||
    responses: number[]; // Array of response ids.
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_CHOICE_AUTO_SYNCED]: AddonModChoiceAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -486,3 +486,15 @@ export type AddonModDataAutoSyncData = {
 | 
			
		||||
    offlineEntryId?: number;
 | 
			
		||||
    deleted?: boolean;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_DATA_AUTO_SYNCED]: AddonModDataAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -27,10 +27,8 @@ import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
 | 
			
		||||
import { makeSingleton, Translate } from '@singletons';
 | 
			
		||||
import { AddonModDataFieldsDelegate } from './data-fields-delegate';
 | 
			
		||||
import { AddonModDataOffline } from './data-offline';
 | 
			
		||||
import { AddonModDataAutoSyncData } from './data-sync';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_DATA_AUTO_SYNCED,
 | 
			
		||||
    ADDON_MOD_DATA_COMPONENT,
 | 
			
		||||
    ADDON_MOD_DATA_ENTRIES_PER_PAGE,
 | 
			
		||||
    ADDON_MOD_DATA_ENTRY_CHANGED,
 | 
			
		||||
@ -46,7 +44,6 @@ declare module '@singletons/events' {
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_DATA_AUTO_SYNCED]: AddonModDataAutoSyncData;
 | 
			
		||||
        [ADDON_MOD_DATA_ENTRY_CHANGED]: AddonModDataEntryChangedEventData;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -35,11 +35,11 @@ import { AddonModFeedbackOffline } from '../../services/feedback-offline';
 | 
			
		||||
import {
 | 
			
		||||
    AddonModFeedbackAutoSyncData,
 | 
			
		||||
    AddonModFeedbackSync,
 | 
			
		||||
    AddonModFeedbackSyncProvider,
 | 
			
		||||
    AddonModFeedbackSyncResult,
 | 
			
		||||
} from '../../services/feedback-sync';
 | 
			
		||||
import { AddonModFeedbackPrefetchHandler } from '../../services/handlers/prefetch';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_FEEDBACK_AUTO_SYNCED,
 | 
			
		||||
    ADDON_MOD_FEEDBACK_COMPONENT,
 | 
			
		||||
    ADDON_MOD_FEEDBACK_FORM_SUBMITTED,
 | 
			
		||||
    ADDON_MOD_FEEDBACK_PAGE_NAME,
 | 
			
		||||
@ -87,7 +87,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    protected submitObserver: CoreEventObserver;
 | 
			
		||||
    protected syncEventName = AddonModFeedbackSyncProvider.AUTO_SYNCED;
 | 
			
		||||
    protected syncEventName = ADDON_MOD_FEEDBACK_AUTO_SYNCED;
 | 
			
		||||
    protected checkCompletionAfterLog = false;
 | 
			
		||||
 | 
			
		||||
    constructor(
 | 
			
		||||
 | 
			
		||||
@ -23,6 +23,8 @@ export const ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP = '<<<<<';
 | 
			
		||||
export const ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT = 'h';
 | 
			
		||||
export const ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP = '####';
 | 
			
		||||
 | 
			
		||||
export const ADDON_MOD_FEEDBACK_AUTO_SYNCED = 'addon_mod_feedback_autom_synced';
 | 
			
		||||
 | 
			
		||||
export const ADDON_MOD_FEEDBACK_PER_PAGE = 20;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@ import { CoreEvents } from '@singletons/events';
 | 
			
		||||
import { AddonModFeedback, AddonModFeedbackWSFeedback } from './feedback';
 | 
			
		||||
import { AddonModFeedbackOffline, AddonModFeedbackOfflineResponse } from './feedback-offline';
 | 
			
		||||
import { AddonModFeedbackPrefetchHandler, AddonModFeedbackPrefetchHandlerService } from './handlers/prefetch';
 | 
			
		||||
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../constants';
 | 
			
		||||
import { ADDON_MOD_FEEDBACK_AUTO_SYNCED, ADDON_MOD_FEEDBACK_COMPONENT } from '../constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Service to sync feedbacks.
 | 
			
		||||
@ -35,8 +35,6 @@ import { ADDON_MOD_FEEDBACK_COMPONENT } from '../constants';
 | 
			
		||||
@Injectable({ providedIn: 'root' })
 | 
			
		||||
export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModFeedbackSyncResult> {
 | 
			
		||||
 | 
			
		||||
    static readonly AUTO_SYNCED = 'addon_mod_feedback_autom_synced';
 | 
			
		||||
 | 
			
		||||
    protected componentTranslatableString = 'feedback';
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
@ -96,7 +94,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
 | 
			
		||||
 | 
			
		||||
            if (result?.updated) {
 | 
			
		||||
                // Sync successful, send event.
 | 
			
		||||
                CoreEvents.trigger(AddonModFeedbackSyncProvider.AUTO_SYNCED, {
 | 
			
		||||
                CoreEvents.trigger(ADDON_MOD_FEEDBACK_AUTO_SYNCED, {
 | 
			
		||||
                    feedbackId: response.feedbackid,
 | 
			
		||||
                    warnings: result.warnings,
 | 
			
		||||
                }, siteId);
 | 
			
		||||
@ -296,9 +294,22 @@ export const AddonModFeedbackSync = makeSingleton(AddonModFeedbackSyncProvider);
 | 
			
		||||
export type AddonModFeedbackSyncResult = CoreSyncResult;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_FEEDBACK_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModFeedbackAutoSyncData = {
 | 
			
		||||
    feedbackId: number;
 | 
			
		||||
    warnings: string[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_FEEDBACK_AUTO_SYNCED]: AddonModFeedbackAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,6 @@ import { CoreUtils } from '@services/utils/utils';
 | 
			
		||||
import { CoreWSExternalFile, CoreWSExternalWarning, CoreWSStoredFile } from '@services/ws';
 | 
			
		||||
import { makeSingleton, Translate } from '@singletons';
 | 
			
		||||
import { AddonModFeedbackOffline } from './feedback-offline';
 | 
			
		||||
import { AddonModFeedbackAutoSyncData, AddonModFeedbackSyncProvider } from './feedback-sync';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_FEEDBACK_COMPONENT,
 | 
			
		||||
@ -1254,7 +1253,6 @@ declare module '@singletons/events' {
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_FEEDBACK_FORM_SUBMITTED]: AddonModFeedbackFormSubmittedData;
 | 
			
		||||
        [AddonModFeedbackSyncProvider.AUTO_SYNCED]: AddonModFeedbackAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -648,7 +648,7 @@ export const AddonModForumSync = makeSingleton(AddonModForumSyncProvider);
 | 
			
		||||
export type AddonModForumSyncResult = CoreSyncResult;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_FORUM_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModForumAutoSyncData = {
 | 
			
		||||
    forumId: number;
 | 
			
		||||
@ -658,7 +658,7 @@ export type AddonModForumAutoSyncData = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to MANUAL_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_FORUM_MANUAL_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModForumManualSyncData = {
 | 
			
		||||
    forumId: number;
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,6 @@ import { AddonModGlossaryOfflineEntry } from '../../services/glossary-offline';
 | 
			
		||||
import {
 | 
			
		||||
    AddonModGlossaryAutoSyncedData,
 | 
			
		||||
    AddonModGlossarySyncResult,
 | 
			
		||||
    GLOSSARY_AUTO_SYNCED,
 | 
			
		||||
} from '../../services/glossary-sync';
 | 
			
		||||
import { AddonModGlossaryPrefetchHandler } from '../../services/handlers/prefetch';
 | 
			
		||||
import { CoreTime } from '@singletons/time';
 | 
			
		||||
@ -57,6 +56,7 @@ import {
 | 
			
		||||
    ADDON_MOD_GLOSSARY_ENTRY_DELETED,
 | 
			
		||||
    ADDON_MOD_GLOSSARY_ENTRY_UPDATED,
 | 
			
		||||
    ADDON_MOD_GLOSSARY_PAGE_NAME,
 | 
			
		||||
    GLOSSARY_AUTO_SYNCED,
 | 
			
		||||
} from '../../constants';
 | 
			
		||||
import { CorePopovers } from '@services/popovers';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -19,5 +19,7 @@ export const ADDON_MOD_GLOSSARY_ENTRY_ADDED = 'addon_mod_glossary_entry_added';
 | 
			
		||||
export const ADDON_MOD_GLOSSARY_ENTRY_UPDATED = 'addon_mod_glossary_entry_updated';
 | 
			
		||||
export const ADDON_MOD_GLOSSARY_ENTRY_DELETED = 'addon_mod_glossary_entry_deleted';
 | 
			
		||||
 | 
			
		||||
export const GLOSSARY_AUTO_SYNCED = 'addon_mod_glossary_auto_synced';
 | 
			
		||||
 | 
			
		||||
export const ADDON_MOD_GLOSSARY_LIMIT_ENTRIES = 25;
 | 
			
		||||
export const ADDON_MOD_GLOSSARY_LIMIT_CATEGORIES = 10;
 | 
			
		||||
 | 
			
		||||
@ -30,9 +30,7 @@ import { AddonModGlossaryHelper } from './glossary-helper';
 | 
			
		||||
import { AddonModGlossaryOffline, AddonModGlossaryOfflineEntry } from './glossary-offline';
 | 
			
		||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
 | 
			
		||||
import { CoreFileEntry } from '@services/file-helper';
 | 
			
		||||
import { ADDON_MOD_GLOSSARY_COMPONENT } from '../constants';
 | 
			
		||||
 | 
			
		||||
export const GLOSSARY_AUTO_SYNCED = 'addon_mod_glossary_auto_synced';
 | 
			
		||||
import { ADDON_MOD_GLOSSARY_COMPONENT, GLOSSARY_AUTO_SYNCED } from '../constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Service to sync glossaries.
 | 
			
		||||
 | 
			
		||||
@ -401,3 +401,16 @@ export type AddonModH5PActivityAutoSyncData = {
 | 
			
		||||
    contextId: number;
 | 
			
		||||
    warnings: string[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_H5PACTIVITY_AUTO_SYNCED]: AddonModH5PActivityAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,11 +25,9 @@ import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
 | 
			
		||||
import { makeSingleton, Translate } from '@singletons/index';
 | 
			
		||||
import { CoreWSError } from '@classes/errors/wserror';
 | 
			
		||||
import { CoreError } from '@classes/errors/error';
 | 
			
		||||
import { AddonModH5PActivityAutoSyncData } from './h5pactivity-sync';
 | 
			
		||||
import { CoreTime } from '@singletons/time';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_H5PACTIVITY_AUTO_SYNCED,
 | 
			
		||||
    ADDON_MOD_H5PACTIVITY_COMPONENT,
 | 
			
		||||
    ADDON_MOD_H5PACTIVITY_USERS_PER_PAGE,
 | 
			
		||||
    AddonModH5PActivityGradeMethod,
 | 
			
		||||
@ -1137,19 +1135,6 @@ export type AddonModH5PActivityGetAllUsersAttemptsOptions = AddonModH5PActivityG
 | 
			
		||||
    dontFailOnError?: boolean; // If true the function will return the users it's able to retrieve, until a call fails.
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_H5PACTIVITY_AUTO_SYNCED]: AddonModH5PActivityAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data to be sent using xAPI.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@ -499,9 +499,22 @@ export type AddonModLessonSyncResult = CoreSyncResult & {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_LESSON_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModLessonAutoSyncData = {
 | 
			
		||||
    lessonId: number;
 | 
			
		||||
    warnings: string[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_LESSON_AUTO_SYNCED]: AddonModLessonAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,10 +25,8 @@ import { makeSingleton, Translate } from '@singletons';
 | 
			
		||||
import { CoreEvents } from '@singletons/events';
 | 
			
		||||
import { AddonModLessonPasswordDBRecord, PASSWORD_TABLE_NAME } from './database/lesson';
 | 
			
		||||
import { AddonModLessonOffline, AddonModLessonPageAttemptRecord } from './lesson-offline';
 | 
			
		||||
import { AddonModLessonAutoSyncData } from './lesson-sync';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_LESSON_AUTO_SYNCED,
 | 
			
		||||
    ADDON_MOD_LESSON_COMPONENT,
 | 
			
		||||
    ADDON_MOD_LESSON_DATA_SENT_EVENT,
 | 
			
		||||
    ADDON_MOD_LESSON_OTHER_ANSWERS,
 | 
			
		||||
@ -48,7 +46,6 @@ declare module '@singletons/events' {
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_LESSON_DATA_SENT_EVENT]: AddonModLessonDataSentData;
 | 
			
		||||
        [ADDON_MOD_LESSON_AUTO_SYNCED]: AddonModLessonAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -496,10 +496,23 @@ type FinishSyncOptions = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_QUIZ_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModQuizAutoSyncData = {
 | 
			
		||||
    quizId: number;
 | 
			
		||||
    attemptFinished: boolean;
 | 
			
		||||
    warnings: string[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_QUIZ_AUTO_SYNCED]: AddonModQuizAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -36,7 +36,6 @@ import { makeSingleton, Translate } from '@singletons';
 | 
			
		||||
import { CoreLogger } from '@singletons/logger';
 | 
			
		||||
import { AddonModQuizAccessRuleDelegate } from './access-rules-delegate';
 | 
			
		||||
import { AddonModQuizOffline, AddonModQuizQuestionsWithAnswers } from './quiz-offline';
 | 
			
		||||
import { AddonModQuizAutoSyncData } from './quiz-sync';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import {
 | 
			
		||||
    QUESTION_INVALID_STATE_CLASSES,
 | 
			
		||||
@ -51,7 +50,6 @@ import {
 | 
			
		||||
    AddonModQuizGradeMethods,
 | 
			
		||||
    AddonModQuizDisplayOptionsAttemptStates,
 | 
			
		||||
    ADDON_MOD_QUIZ_IMMEDIATELY_AFTER_PERIOD,
 | 
			
		||||
    ADDON_MOD_QUIZ_AUTO_SYNCED,
 | 
			
		||||
} from '../constants';
 | 
			
		||||
import { CoreIonicColorNames } from '@singletons/colors';
 | 
			
		||||
import { CoreCacheUpdateFrequency } from '@/core/constants';
 | 
			
		||||
@ -65,7 +63,6 @@ declare module '@singletons/events' {
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_QUIZ_ATTEMPT_FINISHED_EVENT]: AddonModQuizAttemptFinishedData;
 | 
			
		||||
        [ADDON_MOD_QUIZ_AUTO_SYNCED]: AddonModQuizAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -850,3 +850,16 @@ export type AddonModScormAutoSyncEventData = CoreSyncResult & {
 | 
			
		||||
    scormId: number;
 | 
			
		||||
    attemptFinished: boolean;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_SCORM_DATA_AUTO_SYNCED]: AddonModScormAutoSyncEventData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,6 @@ import { makeSingleton, Translate } from '@singletons';
 | 
			
		||||
import { CoreEvents } from '@singletons/events';
 | 
			
		||||
import { CorePath } from '@singletons/path';
 | 
			
		||||
import { AddonModScormOffline } from './scorm-offline';
 | 
			
		||||
import { AddonModScormAutoSyncEventData } from './scorm-sync';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_SCORM_COMPONENT,
 | 
			
		||||
@ -42,7 +41,6 @@ import {
 | 
			
		||||
    ADDON_MOD_SCORM_LAUNCH_NEXT_SCO_EVENT,
 | 
			
		||||
    ADDON_MOD_SCORM_LAUNCH_PREV_SCO_EVENT,
 | 
			
		||||
    ADDON_MOD_SCORM_UPDATE_TOC_EVENT,
 | 
			
		||||
    ADDON_MOD_SCORM_DATA_AUTO_SYNCED,
 | 
			
		||||
} from '../constants';
 | 
			
		||||
 | 
			
		||||
// Private constants.
 | 
			
		||||
@ -2080,7 +2078,6 @@ declare module '@singletons/events' {
 | 
			
		||||
        [ADDON_MOD_SCORM_UPDATE_TOC_EVENT]: AddonModScormCommonEventData;
 | 
			
		||||
        [ADDON_MOD_SCORM_GO_OFFLINE_EVENT]: AddonModScormCommonEventData;
 | 
			
		||||
        [ADDON_MOD_SCORM_DATA_SENT_EVENT]: AddonModScormCommonEventData;
 | 
			
		||||
        [ADDON_MOD_SCORM_DATA_AUTO_SYNCED]: AddonModScormAutoSyncEventData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -241,7 +241,7 @@ export type AddonModSurveySyncResult = CoreSyncResult & {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_SURVEY_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModSurveyAutoSyncData = {
 | 
			
		||||
    surveyId: number;
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ import { CoreEvents } from '@singletons/events';
 | 
			
		||||
import { AddonModWikiPageDBRecord } from './database/wiki';
 | 
			
		||||
import { AddonModWiki } from './wiki';
 | 
			
		||||
import { AddonModWikiOffline } from './wiki-offline';
 | 
			
		||||
import { ADDON_MOD_WIKI_AUTO_SYNCED, ADDON_MOD_WIKI_COMPONENT } from '../constants';
 | 
			
		||||
import { ADDON_MOD_WIKI_AUTO_SYNCED, ADDON_MOD_WIKI_COMPONENT, ADDON_MOD_WIKI_MANUAL_SYNCED } from '../constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Service to sync wikis.
 | 
			
		||||
@ -386,7 +386,7 @@ export type AddonModWikiDiscardedPage = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_WIKI_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModWikiAutoSyncData = {
 | 
			
		||||
    siteId: string;
 | 
			
		||||
@ -400,8 +400,22 @@ export type AddonModWikiAutoSyncData = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to MANUAL_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_MOD_WIKI_MANUAL_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonModWikiManualSyncData = AddonModWikiSyncWikiResult & {
 | 
			
		||||
    wikiId: number;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_WIKI_AUTO_SYNCED]: AddonModWikiAutoSyncData;
 | 
			
		||||
        [ADDON_MOD_WIKI_MANUAL_SYNCED]: AddonModWikiManualSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -26,12 +26,9 @@ import { makeSingleton, Translate } from '@singletons';
 | 
			
		||||
import { CoreEvents } from '@singletons/events';
 | 
			
		||||
import { AddonModWikiPageDBRecord } from './database/wiki';
 | 
			
		||||
import { AddonModWikiOffline } from './wiki-offline';
 | 
			
		||||
import { AddonModWikiAutoSyncData, AddonModWikiManualSyncData } from './wiki-sync';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_WIKI_AUTO_SYNCED,
 | 
			
		||||
    ADDON_MOD_WIKI_COMPONENT,
 | 
			
		||||
    ADDON_MOD_WIKI_MANUAL_SYNCED,
 | 
			
		||||
    ADDON_MOD_WIKI_PAGE_CREATED_EVENT,
 | 
			
		||||
} from '../constants';
 | 
			
		||||
import { CoreCacheUpdateFrequency } from '@/core/constants';
 | 
			
		||||
@ -898,8 +895,6 @@ declare module '@singletons/events' {
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_WIKI_PAGE_CREATED_EVENT]: AddonModWikiPageCreatedData;
 | 
			
		||||
        [ADDON_MOD_WIKI_AUTO_SYNCED]: AddonModWikiAutoSyncData;
 | 
			
		||||
        [ADDON_MOD_WIKI_MANUAL_SYNCED]: AddonModWikiManualSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -640,3 +640,15 @@ export type AddonModWorkshopAutoSyncData = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export type AddonModWorkshopSyncResult = CoreSyncResult;
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_WORKSHOP_AUTO_SYNCED]: AddonModWorkshopAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,11 +25,9 @@ import { CoreStatusWithWarningsWSResponse, CoreWS, CoreWSExternalFile, CoreWSExt
 | 
			
		||||
import { makeSingleton, Translate } from '@singletons';
 | 
			
		||||
import { CoreFormFields } from '@singletons/form';
 | 
			
		||||
import { AddonModWorkshopOffline } from './workshop-offline';
 | 
			
		||||
import { AddonModWorkshopAutoSyncData } from './workshop-sync';
 | 
			
		||||
import {
 | 
			
		||||
    ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED,
 | 
			
		||||
    ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED,
 | 
			
		||||
    ADDON_MOD_WORKSHOP_AUTO_SYNCED,
 | 
			
		||||
    ADDON_MOD_WORKSHOP_COMPONENT,
 | 
			
		||||
    ADDON_MOD_WORKSHOP_PER_PAGE,
 | 
			
		||||
    ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED,
 | 
			
		||||
@ -51,7 +49,6 @@ declare module '@singletons/events' {
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [ADDON_MOD_WORKSHOP_AUTO_SYNCED]: AddonModWorkshopAutoSyncData;
 | 
			
		||||
        [ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED]: AddonModWorkshopSubmissionChangedEventData;
 | 
			
		||||
        [ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED]: AddonModWorkshopAssessmentSavedChangedEventData;
 | 
			
		||||
        [ADDON_MOD_WORKSHOP_ASSESSMENT_INVALIDATED]: AddonModWorkshopAssessmentInvalidatedChangedEventData;
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@ import { CoreConstants } from '@/core/constants';
 | 
			
		||||
import { AddonNotesAddModalReturn } from '@addons/notes/components/add/add-modal';
 | 
			
		||||
import { AddonNotes, AddonNotesNoteFormatted, AddonNotesPublishState } from '@addons/notes/services/notes';
 | 
			
		||||
import { AddonNotesOffline } from '@addons/notes/services/notes-offline';
 | 
			
		||||
import { AddonNotesSync, AddonNotesSyncProvider } from '@addons/notes/services/notes-sync';
 | 
			
		||||
import { AddonNotesSync } from '@addons/notes/services/notes-sync';
 | 
			
		||||
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
 | 
			
		||||
import { CoreAnimations } from '@components/animations';
 | 
			
		||||
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
 | 
			
		||||
@ -33,6 +33,7 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
 | 
			
		||||
import { CoreTime } from '@singletons/time';
 | 
			
		||||
import { CoreToasts, ToastDuration } from '@services/toasts';
 | 
			
		||||
import { CoreModals } from '@services/modals';
 | 
			
		||||
import { ADDON_NOTES_AUTO_SYNCED } from '@addons/notes/services/constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Page that displays a list of notes.
 | 
			
		||||
@ -77,7 +78,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Refresh data if notes are synchronized automatically.
 | 
			
		||||
        this.syncObserver = CoreEvents.on(AddonNotesSyncProvider.AUTO_SYNCED, (data) => {
 | 
			
		||||
        this.syncObserver = CoreEvents.on(ADDON_NOTES_AUTO_SYNCED, (data) => {
 | 
			
		||||
            if (data.courseId == this.courseId) {
 | 
			
		||||
                // Show the sync warnings.
 | 
			
		||||
                this.showSyncWarnings(data.warnings);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								src/addons/notes/services/constants.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/addons/notes/services/constants.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
// (C) Copyright 2015 Moodle Pty Ltd.
 | 
			
		||||
//
 | 
			
		||||
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
// you may not use this file except in compliance with the License.
 | 
			
		||||
// You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
//     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
// See the License for the specific language governing permissions and
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
 | 
			
		||||
export const ADDON_NOTES_AUTO_SYNCED = 'addon_notes_autom_synced';
 | 
			
		||||
@ -27,6 +27,7 @@ import { AddonNotesOffline } from './notes-offline';
 | 
			
		||||
import { CoreArray } from '@singletons/array';
 | 
			
		||||
import { CoreAnyError } from '@classes/errors/error';
 | 
			
		||||
import { CoreErrorHelper } from '@services/error-helper';
 | 
			
		||||
import { ADDON_NOTES_AUTO_SYNCED } from './constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Service to sync notes.
 | 
			
		||||
@ -34,8 +35,6 @@ import { CoreErrorHelper } from '@services/error-helper';
 | 
			
		||||
@Injectable( { providedIn: 'root' } )
 | 
			
		||||
export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncResult> {
 | 
			
		||||
 | 
			
		||||
    static readonly AUTO_SYNCED = 'addon_notes_autom_synced';
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super('AddonNotesSync');
 | 
			
		||||
    }
 | 
			
		||||
@ -80,7 +79,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider<AddonNotesSyncR
 | 
			
		||||
 | 
			
		||||
            if (result !== undefined) {
 | 
			
		||||
                // Sync successful, send event.
 | 
			
		||||
                CoreEvents.trigger(AddonNotesSyncProvider.AUTO_SYNCED, {
 | 
			
		||||
                CoreEvents.trigger(ADDON_NOTES_AUTO_SYNCED, {
 | 
			
		||||
                    courseId,
 | 
			
		||||
                    warnings: result.warnings,
 | 
			
		||||
                }, siteId);
 | 
			
		||||
@ -251,7 +250,7 @@ export type AddonNotesSyncResult = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to ADDON_NOTES_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type AddonNotesSyncAutoSyncData = {
 | 
			
		||||
    courseId: number;
 | 
			
		||||
@ -266,7 +265,7 @@ declare module '@singletons/events' {
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [AddonNotesSyncProvider.AUTO_SYNCED]: AddonNotesSyncAutoSyncData;
 | 
			
		||||
        [ADDON_NOTES_AUTO_SYNCED]: AddonNotesSyncAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								src/core/features/comments/constants.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/core/features/comments/constants.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
// (C) Copyright 2015 Moodle Pty Ltd.
 | 
			
		||||
//
 | 
			
		||||
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
// you may not use this file except in compliance with the License.
 | 
			
		||||
// You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
//     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
// See the License for the specific language governing permissions and
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
 | 
			
		||||
export const CORE_COMMENTS_AUTO_SYNCED = 'core_comments_autom_synced';
 | 
			
		||||
@ -24,7 +24,6 @@ import {
 | 
			
		||||
} from '@features/comments/services/comments';
 | 
			
		||||
import {
 | 
			
		||||
    CoreCommentsSync,
 | 
			
		||||
    CoreCommentsSyncProvider,
 | 
			
		||||
} from '@features/comments/services/comments-sync';
 | 
			
		||||
import { IonContent } from '@ionic/angular';
 | 
			
		||||
import { ContextLevel, CoreConstants } from '@/core/constants';
 | 
			
		||||
@ -45,6 +44,7 @@ import { CoreAnimations } from '@components/animations';
 | 
			
		||||
import { CoreKeyboard } from '@singletons/keyboard';
 | 
			
		||||
import { CoreToasts, ToastDuration } from '@services/toasts';
 | 
			
		||||
import { CoreLoadings } from '@services/loadings';
 | 
			
		||||
import { CORE_COMMENTS_AUTO_SYNCED } from '@features/comments/constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Page that displays comments.
 | 
			
		||||
@ -94,7 +94,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
 | 
			
		||||
        this.currentUserId = CoreSites.getCurrentSiteUserId();
 | 
			
		||||
 | 
			
		||||
        // Refresh data if comments are synchronized automatically.
 | 
			
		||||
        this.syncObserver = CoreEvents.on(CoreCommentsSyncProvider.AUTO_SYNCED, (data) => {
 | 
			
		||||
        this.syncObserver = CoreEvents.on(CORE_COMMENTS_AUTO_SYNCED, (data) => {
 | 
			
		||||
            if (data.contextLevel == this.contextLevel && data.instanceId == this.instanceId &&
 | 
			
		||||
                    data.componentName == this.componentName && data.itemId == this.itemId && data.area == this.area) {
 | 
			
		||||
                // Show the sync warnings.
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
 | 
			
		||||
import { CoreCommentsDBRecord, CoreCommentsDeletedDBRecord } from './database/comments';
 | 
			
		||||
import { CoreSyncResult } from '@services/sync';
 | 
			
		||||
import { ContextLevel } from '@/core/constants';
 | 
			
		||||
import { CORE_COMMENTS_AUTO_SYNCED } from '../constants';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Service to sync omments.
 | 
			
		||||
@ -32,8 +33,6 @@ import { ContextLevel } from '@/core/constants';
 | 
			
		||||
@Injectable( { providedIn: 'root' })
 | 
			
		||||
export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsSyncResult> {
 | 
			
		||||
 | 
			
		||||
    static readonly AUTO_SYNCED = 'core_comments_autom_synced';
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super('CoreCommentsSync');
 | 
			
		||||
    }
 | 
			
		||||
@ -96,7 +95,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider<CoreCommentsS
 | 
			
		||||
 | 
			
		||||
            if (result !== undefined) {
 | 
			
		||||
                // Sync successful, send event.
 | 
			
		||||
                CoreEvents.trigger(CoreCommentsSyncProvider.AUTO_SYNCED, {
 | 
			
		||||
                CoreEvents.trigger(CORE_COMMENTS_AUTO_SYNCED, {
 | 
			
		||||
                    contextLevel: comment.contextlevel,
 | 
			
		||||
                    instanceId: comment.instanceid,
 | 
			
		||||
                    componentName: comment.component,
 | 
			
		||||
@ -329,7 +328,7 @@ export const CoreCommentsSync = makeSingleton(CoreCommentsSyncProvider);
 | 
			
		||||
export type CoreCommentsSyncResult = CoreSyncResult;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Data passed to AUTO_SYNCED event.
 | 
			
		||||
 * Data passed to CORE_COMMENTS_AUTO_SYNCED event.
 | 
			
		||||
 */
 | 
			
		||||
export type CoreCommentsSyncAutoSyncData = {
 | 
			
		||||
    contextLevel: ContextLevel;
 | 
			
		||||
@ -339,3 +338,16 @@ export type CoreCommentsSyncAutoSyncData = {
 | 
			
		||||
    area: string;
 | 
			
		||||
    warnings: string[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [CORE_COMMENTS_AUTO_SYNCED]: CoreCommentsSyncAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,6 @@ import { CoreWSExternalWarning } from '@services/ws';
 | 
			
		||||
import { makeSingleton } from '@singletons';
 | 
			
		||||
import { CoreEvents } from '@singletons/events';
 | 
			
		||||
import { CoreCommentsOffline } from './comments-offline';
 | 
			
		||||
import { CoreCommentsSyncAutoSyncData, CoreCommentsSyncProvider } from './comments-sync';
 | 
			
		||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
			
		||||
import { ContextLevel, CoreCacheUpdateFrequency } from '@/core/constants';
 | 
			
		||||
 | 
			
		||||
@ -38,7 +37,6 @@ declare module '@singletons/events' {
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [CoreCommentsProvider.REFRESH_COMMENTS_EVENT]: CoreCommentsRefreshCommentsEventData;
 | 
			
		||||
        [CoreCommentsProvider.COMMENTS_COUNT_CHANGED_EVENT]: CoreCommentsCountChangedEventData;
 | 
			
		||||
        [CoreCommentsSyncProvider.AUTO_SYNCED]: CoreCommentsSyncAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -46,7 +46,6 @@ import { CoreCourseHelper, CoreCourseModuleData, CoreCourseModuleCompletionData
 | 
			
		||||
import { CoreCourseFormatDelegate } from './format-delegate';
 | 
			
		||||
import { CoreCronDelegate } from '@services/cron';
 | 
			
		||||
import { CoreCourseLogCronHandler } from './handlers/log-cron';
 | 
			
		||||
import { CoreCourseAutoSyncData } from './sync';
 | 
			
		||||
import { CoreTagItem } from '@features/tag/services/tag';
 | 
			
		||||
import { CoreNavigationOptions, CoreNavigator } from '@services/navigator';
 | 
			
		||||
import { CoreCourseModuleDelegate } from './module-delegate';
 | 
			
		||||
@ -74,7 +73,6 @@ import {
 | 
			
		||||
    CORE_COURSE_CORE_MODULES,
 | 
			
		||||
    CORE_COURSE_PROGRESS_UPDATED_EVENT,
 | 
			
		||||
    CORE_COURSE_STEALTH_MODULES_SECTION_ID,
 | 
			
		||||
    CORE_COURSE_AUTO_SYNCED,
 | 
			
		||||
} from '../constants';
 | 
			
		||||
 | 
			
		||||
export type CoreCourseProgressUpdated = { progress: number; courseId: number };
 | 
			
		||||
@ -87,7 +85,6 @@ declare module '@singletons/events' {
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [CORE_COURSE_AUTO_SYNCED]: CoreCourseAutoSyncData;
 | 
			
		||||
        [CORE_COURSE_PROGRESS_UPDATED_EVENT]: CoreCourseProgressUpdated;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -275,3 +275,16 @@ export type CoreCourseAutoSyncData = {
 | 
			
		||||
    courseId: number;
 | 
			
		||||
    warnings: CoreWSExternalWarning[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
declare module '@singletons/events' {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Augment CoreEventsData interface with events specific to this service.
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | 
			
		||||
     */
 | 
			
		||||
    export interface CoreEventsData {
 | 
			
		||||
        [CORE_COURSE_AUTO_SYNCED]: CoreCourseAutoSyncData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -13,3 +13,5 @@
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
 | 
			
		||||
export const PARTICIPANTS_PAGE_NAME = 'participants';
 | 
			
		||||
 | 
			
		||||
export const CORE_USER_AUTO_SYNCED = 'core_user_autom_synced';
 | 
			
		||||
 | 
			
		||||
@ -28,8 +28,6 @@ import { CoreUser } from './user';
 | 
			
		||||
@Injectable({ providedIn: 'root' })
 | 
			
		||||
export class CoreUserSyncProvider extends CoreSyncBaseProvider<string[]> {
 | 
			
		||||
 | 
			
		||||
    static readonly AUTO_SYNCED = 'core_user_autom_synced';
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super('CoreUserSync');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user