diff --git a/src/addons/mod/assign/services/assign-sync.ts b/src/addons/mod/assign/services/assign-sync.ts index 063e3f1cd..22b3c7c47 100644 --- a/src/addons/mod/assign/services/assign-sync.ts +++ b/src/addons/mod/assign/services/assign-sync.ts @@ -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; + } + +} diff --git a/src/addons/mod/assign/services/assign.ts b/src/addons/mod/assign/services/assign.ts index 5d2e05909..a5a4caf68 100644 --- a/src/addons/mod/assign/services/assign.ts +++ b/src/addons/mod/assign/services/assign.ts @@ -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; } } diff --git a/src/addons/mod/choice/services/choice-sync.ts b/src/addons/mod/choice/services/choice-sync.ts index 16adaa888..3d2f7b7d9 100644 --- a/src/addons/mod/choice/services/choice-sync.ts +++ b/src/addons/mod/choice/services/choice-sync.ts @@ -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; diff --git a/src/addons/mod/choice/services/choice.ts b/src/addons/mod/choice/services/choice.ts index 58f73a1a7..489858904 100644 --- a/src/addons/mod/choice/services/choice.ts +++ b/src/addons/mod/choice/services/choice.ts @@ -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; - } - -} diff --git a/src/addons/mod/data/services/data-sync.ts b/src/addons/mod/data/services/data-sync.ts index 26ba459d0..f940aae39 100644 --- a/src/addons/mod/data/services/data-sync.ts +++ b/src/addons/mod/data/services/data-sync.ts @@ -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; + } +} diff --git a/src/addons/mod/data/services/data.ts b/src/addons/mod/data/services/data.ts index 27b7f5a87..aab92f797 100644 --- a/src/addons/mod/data/services/data.ts +++ b/src/addons/mod/data/services/data.ts @@ -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; } } diff --git a/src/addons/mod/feedback/components/index/index.ts b/src/addons/mod/feedback/components/index/index.ts index c76f6b961..268ad383c 100644 --- a/src/addons/mod/feedback/components/index/index.ts +++ b/src/addons/mod/feedback/components/index/index.ts @@ -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( diff --git a/src/addons/mod/feedback/constants.ts b/src/addons/mod/feedback/constants.ts index 15b724430..efd3cc0f7 100644 --- a/src/addons/mod/feedback/constants.ts +++ b/src/addons/mod/feedback/constants.ts @@ -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; /** diff --git a/src/addons/mod/feedback/services/feedback-sync.ts b/src/addons/mod/feedback/services/feedback-sync.ts index aeaf4d6ab..636805023 100644 --- a/src/addons/mod/feedback/services/feedback-sync.ts +++ b/src/addons/mod/feedback/services/feedback-sync.ts @@ -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 { - 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; + } + +} diff --git a/src/addons/mod/feedback/services/feedback.ts b/src/addons/mod/feedback/services/feedback.ts index 8ba4bab55..abd261725 100644 --- a/src/addons/mod/feedback/services/feedback.ts +++ b/src/addons/mod/feedback/services/feedback.ts @@ -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; } } diff --git a/src/addons/mod/forum/services/forum-sync.ts b/src/addons/mod/forum/services/forum-sync.ts index d7936d0a3..cd3f6dbc1 100644 --- a/src/addons/mod/forum/services/forum-sync.ts +++ b/src/addons/mod/forum/services/forum-sync.ts @@ -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; diff --git a/src/addons/mod/glossary/components/index/index.ts b/src/addons/mod/glossary/components/index/index.ts index 5c71d84cd..6e9a4df07 100644 --- a/src/addons/mod/glossary/components/index/index.ts +++ b/src/addons/mod/glossary/components/index/index.ts @@ -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'; diff --git a/src/addons/mod/glossary/constants.ts b/src/addons/mod/glossary/constants.ts index e7eae3be2..c51aad210 100644 --- a/src/addons/mod/glossary/constants.ts +++ b/src/addons/mod/glossary/constants.ts @@ -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; diff --git a/src/addons/mod/glossary/services/glossary-sync.ts b/src/addons/mod/glossary/services/glossary-sync.ts index 61a6b1f9f..3155ca28a 100644 --- a/src/addons/mod/glossary/services/glossary-sync.ts +++ b/src/addons/mod/glossary/services/glossary-sync.ts @@ -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. diff --git a/src/addons/mod/h5pactivity/services/h5pactivity-sync.ts b/src/addons/mod/h5pactivity/services/h5pactivity-sync.ts index 8a2c3361b..b719ddd27 100644 --- a/src/addons/mod/h5pactivity/services/h5pactivity-sync.ts +++ b/src/addons/mod/h5pactivity/services/h5pactivity-sync.ts @@ -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; + } + +} diff --git a/src/addons/mod/h5pactivity/services/h5pactivity.ts b/src/addons/mod/h5pactivity/services/h5pactivity.ts index 77a9cc4d9..68ebb7ab3 100644 --- a/src/addons/mod/h5pactivity/services/h5pactivity.ts +++ b/src/addons/mod/h5pactivity/services/h5pactivity.ts @@ -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. */ diff --git a/src/addons/mod/lesson/services/lesson-sync.ts b/src/addons/mod/lesson/services/lesson-sync.ts index 04db999a1..304eb227f 100644 --- a/src/addons/mod/lesson/services/lesson-sync.ts +++ b/src/addons/mod/lesson/services/lesson-sync.ts @@ -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; + } + +} diff --git a/src/addons/mod/lesson/services/lesson.ts b/src/addons/mod/lesson/services/lesson.ts index 5ccb9947a..8628d7e7c 100644 --- a/src/addons/mod/lesson/services/lesson.ts +++ b/src/addons/mod/lesson/services/lesson.ts @@ -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; } } diff --git a/src/addons/mod/quiz/services/quiz-sync.ts b/src/addons/mod/quiz/services/quiz-sync.ts index dd36abfb2..370a8c81f 100644 --- a/src/addons/mod/quiz/services/quiz-sync.ts +++ b/src/addons/mod/quiz/services/quiz-sync.ts @@ -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; + } + +} diff --git a/src/addons/mod/quiz/services/quiz.ts b/src/addons/mod/quiz/services/quiz.ts index 4de507458..77891551c 100644 --- a/src/addons/mod/quiz/services/quiz.ts +++ b/src/addons/mod/quiz/services/quiz.ts @@ -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; } } diff --git a/src/addons/mod/scorm/services/scorm-sync.ts b/src/addons/mod/scorm/services/scorm-sync.ts index 3c8ae7bb7..02e53d0fe 100644 --- a/src/addons/mod/scorm/services/scorm-sync.ts +++ b/src/addons/mod/scorm/services/scorm-sync.ts @@ -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; + } + +} diff --git a/src/addons/mod/scorm/services/scorm.ts b/src/addons/mod/scorm/services/scorm.ts index 3f3cfcbf0..06ea99b1e 100644 --- a/src/addons/mod/scorm/services/scorm.ts +++ b/src/addons/mod/scorm/services/scorm.ts @@ -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; } } diff --git a/src/addons/mod/survey/services/survey-sync.ts b/src/addons/mod/survey/services/survey-sync.ts index 54a793fe6..ff8d8d208 100644 --- a/src/addons/mod/survey/services/survey-sync.ts +++ b/src/addons/mod/survey/services/survey-sync.ts @@ -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; diff --git a/src/addons/mod/wiki/services/wiki-sync.ts b/src/addons/mod/wiki/services/wiki-sync.ts index c79f614f9..79ab18dbd 100644 --- a/src/addons/mod/wiki/services/wiki-sync.ts +++ b/src/addons/mod/wiki/services/wiki-sync.ts @@ -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; + } + +} diff --git a/src/addons/mod/wiki/services/wiki.ts b/src/addons/mod/wiki/services/wiki.ts index 4940a5911..af5842a4d 100644 --- a/src/addons/mod/wiki/services/wiki.ts +++ b/src/addons/mod/wiki/services/wiki.ts @@ -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; } } diff --git a/src/addons/mod/workshop/services/workshop-sync.ts b/src/addons/mod/workshop/services/workshop-sync.ts index 645a3fa38..d7c7f9420 100644 --- a/src/addons/mod/workshop/services/workshop-sync.ts +++ b/src/addons/mod/workshop/services/workshop-sync.ts @@ -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; + } +} diff --git a/src/addons/mod/workshop/services/workshop.ts b/src/addons/mod/workshop/services/workshop.ts index 15084fd42..da97e87e5 100644 --- a/src/addons/mod/workshop/services/workshop.ts +++ b/src/addons/mod/workshop/services/workshop.ts @@ -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; diff --git a/src/addons/notes/pages/list/list.ts b/src/addons/notes/pages/list/list.ts index ec187befa..280f26e5b 100644 --- a/src/addons/notes/pages/list/list.ts +++ b/src/addons/notes/pages/list/list.ts @@ -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); diff --git a/src/addons/notes/services/constants.ts b/src/addons/notes/services/constants.ts new file mode 100644 index 000000000..1878416be --- /dev/null +++ b/src/addons/notes/services/constants.ts @@ -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'; diff --git a/src/addons/notes/services/notes-sync.ts b/src/addons/notes/services/notes-sync.ts index c60a6f431..b02557293 100644 --- a/src/addons/notes/services/notes-sync.ts +++ b/src/addons/notes/services/notes-sync.ts @@ -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 { - static readonly AUTO_SYNCED = 'addon_notes_autom_synced'; - constructor() { super('AddonNotesSync'); } @@ -80,7 +79,7 @@ export class AddonNotesSyncProvider extends CoreSyncBaseProvider { + 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. diff --git a/src/core/features/comments/services/comments-sync.ts b/src/core/features/comments/services/comments-sync.ts index 2aa32d833..649d375da 100644 --- a/src/core/features/comments/services/comments-sync.ts +++ b/src/core/features/comments/services/comments-sync.ts @@ -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 { - static readonly AUTO_SYNCED = 'core_comments_autom_synced'; - constructor() { super('CoreCommentsSync'); } @@ -96,7 +95,7 @@ export class CoreCommentsSyncProvider extends CoreSyncBaseProvider { - static readonly AUTO_SYNCED = 'core_user_autom_synced'; - constructor() { super('CoreUserSync'); }