forked from CIT/Vmeda.Online
		
	MOBILE-4616 forum: Move forum constants to a file
This commit is contained in:
		
							parent
							
								
									94743ed700
								
							
						
					
					
						commit
						67cae258f6
					
				| @ -22,10 +22,10 @@ import { | |||||||
|     AddonModForumCanAddDiscussion, |     AddonModForumCanAddDiscussion, | ||||||
|     AddonModForumData, |     AddonModForumData, | ||||||
|     AddonModForumDiscussion, |     AddonModForumDiscussion, | ||||||
|     AddonModForumProvider, |  | ||||||
|     AddonModForumSortOrder, |     AddonModForumSortOrder, | ||||||
| } from '../services/forum'; | } from '../services/forum'; | ||||||
| import { AddonModForumOffline, AddonModForumOfflineDiscussion } from '../services/forum-offline'; | import { AddonModForumOffline, AddonModForumOfflineDiscussion } from '../services/forum-offline'; | ||||||
|  | import { ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE } from '../constants'; | ||||||
| 
 | 
 | ||||||
| export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource<AddonModForumDiscussionItem> { | export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource<AddonModForumDiscussionItem> { | ||||||
| 
 | 
 | ||||||
| @ -136,7 +136,7 @@ export class AddonModForumDiscussionsSource extends CoreRoutedItemsManagerSource | |||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     getPageLength(): number { |     getPageLength(): number { | ||||||
|         return AddonModForumProvider.DISCUSSIONS_PER_PAGE; |         return ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -17,7 +17,8 @@ import { CoreSites } from '@services/sites'; | |||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { PopoverController } from '@singletons'; | import { PopoverController } from '@singletons'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| import { AddonModForum, AddonModForumDiscussion, AddonModForumProvider } from '../../services/forum'; | import { AddonModForum, AddonModForumDiscussion } from '../../services/forum'; | ||||||
|  | import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * This component is meant to display a popover with the discussion options. |  * This component is meant to display a popover with the discussion options. | ||||||
| @ -71,7 +72,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { | |||||||
|                 locked: response.locked, |                 locked: response.locked, | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|             CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); |             CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); | ||||||
|             PopoverController.dismiss({ action: 'lock', value: locked }); |             PopoverController.dismiss({ action: 'lock', value: locked }); | ||||||
|             CoreDomUtils.showToast('addon.mod_forum.lockupdated', true); |             CoreDomUtils.showToast('addon.mod_forum.lockupdated', true); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
| @ -100,7 +101,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { | |||||||
|                 pinned: pinned, |                 pinned: pinned, | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|             CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); |             CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); | ||||||
|             PopoverController.dismiss({ action: 'pin', value: pinned }); |             PopoverController.dismiss({ action: 'pin', value: pinned }); | ||||||
|             CoreDomUtils.showToast('addon.mod_forum.pinupdated', true); |             CoreDomUtils.showToast('addon.mod_forum.pinupdated', true); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
| @ -129,7 +130,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { | |||||||
|                 starred: starred, |                 starred: starred, | ||||||
|             }; |             }; | ||||||
| 
 | 
 | ||||||
|             CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); |             CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); | ||||||
|             PopoverController.dismiss({ action: 'star', value: starred }); |             PopoverController.dismiss({ action: 'star', value: starred }); | ||||||
|             CoreDomUtils.showToast('addon.mod_forum.favouriteupdated', true); |             CoreDomUtils.showToast('addon.mod_forum.favouriteupdated', true); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
|  | |||||||
| @ -20,7 +20,6 @@ import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/ | |||||||
| import { | import { | ||||||
|     AddonModForum, |     AddonModForum, | ||||||
|     AddonModForumData, |     AddonModForumData, | ||||||
|     AddonModForumProvider, |  | ||||||
|     AddonModForumSortOrder, |     AddonModForumSortOrder, | ||||||
|     AddonModForumDiscussion, |     AddonModForumDiscussion, | ||||||
|     AddonModForumNewDiscussionData, |     AddonModForumNewDiscussionData, | ||||||
| @ -35,7 +34,6 @@ import { CoreEvents, CoreEventObserver } from '@singletons/events'; | |||||||
| import { | import { | ||||||
|     AddonModForumAutoSyncData, |     AddonModForumAutoSyncData, | ||||||
|     AddonModForumManualSyncData, |     AddonModForumManualSyncData, | ||||||
|     AddonModForumSyncProvider, |  | ||||||
|     AddonModForumSyncResult, |     AddonModForumSyncResult, | ||||||
| } from '@addons/mod/forum/services/forum-sync'; | } from '@addons/mod/forum/services/forum-sync'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| @ -46,7 +44,6 @@ import { CoreSplitViewComponent } from '@components/split-view/split-view'; | |||||||
| import { AddonModForumDiscussionOptionsMenuComponent } from '../discussion-options-menu/discussion-options-menu'; | import { AddonModForumDiscussionOptionsMenuComponent } from '../discussion-options-menu/discussion-options-menu'; | ||||||
| import { CoreScreen } from '@services/screen'; | import { CoreScreen } from '@services/screen'; | ||||||
| import { AddonModForumPrefetchHandler } from '../../services/handlers/prefetch'; | import { AddonModForumPrefetchHandler } from '../../services/handlers/prefetch'; | ||||||
| import { AddonModForumModuleHandlerService } from '../../services/handlers/module'; |  | ||||||
| import { CoreRatingProvider } from '@features/rating/services/rating'; | import { CoreRatingProvider } from '@features/rating/services/rating'; | ||||||
| import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync'; | import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync'; | ||||||
| import { CoreRatingOffline } from '@features/rating/services/rating-offline'; | import { CoreRatingOffline } from '@features/rating/services/rating-offline'; | ||||||
| @ -56,7 +53,17 @@ import { CoreListItemsManager } from '@classes/items-management/list-items-manag | |||||||
| import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker'; | import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker'; | ||||||
| import { CorePromisedValue } from '@classes/promised-value'; | import { CorePromisedValue } from '@classes/promised-value'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/constants'; | import { | ||||||
|  |     ADDON_MOD_FORUM_AUTO_SYNCED, | ||||||
|  |     ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, | ||||||
|  |     ADDON_MOD_FORUM_COMPONENT, | ||||||
|  |     ADDON_MOD_FORUM_MANUAL_SYNCED, | ||||||
|  |     ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT, | ||||||
|  |     ADDON_MOD_FORUM_PAGE_NAME, | ||||||
|  |     ADDON_MOD_FORUM_PREFERENCE_SORTORDER, | ||||||
|  |     ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT, | ||||||
|  |     ADDON_MOD_FORUM_SEARCH_PAGE_NAME, | ||||||
|  | } from '@addons/mod/forum/constants'; | ||||||
| import { CoreSearchGlobalSearch } from '@features/search/services/global-search'; | import { CoreSearchGlobalSearch } from '@features/search/services/global-search'; | ||||||
| /** | /** | ||||||
|  * Component that displays a forum entry page. |  * Component that displays a forum entry page. | ||||||
| @ -70,7 +77,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
| 
 | 
 | ||||||
|     @ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent; |     @ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent; | ||||||
| 
 | 
 | ||||||
|     component = AddonModForumProvider.COMPONENT; |     component = ADDON_MOD_FORUM_COMPONENT; | ||||||
|     pluginName = 'forum'; |     pluginName = 'forum'; | ||||||
|     descriptionNote?: string; |     descriptionNote?: string; | ||||||
|     promisedDiscussions: CorePromisedValue<AddonModForumDiscussionsManager>; |     promisedDiscussions: CorePromisedValue<AddonModForumDiscussionsManager>; | ||||||
| @ -87,7 +94,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|     showSearch = false; |     showSearch = false; | ||||||
| 
 | 
 | ||||||
|     protected fetchContentDefaultError = 'addon.mod_forum.errorgetforum'; |     protected fetchContentDefaultError = 'addon.mod_forum.errorgetforum'; | ||||||
|     protected syncEventName = AddonModForumSyncProvider.AUTO_SYNCED; |     protected syncEventName = ADDON_MOD_FORUM_AUTO_SYNCED; | ||||||
|     protected syncManualObserver?: CoreEventObserver; // It will observe the sync manual event.
 |     protected syncManualObserver?: CoreEventObserver; // It will observe the sync manual event.
 | ||||||
|     protected replyObserver?: CoreEventObserver; |     protected replyObserver?: CoreEventObserver; | ||||||
|     protected newDiscObserver?: CoreEventObserver; |     protected newDiscObserver?: CoreEventObserver; | ||||||
| @ -188,7 +195,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|         // Initialize discussions manager.
 |         // Initialize discussions manager.
 | ||||||
|         const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource( |         const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource( | ||||||
|             AddonModForumDiscussionsSource, |             AddonModForumDiscussionsSource, | ||||||
|             [this.courseId, this.module.id, this.courseContentsPage ? `${AddonModForumModuleHandlerService.PAGE_NAME}/` : ''], |             [this.courseId, this.module.id, this.courseContentsPage ? `${ADDON_MOD_FORUM_PAGE_NAME}/` : ''], | ||||||
|         ); |         ); | ||||||
| 
 | 
 | ||||||
|         this.sourceUnsubscribe = source.addListener({ |         this.sourceUnsubscribe = source.addListener({ | ||||||
| @ -229,20 +236,20 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|         this.promisedDiscussions.resolve(new AddonModForumDiscussionsManager(source, this)); |         this.promisedDiscussions.resolve(new AddonModForumDiscussionsManager(source, this)); | ||||||
| 
 | 
 | ||||||
|         // Refresh data if this forum discussion is synchronized from discussions list.
 |         // Refresh data if this forum discussion is synchronized from discussions list.
 | ||||||
|         this.syncManualObserver = CoreEvents.on(AddonModForumSyncProvider.MANUAL_SYNCED, (data) => { |         this.syncManualObserver = CoreEvents.on(ADDON_MOD_FORUM_MANUAL_SYNCED, (data) => { | ||||||
|             this.autoSyncEventReceived(data); |             this.autoSyncEventReceived(data); | ||||||
|         }, this.siteId); |         }, this.siteId); | ||||||
| 
 | 
 | ||||||
|         // Listen for discussions added. When a discussion is added, we reload the data.
 |         // Listen for discussions added. When a discussion is added, we reload the data.
 | ||||||
|         this.newDiscObserver = CoreEvents.on( |         this.newDiscObserver = CoreEvents.on( | ||||||
|             AddonModForumProvider.NEW_DISCUSSION_EVENT, |             ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT, | ||||||
|             (data) => this.eventReceived(true, data), |             (data) => this.eventReceived(true, data), | ||||||
|         ); |         ); | ||||||
|         this.replyObserver = CoreEvents.on( |         this.replyObserver = CoreEvents.on( | ||||||
|             AddonModForumProvider.REPLY_DISCUSSION_EVENT, |             ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT, | ||||||
|             (data) => this.eventReceived(false, data), |             (data) => this.eventReceived(false, data), | ||||||
|         ); |         ); | ||||||
|         this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => { |         this.changeDiscObserver = CoreEvents.on(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data => { | ||||||
|             if (!this.forum) { |             if (!this.forum) { | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| @ -419,7 +426,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
| 
 | 
 | ||||||
|             if (updated) { |             if (updated) { | ||||||
|                 // Sync successful, send event.
 |                 // Sync successful, send event.
 | ||||||
|                 CoreEvents.trigger(AddonModForumSyncProvider.MANUAL_SYNCED, { |                 CoreEvents.trigger(ADDON_MOD_FORUM_MANUAL_SYNCED, { | ||||||
|                     forumId: forum.id, |                     forumId: forum.id, | ||||||
|                     userId: CoreSites.getCurrentSiteUserId(), |                     userId: CoreSites.getCurrentSiteUserId(), | ||||||
|                     source: 'index', |                     source: 'index', | ||||||
| @ -502,7 +509,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (this.sortingAvailable) { |         if (this.sortingAvailable) { | ||||||
|             promises.push(CoreUser.invalidateUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER)); |             promises.push(CoreUser.invalidateUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         await Promise.all(promises); |         await Promise.all(promises); | ||||||
| @ -602,7 +609,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|             this.discussions.getSource().setDirty(true); |             this.discussions.getSource().setDirty(true); | ||||||
| 
 | 
 | ||||||
|             try { |             try { | ||||||
|                 await CoreUser.setUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER, sortOrder.value.toFixed(0)); |                 await CoreUser.setUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER, sortOrder.value.toFixed(0)); | ||||||
|                 await this.showLoadingAndFetch(); |                 await this.showLoadingAndFetch(); | ||||||
|             } catch (error) { |             } catch (error) { | ||||||
|                 CoreDomUtils.showErrorModalDefault(error, 'Error updating preference.'); |                 CoreDomUtils.showErrorModalDefault(error, 'Error updating preference.'); | ||||||
|  | |||||||
| @ -34,7 +34,6 @@ import { | |||||||
|     AddonModForumData, |     AddonModForumData, | ||||||
|     AddonModForumDiscussion, |     AddonModForumDiscussion, | ||||||
|     AddonModForumPost, |     AddonModForumPost, | ||||||
|     AddonModForumProvider, |  | ||||||
|     AddonModForumPostFormData, |     AddonModForumPostFormData, | ||||||
| } from '../../services/forum'; | } from '../../services/forum'; | ||||||
| import { CoreTag } from '@features/tag/services/tag'; | import { CoreTag } from '@features/tag/services/tag'; | ||||||
| @ -53,6 +52,7 @@ import { CoreFileEntry } from '@services/file-helper'; | |||||||
| import { AddonModForumSharedPostFormData } from '../../pages/discussion/discussion'; | import { AddonModForumSharedPostFormData } from '../../pages/discussion/discussion'; | ||||||
| import { CoreDom } from '@singletons/dom'; | import { CoreDom } from '@singletons/dom'; | ||||||
| import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; | import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; | ||||||
|  | import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, ADDON_MOD_FORUM_COMPONENT } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Components that shows a discussion post, its attachments and the action buttons allowed (reply, etc.). |  * Components that shows a discussion post, its attachments and the action buttons allowed (reply, etc.). | ||||||
| @ -162,7 +162,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges | |||||||
|                 }; |                 }; | ||||||
| 
 | 
 | ||||||
|                 CoreEvents.trigger( |                 CoreEvents.trigger( | ||||||
|                     AddonModForumProvider.CHANGE_DISCUSSION_EVENT, |                     ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, | ||||||
|                     data, |                     data, | ||||||
|                     CoreSites.getCurrentSiteId(), |                     CoreSites.getCurrentSiteId(), | ||||||
|                 ); |                 ); | ||||||
| @ -307,7 +307,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges | |||||||
|             await this.confirmDiscard(); |             await this.confirmDiscard(); | ||||||
| 
 | 
 | ||||||
|             this.formData.syncId = AddonModForumSync.getDiscussionSyncId(this.discussionId); |             this.formData.syncId = AddonModForumSync.getDiscussionSyncId(this.discussionId); | ||||||
|             CoreSync.blockOperation(AddonModForumProvider.COMPONENT, this.formData.syncId); |             CoreSync.blockOperation(ADDON_MOD_FORUM_COMPONENT, this.formData.syncId); | ||||||
| 
 | 
 | ||||||
|             this.setFormData( |             this.setFormData( | ||||||
|                 this.post.parentid, |                 this.post.parentid, | ||||||
| @ -546,7 +546,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         CoreSync.unblockOperation(AddonModForumProvider.COMPONENT, this.formData.syncId); |         CoreSync.unblockOperation(ADDON_MOD_FORUM_COMPONENT, this.formData.syncId); | ||||||
|         delete this.formData.syncId; |         delete this.formData.syncId; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -12,4 +12,30 @@ | |||||||
| // See the License for the specific language governing permissions and
 | // See the License for the specific language governing permissions and
 | ||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
|  | export const ADDON_MOD_FORUM_PAGE_NAME = 'mod_forum'; | ||||||
| export const ADDON_MOD_FORUM_SEARCH_PAGE_NAME = 'forum/search'; | export const ADDON_MOD_FORUM_SEARCH_PAGE_NAME = 'forum/search'; | ||||||
|  | 
 | ||||||
|  | export const ADDON_MOD_FORUM_COMPONENT = 'mmaModForum'; | ||||||
|  | 
 | ||||||
|  | export const ADDON_MOD_FORUM_AUTO_SYNCED = 'addon_mod_forum_autom_synced'; | ||||||
|  | export const ADDON_MOD_FORUM_MANUAL_SYNCED = 'addon_mod_forum_manual_synced'; | ||||||
|  | 
 | ||||||
|  | export const ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE = 10; // Max of discussions per page.
 | ||||||
|  | export const ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT = 'addon_mod_forum_new_discussion'; | ||||||
|  | export const ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT = 'addon_mod_forum_reply_discussion'; | ||||||
|  | export const ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT = 'addon_mod_forum_change_discussion_status'; | ||||||
|  | export const ADDON_MOD_FORUM_MARK_READ_EVENT = 'addon_mod_forum_mark_read'; | ||||||
|  | 
 | ||||||
|  | export const ADDON_MOD_FORUM_PREFERENCE_SORTORDER = 'forum_discussionlistsortorder'; | ||||||
|  | 
 | ||||||
|  | export const enum AddonModForumSortorder { | ||||||
|  |     LASTPOST_DESC = 1, | ||||||
|  |     LASTPOST_ASC = 2, | ||||||
|  |     CREATED_DESC = 3, | ||||||
|  |     CREATED_ASC = 4, | ||||||
|  |     REPLIES_DESC = 5, | ||||||
|  |     REPLIES_ASC = 6, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export const ADDON_MOD_FORUM_ALL_PARTICIPANTS = -1; | ||||||
|  | export const ADDON_MOD_FORUM_ALL_GROUPS = -2; | ||||||
|  | |||||||
| @ -36,4 +36,4 @@ const routes: Routes = [{ | |||||||
|         AddonModForumDiscussionPage, |         AddonModForumDiscussionPage, | ||||||
|     ], |     ], | ||||||
| }) | }) | ||||||
| export class AddonModForumDiscussionLazyModule {} | export default class AddonModForumDiscussionLazyModule {} | ||||||
|  | |||||||
| @ -29,15 +29,15 @@ const mobileRoutes: Routes = [ | |||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         path: ':courseId/:cmId/new/:timeCreated', |         path: ':courseId/:cmId/new/:timeCreated', | ||||||
|         loadChildren: () => import('./forum-new-discussion-lazy.module').then(m => m.AddonModForumNewDiscussionLazyModule), |         loadChildren: () => import('./forum-new-discussion-lazy.module'), | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         path: ':courseId/:cmId/:discussionId', |         path: ':courseId/:cmId/:discussionId', | ||||||
|         loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule), |         loadChildren: () => import('./forum-discussion-lazy.module'), | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         path: 'discussion/:discussionId', // Only for discussion link handling.
 |         path: 'discussion/:discussionId', // Only for discussion link handling.
 | ||||||
|         loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule), |         loadChildren: () => import('./forum-discussion-lazy.module'), | ||||||
|     }, |     }, | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
| @ -48,11 +48,11 @@ const tabletRoutes: Routes = [ | |||||||
|         children: [ |         children: [ | ||||||
|             { |             { | ||||||
|                 path: 'new/:timeCreated', |                 path: 'new/:timeCreated', | ||||||
|                 loadChildren: () => import('./forum-new-discussion-lazy.module').then(m => m.AddonModForumNewDiscussionLazyModule), |                 loadChildren: () => import('./forum-new-discussion-lazy.module'), | ||||||
|             }, |             }, | ||||||
|             { |             { | ||||||
|                 path: ':discussionId', |                 path: ':discussionId', | ||||||
|                 loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule), |                 loadChildren: () => import('./forum-discussion-lazy.module'), | ||||||
|             }, |             }, | ||||||
|         ], |         ], | ||||||
|     }, |     }, | ||||||
| @ -73,4 +73,4 @@ const routes: Routes = [ | |||||||
|         AddonModForumIndexPage, |         AddonModForumIndexPage, | ||||||
|     ], |     ], | ||||||
| }) | }) | ||||||
| export class AddonModForumLazyModule {} | export default class AddonModForumLazyModule {} | ||||||
|  | |||||||
| @ -38,4 +38,4 @@ const routes: Routes = [{ | |||||||
|         AddonModForumNewDiscussionPage, |         AddonModForumNewDiscussionPage, | ||||||
|     ], |     ], | ||||||
| }) | }) | ||||||
| export class AddonModForumNewDiscussionLazyModule {} | export default class AddonModForumNewDiscussionLazyModule {} | ||||||
|  | |||||||
| @ -35,4 +35,4 @@ const routes: Routes = [{ | |||||||
|         AddonModForumSearchPage, |         AddonModForumSearchPage, | ||||||
|     ], |     ], | ||||||
| }) | }) | ||||||
| export class AddonModForumSearchLazyModule {} | export default class AddonModForumSearchLazyModule {} | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg | |||||||
| import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; | import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; | ||||||
| import { CoreScreen } from '@services/screen'; | import { CoreScreen } from '@services/screen'; | ||||||
| 
 | 
 | ||||||
| import { AddonModForumModuleHandler, AddonModForumModuleHandlerService } from './services/handlers/module'; | import { AddonModForumModuleHandler } from './services/handlers/module'; | ||||||
| import { SITE_SCHEMA } from './services/database/offline'; | import { SITE_SCHEMA } from './services/database/offline'; | ||||||
| import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | ||||||
| import { AddonModForumPrefetchHandler } from './services/handlers/prefetch'; | import { AddonModForumPrefetchHandler } from './services/handlers/prefetch'; | ||||||
| @ -37,36 +37,35 @@ import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate'; | |||||||
| import { AddonModForumTagAreaHandler } from './services/handlers/tag-area'; | import { AddonModForumTagAreaHandler } from './services/handlers/tag-area'; | ||||||
| import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate'; | import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate'; | ||||||
| import { AddonModForumPushClickHandler } from './services/handlers/push-click'; | import { AddonModForumPushClickHandler } from './services/handlers/push-click'; | ||||||
| import { AddonModForumProvider } from './services/forum'; |  | ||||||
| import { COURSE_CONTENTS_PATH } from '@features/course/course.module'; | import { COURSE_CONTENTS_PATH } from '@features/course/course.module'; | ||||||
| import { CoreCourseHelper } from '@features/course/services/course-helper'; | import { CoreCourseHelper } from '@features/course/services/course-helper'; | ||||||
| import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from './constants'; | import { ADDON_MOD_FORUM_COMPONENT, ADDON_MOD_FORUM_PAGE_NAME, ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from './constants'; | ||||||
| 
 | 
 | ||||||
| const mainMenuRoutes: Routes = [ | const mainMenuRoutes: Routes = [ | ||||||
|     { |     { | ||||||
|         path: ADDON_MOD_FORUM_SEARCH_PAGE_NAME, |         path: ADDON_MOD_FORUM_SEARCH_PAGE_NAME, | ||||||
|         loadChildren: () => import('./forum-search-lazy.module').then(m => m.AddonModForumSearchLazyModule), |         loadChildren: () => import('./forum-search-lazy.module'), | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         path: `${AddonModForumModuleHandlerService.PAGE_NAME}/discussion/:discussionId`, |         path: `${ADDON_MOD_FORUM_PAGE_NAME}/discussion/:discussionId`, | ||||||
|         loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule), |         loadChildren: () => import('./forum-discussion-lazy.module'), | ||||||
|         data: { swipeEnabled: false }, |         data: { swipeEnabled: false }, | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|         path: AddonModForumModuleHandlerService.PAGE_NAME, |         path: ADDON_MOD_FORUM_PAGE_NAME, | ||||||
|         loadChildren: () => import('./forum-lazy.module').then(m => m.AddonModForumLazyModule), |         loadChildren: () => import('./forum-lazy.module'), | ||||||
|     }, |     }, | ||||||
|     ...conditionalRoutes( |     ...conditionalRoutes( | ||||||
|         [ |         [ | ||||||
|             { |             { | ||||||
|                 path: `${COURSE_CONTENTS_PATH}/${AddonModForumModuleHandlerService.PAGE_NAME}/new/:timeCreated`, |                 path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/new/:timeCreated`, | ||||||
|                 loadChildren: () => import('./forum-new-discussion-lazy.module').then(m => m.AddonModForumNewDiscussionLazyModule), |                 loadChildren: () => import('./forum-new-discussion-lazy.module'), | ||||||
|                 data: { discussionsPathPrefix: `${AddonModForumModuleHandlerService.PAGE_NAME}/` }, |                 data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, | ||||||
|             }, |             }, | ||||||
|             { |             { | ||||||
|                 path: `${COURSE_CONTENTS_PATH}/${AddonModForumModuleHandlerService.PAGE_NAME}/:discussionId`, |                 path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/:discussionId`, | ||||||
|                 loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule), |                 loadChildren: () => import('./forum-discussion-lazy.module'), | ||||||
|                 data: { discussionsPathPrefix: `${AddonModForumModuleHandlerService.PAGE_NAME}/` }, |                 data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, | ||||||
|             }, |             }, | ||||||
|         ], |         ], | ||||||
|         () => CoreScreen.isMobile, |         () => CoreScreen.isMobile, | ||||||
| @ -77,14 +76,14 @@ const mainMenuRoutes: Routes = [ | |||||||
| const courseContentsRoutes: Routes = conditionalRoutes( | const courseContentsRoutes: Routes = conditionalRoutes( | ||||||
|     [ |     [ | ||||||
|         { |         { | ||||||
|             path: `${AddonModForumModuleHandlerService.PAGE_NAME}/new/:timeCreated`, |             path: `${ADDON_MOD_FORUM_PAGE_NAME}/new/:timeCreated`, | ||||||
|             loadChildren: () => import('./forum-new-discussion-lazy.module').then(m => m.AddonModForumNewDiscussionLazyModule), |             loadChildren: () => import('./forum-new-discussion-lazy.module'), | ||||||
|             data: { discussionsPathPrefix: `${AddonModForumModuleHandlerService.PAGE_NAME}/` }, |             data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|             path: `${AddonModForumModuleHandlerService.PAGE_NAME}/:discussionId`, |             path: `${ADDON_MOD_FORUM_PAGE_NAME}/:discussionId`, | ||||||
|             loadChildren: () => import('./forum-discussion-lazy.module').then(m => m.AddonModForumDiscussionLazyModule), |             loadChildren: () => import('./forum-discussion-lazy.module'), | ||||||
|             data: { discussionsPathPrefix: `${AddonModForumModuleHandlerService.PAGE_NAME}/` }, |             data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, | ||||||
|         }, |         }, | ||||||
|     ], |     ], | ||||||
|     () => CoreScreen.isTablet, |     () => CoreScreen.isTablet, | ||||||
| @ -115,7 +114,7 @@ const courseContentsRoutes: Routes = conditionalRoutes( | |||||||
|                 CoreTagAreaDelegate.registerHandler(AddonModForumTagAreaHandler.instance); |                 CoreTagAreaDelegate.registerHandler(AddonModForumTagAreaHandler.instance); | ||||||
|                 CorePushNotificationsDelegate.registerClickHandler(AddonModForumPushClickHandler.instance); |                 CorePushNotificationsDelegate.registerClickHandler(AddonModForumPushClickHandler.instance); | ||||||
| 
 | 
 | ||||||
|                 CoreCourseHelper.registerModuleReminderClick(AddonModForumProvider.COMPONENT); |                 CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_FORUM_COMPONENT); | ||||||
|             }, |             }, | ||||||
|         }, |         }, | ||||||
|     ], |     ], | ||||||
|  | |||||||
| @ -42,15 +42,22 @@ import { | |||||||
|     AddonModForumData, |     AddonModForumData, | ||||||
|     AddonModForumDiscussion, |     AddonModForumDiscussion, | ||||||
|     AddonModForumPost, |     AddonModForumPost, | ||||||
|     AddonModForumProvider, |  | ||||||
|     AddonModForumPostFormData, |     AddonModForumPostFormData, | ||||||
|     AddonModForumChangeDiscussionData, |     AddonModForumChangeDiscussionData, | ||||||
|     AddonModForumReplyDiscussionData, |     AddonModForumReplyDiscussionData, | ||||||
| } from '../../services/forum'; | } from '../../services/forum'; | ||||||
| import { AddonModForumHelper } from '../../services/forum-helper'; | import { AddonModForumHelper } from '../../services/forum-helper'; | ||||||
| import { AddonModForumOffline } from '../../services/forum-offline'; | import { AddonModForumOffline } from '../../services/forum-offline'; | ||||||
| import { AddonModForumSync, AddonModForumSyncProvider } from '../../services/forum-sync'; | import { AddonModForumSync } from '../../services/forum-sync'; | ||||||
| import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; | import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; | ||||||
|  | import { | ||||||
|  |     ADDON_MOD_FORUM_AUTO_SYNCED, | ||||||
|  |     ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, | ||||||
|  |     ADDON_MOD_FORUM_COMPONENT, | ||||||
|  |     ADDON_MOD_FORUM_MANUAL_SYNCED, | ||||||
|  |     ADDON_MOD_FORUM_MARK_READ_EVENT, | ||||||
|  |     ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT, | ||||||
|  | } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| type SortType = 'flat-newest' | 'flat-oldest' | 'nested'; | type SortType = 'flat-newest' | 'flat-oldest' | 'nested'; | ||||||
| 
 | 
 | ||||||
| @ -101,7 +108,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|     refreshIcon = CoreConstants.ICON_LOADING; |     refreshIcon = CoreConstants.ICON_LOADING; | ||||||
|     syncIcon = CoreConstants.ICON_LOADING; |     syncIcon = CoreConstants.ICON_LOADING; | ||||||
|     discussionStr = ''; |     discussionStr = ''; | ||||||
|     component = AddonModForumProvider.COMPONENT; |     component = ADDON_MOD_FORUM_COMPONENT; | ||||||
|     cmId?: number; |     cmId?: number; | ||||||
|     canPin = false; |     canPin = false; | ||||||
|     availabilityMessage: string | null = null; |     availabilityMessage: string | null = null; | ||||||
| @ -216,7 +223,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|         const discussion = this.discussion; |         const discussion = this.discussion; | ||||||
| 
 | 
 | ||||||
|         // Refresh data if this discussion is synchronized automatically.
 |         // Refresh data if this discussion is synchronized automatically.
 | ||||||
|         this.syncObserver = CoreEvents.on(AddonModForumSyncProvider.AUTO_SYNCED, data => { |         this.syncObserver = CoreEvents.on(ADDON_MOD_FORUM_AUTO_SYNCED, data => { | ||||||
|             if (data.forumId == this.forumId && this.discussionId == data.discussionId |             if (data.forumId == this.forumId && this.discussionId == data.discussionId | ||||||
|                     && data.userId == CoreSites.getCurrentSiteUserId()) { |                     && data.userId == CoreSites.getCurrentSiteUserId()) { | ||||||
|                 // Refresh the data.
 |                 // Refresh the data.
 | ||||||
| @ -226,7 +233,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|         }, CoreSites.getCurrentSiteId()); |         }, CoreSites.getCurrentSiteId()); | ||||||
| 
 | 
 | ||||||
|         // Refresh data if this forum discussion is synchronized from discussions list.
 |         // Refresh data if this forum discussion is synchronized from discussions list.
 | ||||||
|         this.syncManualObserver = CoreEvents.on(AddonModForumSyncProvider.MANUAL_SYNCED, data => { |         this.syncManualObserver = CoreEvents.on(ADDON_MOD_FORUM_MANUAL_SYNCED, data => { | ||||||
|             if (data.source != 'discussion' && data.forumId == this.forumId && |             if (data.source != 'discussion' && data.forumId == this.forumId && | ||||||
|                     data.userId == CoreSites.getCurrentSiteUserId()) { |                     data.userId == CoreSites.getCurrentSiteUserId()) { | ||||||
|                 // Refresh the data.
 |                 // Refresh the data.
 | ||||||
| @ -255,7 +262,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => { |         this.changeDiscObserver = CoreEvents.on(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data => { | ||||||
|             if (discussion && this.forumId && (this.forumId === data.forumId || data.cmId === this.cmId)) { |             if (discussion && this.forumId && (this.forumId === data.forumId || data.cmId === this.cmId)) { | ||||||
|                 AddonModForum.invalidateDiscussionsList(this.forumId).finally(() => { |                 AddonModForum.invalidateDiscussionsList(this.forumId).finally(() => { | ||||||
|                     if (data.locked !== undefined) { |                     if (data.locked !== undefined) { | ||||||
| @ -607,7 +614,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
| 
 | 
 | ||||||
|                     if (result && result.updated && this.forumId) { |                     if (result && result.updated && this.forumId) { | ||||||
|                         // Sync successful, send event.
 |                         // Sync successful, send event.
 | ||||||
|                         CoreEvents.trigger(AddonModForumSyncProvider.MANUAL_SYNCED, { |                         CoreEvents.trigger(ADDON_MOD_FORUM_MANUAL_SYNCED, { | ||||||
|                             forumId: this.forumId, |                             forumId: this.forumId, | ||||||
|                             userId: CoreSites.getCurrentSiteUserId(), |                             userId: CoreSites.getCurrentSiteUserId(), | ||||||
|                             source: 'discussion', |                             source: 'discussion', | ||||||
| @ -719,7 +726,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|                 cmId: this.cmId, |                 cmId: this.cmId, | ||||||
|                 locked: this.discussion.locked, |                 locked: this.discussion.locked, | ||||||
|             }; |             }; | ||||||
|             CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); |             CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); | ||||||
| 
 | 
 | ||||||
|             CoreDomUtils.showToast('addon.mod_forum.lockupdated', true); |             CoreDomUtils.showToast('addon.mod_forum.lockupdated', true); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
| @ -752,7 +759,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|                 cmId: this.cmId, |                 cmId: this.cmId, | ||||||
|                 pinned: this.discussion.pinned, |                 pinned: this.discussion.pinned, | ||||||
|             }; |             }; | ||||||
|             CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); |             CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); | ||||||
| 
 | 
 | ||||||
|             CoreDomUtils.showToast('addon.mod_forum.pinupdated', true); |             CoreDomUtils.showToast('addon.mod_forum.pinupdated', true); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
| @ -785,7 +792,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|                 cmId: this.cmId, |                 cmId: this.cmId, | ||||||
|                 starred: this.discussion.starred, |                 starred: this.discussion.starred, | ||||||
|             }; |             }; | ||||||
|             CoreEvents.trigger(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); |             CoreEvents.trigger(ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); | ||||||
| 
 | 
 | ||||||
|             CoreDomUtils.showToast('addon.mod_forum.favouriteupdated', true); |             CoreDomUtils.showToast('addon.mod_forum.favouriteupdated', true); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
| @ -809,7 +816,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|             discussionId: this.discussionId, |             discussionId: this.discussionId, | ||||||
|             cmId: this.cmId, |             cmId: this.cmId, | ||||||
|         }; |         }; | ||||||
|         CoreEvents.trigger(AddonModForumProvider.REPLY_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); |         CoreEvents.trigger(ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT, data, CoreSites.getCurrentSiteId()); | ||||||
| 
 | 
 | ||||||
|         this.discussionLoaded = false; |         this.discussionLoaded = false; | ||||||
|         this.refreshPosts().finally(() => { |         this.refreshPosts().finally(() => { | ||||||
| @ -868,7 +875,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Trigger mark read posts.
 |         // Trigger mark read posts.
 | ||||||
|         CoreEvents.trigger(AddonModForumProvider.MARK_READ_EVENT, { |         CoreEvents.trigger(ADDON_MOD_FORUM_MARK_READ_EVENT, { | ||||||
|             courseId: this.courseId, |             courseId: this.courseId, | ||||||
|             moduleId: this.cmId, |             moduleId: this.cmId, | ||||||
|         }, CoreSites.getCurrentSiteId()); |         }, CoreSites.getCurrentSiteId()); | ||||||
|  | |||||||
| @ -23,10 +23,9 @@ import { | |||||||
|     AddonModForumAccessInformation, |     AddonModForumAccessInformation, | ||||||
|     AddonModForumCanAddDiscussion, |     AddonModForumCanAddDiscussion, | ||||||
|     AddonModForumData, |     AddonModForumData, | ||||||
|     AddonModForumProvider, |  | ||||||
| } from '@addons/mod/forum/services/forum'; | } from '@addons/mod/forum/services/forum'; | ||||||
| import { CoreEditorRichTextEditorComponent } from '@features/editor/components/rich-text-editor/rich-text-editor'; | import { CoreEditorRichTextEditorComponent } from '@features/editor/components/rich-text-editor/rich-text-editor'; | ||||||
| import { AddonModForumSync, AddonModForumSyncProvider } from '@addons/mod/forum/services/forum-sync'; | import { AddonModForumSync } from '@addons/mod/forum/services/forum-sync'; | ||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { Translate } from '@singletons'; | import { Translate } from '@singletons'; | ||||||
| @ -45,6 +44,13 @@ import { AddonModForumDiscussionsSource } from '../../classes/forum-discussions- | |||||||
| import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker'; | import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker'; | ||||||
| import { CoreTime } from '@singletons/time'; | import { CoreTime } from '@singletons/time'; | ||||||
| import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; | import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; | ||||||
|  | import { | ||||||
|  |     ADDON_MOD_FORUM_ALL_GROUPS, | ||||||
|  |     ADDON_MOD_FORUM_ALL_PARTICIPANTS, | ||||||
|  |     ADDON_MOD_FORUM_AUTO_SYNCED, | ||||||
|  |     ADDON_MOD_FORUM_COMPONENT, | ||||||
|  |     ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT, | ||||||
|  | } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| type NewDiscussionData = { | type NewDiscussionData = { | ||||||
|     subject: string; |     subject: string; | ||||||
| @ -69,7 +75,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | |||||||
|     @ViewChild('newDiscFormEl') formElement!: ElementRef; |     @ViewChild('newDiscFormEl') formElement!: ElementRef; | ||||||
|     @ViewChild(CoreEditorRichTextEditorComponent) messageEditor!: CoreEditorRichTextEditorComponent; |     @ViewChild(CoreEditorRichTextEditorComponent) messageEditor!: CoreEditorRichTextEditorComponent; | ||||||
| 
 | 
 | ||||||
|     component = AddonModForumProvider.COMPONENT; |     component = ADDON_MOD_FORUM_COMPONENT; | ||||||
|     messageControl = new FormControl<string | null>(null); |     messageControl = new FormControl<string | null>(null); | ||||||
|     groupsLoaded = false; |     groupsLoaded = false; | ||||||
|     showGroups = false; |     showGroups = false; | ||||||
| @ -133,7 +139,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | |||||||
|             this.initialGroupId = CoreNavigator.getRouteNumberParam('groupId'); |             this.initialGroupId = CoreNavigator.getRouteNumberParam('groupId'); | ||||||
| 
 | 
 | ||||||
|             // Discussion list uses 0 for all participants, but this page WebServices use a different value. Convert it.
 |             // Discussion list uses 0 for all participants, but this page WebServices use a different value. Convert it.
 | ||||||
|             this.initialGroupId = this.initialGroupId === 0 ? AddonModForumProvider.ALL_PARTICIPANTS : this.initialGroupId; |             this.initialGroupId = this.initialGroupId === 0 ? ADDON_MOD_FORUM_ALL_PARTICIPANTS : this.initialGroupId; | ||||||
| 
 | 
 | ||||||
|             if (this.timeCreated !== 0 && (routeData.swipeEnabled ?? true)) { |             if (this.timeCreated !== 0 && (routeData.swipeEnabled ?? true)) { | ||||||
|                 const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource( |                 const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource( | ||||||
| @ -168,7 +174,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Refresh data if this discussion is synchronized automatically.
 |         // Refresh data if this discussion is synchronized automatically.
 | ||||||
|         this.syncObserver = CoreEvents.on(AddonModForumSyncProvider.AUTO_SYNCED, data => { |         this.syncObserver = CoreEvents.on(ADDON_MOD_FORUM_AUTO_SYNCED, data => { | ||||||
|             if (data.forumId == this.forumId && data.userId == CoreSites.getCurrentSiteUserId()) { |             if (data.forumId == this.forumId && data.userId == CoreSites.getCurrentSiteUserId()) { | ||||||
|                 CoreDomUtils.showAlertTranslated('core.notice', 'core.contenteditingsynced'); |                 CoreDomUtils.showAlertTranslated('core.notice', 'core.contenteditingsynced'); | ||||||
|                 this.returnToDiscussions(); |                 this.returnToDiscussions(); | ||||||
| @ -262,7 +268,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | |||||||
|                 await AddonModForumSync.waitForSync(this.syncId).then(() => { |                 await AddonModForumSync.waitForSync(this.syncId).then(() => { | ||||||
|                     // Do not block if the scope is already destroyed.
 |                     // Do not block if the scope is already destroyed.
 | ||||||
|                     if (!this.isDestroyed) { |                     if (!this.isDestroyed) { | ||||||
|                         CoreSync.blockOperation(AddonModForumProvider.COMPONENT, this.syncId); |                         CoreSync.blockOperation(ADDON_MOD_FORUM_COMPONENT, this.syncId); | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     return AddonModForumOffline.instance |                     return AddonModForumOffline.instance | ||||||
| @ -270,7 +276,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | |||||||
|                         .then(async (discussion) => { |                         .then(async (discussion) => { | ||||||
|                             this.hasOffline = true; |                             this.hasOffline = true; | ||||||
|                             discussion.options = discussion.options || {}; |                             discussion.options = discussion.options || {}; | ||||||
|                             if (discussion.groupid == AddonModForumProvider.ALL_GROUPS) { |                             if (discussion.groupid == ADDON_MOD_FORUM_ALL_GROUPS) { | ||||||
|                                 this.newDiscussion.groupId = this.groups[0].id; |                                 this.newDiscussion.groupId = this.groups[0].id; | ||||||
|                                 this.newDiscussion.postToAllGroups = true; |                                 this.newDiscussion.postToAllGroups = true; | ||||||
|                             } else { |                             } else { | ||||||
| @ -438,7 +444,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | |||||||
|             if (canAdd) { |             if (canAdd) { | ||||||
|                 groups.unshift({ |                 groups.unshift({ | ||||||
|                     courseid: this.courseId, |                     courseid: this.courseId, | ||||||
|                     id: AddonModForumProvider.ALL_PARTICIPANTS, |                     id: ADDON_MOD_FORUM_ALL_PARTICIPANTS, | ||||||
|                     name: Translate.instant('core.allparticipants'), |                     name: Translate.instant('core.allparticipants'), | ||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
| @ -479,7 +485,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | |||||||
|         CoreFileUploader.clearTmpFiles(this.newDiscussion.files); |         CoreFileUploader.clearTmpFiles(this.newDiscussion.files); | ||||||
| 
 | 
 | ||||||
|         CoreEvents.trigger( |         CoreEvents.trigger( | ||||||
|             AddonModForumProvider.NEW_DISCUSSION_EVENT, |             ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT, | ||||||
|             { |             { | ||||||
|                 forumId: this.forumId, |                 forumId: this.forumId, | ||||||
|                 cmId: this.cmId, |                 cmId: this.cmId, | ||||||
| @ -683,7 +689,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea | |||||||
|      */ |      */ | ||||||
|     ngOnDestroy(): void { |     ngOnDestroy(): void { | ||||||
|         if (this.syncId) { |         if (this.syncId) { | ||||||
|             CoreSync.unblockOperation(AddonModForumProvider.COMPONENT, this.syncId); |             CoreSync.unblockOperation(ADDON_MOD_FORUM_COMPONENT, this.syncId); | ||||||
|         } |         } | ||||||
|         this.isDestroyed = true; |         this.isDestroyed = true; | ||||||
|         this.discussions?.destroy(); |         this.discussions?.destroy(); | ||||||
|  | |||||||
| @ -28,10 +28,10 @@ import { | |||||||
|     AddonModForumData, |     AddonModForumData, | ||||||
|     AddonModForumDiscussion, |     AddonModForumDiscussion, | ||||||
|     AddonModForumPost, |     AddonModForumPost, | ||||||
|     AddonModForumProvider, |  | ||||||
| } from './forum'; | } from './forum'; | ||||||
| import { AddonModForumDiscussionOptions, AddonModForumOffline, AddonModForumOfflineReply } from './forum-offline'; | import { AddonModForumDiscussionOptions, AddonModForumOffline, AddonModForumOfflineReply } from './forum-offline'; | ||||||
| import { CoreFileEntry } from '@services/file-helper'; | import { CoreFileEntry } from '@services/file-helper'; | ||||||
|  | import { ADDON_MOD_FORUM_ALL_GROUPS, ADDON_MOD_FORUM_COMPONENT } from '../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service that provides some features for forums. |  * Service that provides some features for forums. | ||||||
| @ -76,7 +76,7 @@ export class AddonModForumHelperProvider { | |||||||
|         // Convenience function to store a message to be synchronized later.
 |         // Convenience function to store a message to be synchronized later.
 | ||||||
|         const storeOffline = async (): Promise<void> => { |         const storeOffline = async (): Promise<void> => { | ||||||
|             // Multiple groups, the discussion is being posted to all groups.
 |             // Multiple groups, the discussion is being posted to all groups.
 | ||||||
|             const groupId = groupIds.length > 1 ? AddonModForumProvider.ALL_GROUPS : groupIds[0]; |             const groupId = groupIds.length > 1 ? ADDON_MOD_FORUM_ALL_GROUPS : groupIds[0]; | ||||||
| 
 | 
 | ||||||
|             if (offlineAttachments && options) { |             if (offlineAttachments && options) { | ||||||
|                 options.attachmentsid = offlineAttachments; |                 options.attachmentsid = offlineAttachments; | ||||||
| @ -502,7 +502,7 @@ export class AddonModForumHelperProvider { | |||||||
|             return this.storeNewDiscussionFiles(forumId, timecreated, files, siteId); |             return this.storeNewDiscussionFiles(forumId, timecreated, files, siteId); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId); |         return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_FORUM_COMPONENT, forumId, siteId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -544,7 +544,7 @@ export class AddonModForumHelperProvider { | |||||||
|             return this.storeReplyFiles(forumId, postId, files, siteId, userId); |             return this.storeReplyFiles(forumId, postId, files, siteId, userId); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId); |         return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_FORUM_COMPONENT, forumId, siteId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -18,7 +18,6 @@ import { CoreFile } from '@services/file'; | |||||||
| import { CoreSites } from '@services/sites'; | import { CoreSites } from '@services/sites'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { AddonModForumProvider } from './forum'; |  | ||||||
| import { | import { | ||||||
|     AddonModForumOfflineDiscussionDBRecord, |     AddonModForumOfflineDiscussionDBRecord, | ||||||
|     AddonModForumOfflineReplyDBRecord, |     AddonModForumOfflineReplyDBRecord, | ||||||
| @ -26,6 +25,7 @@ import { | |||||||
|     REPLIES_TABLE, |     REPLIES_TABLE, | ||||||
| } from './database/offline'; | } from './database/offline'; | ||||||
| import { CorePath } from '@singletons/path'; | import { CorePath } from '@singletons/path'; | ||||||
|  | import { ADDON_MOD_FORUM_ALL_PARTICIPANTS } from '../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline forum. |  * Service to handle offline forum. | ||||||
| @ -168,7 +168,7 @@ export class AddonModForumOfflineProvider { | |||||||
|             subject: subject, |             subject: subject, | ||||||
|             message: message, |             message: message, | ||||||
|             options: JSON.stringify(options || {}), |             options: JSON.stringify(options || {}), | ||||||
|             groupid: groupId || AddonModForumProvider.ALL_PARTICIPANTS, |             groupid: groupId || ADDON_MOD_FORUM_ALL_PARTICIPANTS, | ||||||
|             userid: userId || site.getUserId(), |             userid: userId || site.getUserId(), | ||||||
|             timecreated: timeCreated || Date.now(), |             timecreated: timeCreated || Date.now(), | ||||||
|         }; |         }; | ||||||
|  | |||||||
| @ -29,10 +29,15 @@ import { | |||||||
|     AddonModForum, |     AddonModForum, | ||||||
|     AddonModForumAddDiscussionPostWSOptionsObject, |     AddonModForumAddDiscussionPostWSOptionsObject, | ||||||
|     AddonModForumAddDiscussionWSOptionsObject, |     AddonModForumAddDiscussionWSOptionsObject, | ||||||
|     AddonModForumProvider, |  | ||||||
| } from './forum'; | } from './forum'; | ||||||
| import { AddonModForumHelper } from './forum-helper'; | import { AddonModForumHelper } from './forum-helper'; | ||||||
| import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumOfflineReply } from './forum-offline'; | import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumOfflineReply } from './forum-offline'; | ||||||
|  | import { | ||||||
|  |     ADDON_MOD_FORUM_ALL_GROUPS, | ||||||
|  |     ADDON_MOD_FORUM_AUTO_SYNCED, | ||||||
|  |     ADDON_MOD_FORUM_COMPONENT, | ||||||
|  |     ADDON_MOD_FORUM_MANUAL_SYNCED, | ||||||
|  | } from '../constants'; | ||||||
| 
 | 
 | ||||||
| declare module '@singletons/events' { | declare module '@singletons/events' { | ||||||
| 
 | 
 | ||||||
| @ -42,8 +47,8 @@ declare module '@singletons/events' { | |||||||
|      * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 |      * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | ||||||
|      */ |      */ | ||||||
|     export interface CoreEventsData { |     export interface CoreEventsData { | ||||||
|         [AddonModForumSyncProvider.AUTO_SYNCED]: AddonModForumAutoSyncData; |         [ADDON_MOD_FORUM_AUTO_SYNCED]: AddonModForumAutoSyncData; | ||||||
|         [AddonModForumSyncProvider.MANUAL_SYNCED]: AddonModForumManualSyncData; |         [ADDON_MOD_FORUM_MANUAL_SYNCED]: AddonModForumManualSyncData; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| @ -54,9 +59,6 @@ declare module '@singletons/events' { | |||||||
| @Injectable({ providedIn: 'root' }) | @Injectable({ providedIn: 'root' }) | ||||||
| export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModForumSyncResult> { | export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModForumSyncResult> { | ||||||
| 
 | 
 | ||||||
|     static readonly AUTO_SYNCED = 'addon_mod_forum_autom_synced'; |  | ||||||
|     static readonly MANUAL_SYNCED = 'addon_mod_forum_manual_synced'; |  | ||||||
| 
 |  | ||||||
|     protected componentTranslatableString = 'forum'; |     protected componentTranslatableString = 'forum'; | ||||||
| 
 | 
 | ||||||
|     constructor() { |     constructor() { | ||||||
| @ -100,7 +102,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
| 
 | 
 | ||||||
|                 if (result && result.updated) { |                 if (result && result.updated) { | ||||||
|                     // Sync successful, send event.
 |                     // Sync successful, send event.
 | ||||||
|                     CoreEvents.trigger(AddonModForumSyncProvider.AUTO_SYNCED, { |                     CoreEvents.trigger(ADDON_MOD_FORUM_AUTO_SYNCED, { | ||||||
|                         forumId: discussion.forumid, |                         forumId: discussion.forumid, | ||||||
|                         userId: discussion.userid, |                         userId: discussion.userid, | ||||||
|                         warnings: result.warnings, |                         warnings: result.warnings, | ||||||
| @ -134,7 +136,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
| 
 | 
 | ||||||
|                 if (result && result.updated) { |                 if (result && result.updated) { | ||||||
|                     // Sync successful, send event.
 |                     // Sync successful, send event.
 | ||||||
|                     CoreEvents.trigger(AddonModForumSyncProvider.AUTO_SYNCED, { |                     CoreEvents.trigger(ADDON_MOD_FORUM_AUTO_SYNCED, { | ||||||
|                         forumId: reply.forumid, |                         forumId: reply.forumid, | ||||||
|                         discussionId: reply.discussionid, |                         discussionId: reply.discussionid, | ||||||
|                         userId: reply.userid, |                         userId: reply.userid, | ||||||
| @ -207,7 +209,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Verify that forum isn't blocked.
 |         // Verify that forum isn't blocked.
 | ||||||
|         if (CoreSync.isBlocked(AddonModForumProvider.COMPONENT, syncId, siteId)) { |         if (CoreSync.isBlocked(ADDON_MOD_FORUM_COMPONENT, syncId, siteId)) { | ||||||
|             this.logger.debug('Cannot sync forum ' + forumId + ' because it is blocked.'); |             this.logger.debug('Cannot sync forum ' + forumId + ' because it is blocked.'); | ||||||
| 
 | 
 | ||||||
|             throw new Error(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate })); |             throw new Error(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate })); | ||||||
| @ -223,7 +225,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
|         // Sync offline logs.
 |         // Sync offline logs.
 | ||||||
|         const syncDiscussions = async (): Promise<AddonModForumSyncResult> => { |         const syncDiscussions = async (): Promise<AddonModForumSyncResult> => { | ||||||
|             await CoreUtils.ignoreErrors( |             await CoreUtils.ignoreErrors( | ||||||
|                 CoreCourseLogHelper.syncActivity(AddonModForumProvider.COMPONENT, forumId, siteId), |                 CoreCourseLogHelper.syncActivity(ADDON_MOD_FORUM_COMPONENT, forumId, siteId), | ||||||
|             ); |             ); | ||||||
| 
 | 
 | ||||||
|             // Get offline responses to be sent.
 |             // Get offline responses to be sent.
 | ||||||
| @ -238,7 +240,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
| 
 | 
 | ||||||
|             const promises = discussions.map(async discussion => { |             const promises = discussions.map(async discussion => { | ||||||
|                 const errors: Error[] = []; |                 const errors: Error[] = []; | ||||||
|                 const groupIds = discussion.groupid === AddonModForumProvider.ALL_GROUPS |                 const groupIds = discussion.groupid === ADDON_MOD_FORUM_ALL_GROUPS | ||||||
|                     ? await AddonModForum.instance |                     ? await AddonModForum.instance | ||||||
|                         .getForumById(discussion.courseid, discussion.forumid, { siteId }) |                         .getForumById(discussion.courseid, discussion.forumid, { siteId }) | ||||||
|                         .then(forum => CoreGroups.getActivityAllowedGroups(forum.cmid)) |                         .then(forum => CoreGroups.getActivityAllowedGroups(forum.cmid)) | ||||||
| @ -439,7 +441,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Verify that forum isn't blocked.
 |         // Verify that forum isn't blocked.
 | ||||||
|         if (CoreSync.isBlocked(AddonModForumProvider.COMPONENT, syncId, siteId)) { |         if (CoreSync.isBlocked(ADDON_MOD_FORUM_COMPONENT, syncId, siteId)) { | ||||||
|             this.logger.debug('Cannot sync forum discussion ' + discussionId + ' because it is blocked.'); |             this.logger.debug('Cannot sync forum discussion ' + discussionId + ' because it is blocked.'); | ||||||
| 
 | 
 | ||||||
|             throw new Error(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate })); |             throw new Error(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate })); | ||||||
| @ -607,7 +609,7 @@ export class AddonModForumSyncProvider extends CoreCourseActivitySyncBaseProvide | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return CoreFileUploader.uploadOrReuploadFiles(files, AddonModForumProvider.COMPONENT, forumId, siteId); |         return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_FORUM_COMPONENT, forumId, siteId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -30,8 +30,18 @@ import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWar | |||||||
| import { makeSingleton, Translate } from '@singletons'; | import { makeSingleton, Translate } from '@singletons'; | ||||||
| import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumReplyOptions } from './forum-offline'; | import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumReplyOptions } from './forum-offline'; | ||||||
| import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; | import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; | ||||||
| 
 | import { | ||||||
| const ROOT_CACHE_KEY = 'mmaModForum:'; |     ADDON_MOD_FORUM_ALL_GROUPS, | ||||||
|  |     ADDON_MOD_FORUM_ALL_PARTICIPANTS, | ||||||
|  |     ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, | ||||||
|  |     ADDON_MOD_FORUM_COMPONENT, | ||||||
|  |     ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE, | ||||||
|  |     ADDON_MOD_FORUM_MARK_READ_EVENT, | ||||||
|  |     ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT, | ||||||
|  |     ADDON_MOD_FORUM_PREFERENCE_SORTORDER, | ||||||
|  |     ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT, | ||||||
|  |     AddonModForumSortorder, | ||||||
|  | } from '../constants'; | ||||||
| 
 | 
 | ||||||
| declare module '@singletons/events' { | declare module '@singletons/events' { | ||||||
| 
 | 
 | ||||||
| @ -41,10 +51,10 @@ declare module '@singletons/events' { | |||||||
|      * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 |      * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
 | ||||||
|      */ |      */ | ||||||
|     export interface CoreEventsData { |     export interface CoreEventsData { | ||||||
|         [AddonModForumProvider.NEW_DISCUSSION_EVENT]: AddonModForumNewDiscussionData; |         [ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT]: AddonModForumNewDiscussionData; | ||||||
|         [AddonModForumProvider.REPLY_DISCUSSION_EVENT]: AddonModForumReplyDiscussionData; |         [ADDON_MOD_FORUM_REPLY_DISCUSSION_EVENT]: AddonModForumReplyDiscussionData; | ||||||
|         [AddonModForumProvider.CHANGE_DISCUSSION_EVENT]: AddonModForumChangeDiscussionData; |         [ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT]: AddonModForumChangeDiscussionData; | ||||||
|         [AddonModForumProvider.MARK_READ_EVENT]: AddonModForumMarkReadData; |         [ADDON_MOD_FORUM_MARK_READ_EVENT]: AddonModForumMarkReadData; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| @ -55,24 +65,7 @@ declare module '@singletons/events' { | |||||||
| @Injectable({ providedIn: 'root' }) | @Injectable({ providedIn: 'root' }) | ||||||
| export class AddonModForumProvider { | export class AddonModForumProvider { | ||||||
| 
 | 
 | ||||||
|     static readonly COMPONENT = 'mmaModForum'; |     protected static readonly ROOT_CACHE_KEY = 'mmaModForum:'; | ||||||
|     static readonly DISCUSSIONS_PER_PAGE = 10; // Max of discussions per page.
 |  | ||||||
|     static readonly NEW_DISCUSSION_EVENT = 'addon_mod_forum_new_discussion'; |  | ||||||
|     static readonly REPLY_DISCUSSION_EVENT = 'addon_mod_forum_reply_discussion'; |  | ||||||
|     static readonly CHANGE_DISCUSSION_EVENT = 'addon_mod_forum_change_discussion_status'; |  | ||||||
|     static readonly MARK_READ_EVENT = 'addon_mod_forum_mark_read'; |  | ||||||
|     static readonly LEAVING_POSTS_PAGE = 'addon_mod_forum_leaving_posts_page'; |  | ||||||
| 
 |  | ||||||
|     static readonly PREFERENCE_SORTORDER = 'forum_discussionlistsortorder'; |  | ||||||
|     static readonly SORTORDER_LASTPOST_DESC = 1; |  | ||||||
|     static readonly SORTORDER_LASTPOST_ASC = 2; |  | ||||||
|     static readonly SORTORDER_CREATED_DESC = 3; |  | ||||||
|     static readonly SORTORDER_CREATED_ASC = 4; |  | ||||||
|     static readonly SORTORDER_REPLIES_DESC = 5; |  | ||||||
|     static readonly SORTORDER_REPLIES_ASC = 6; |  | ||||||
| 
 |  | ||||||
|     static readonly ALL_PARTICIPANTS = -1; |  | ||||||
|     static readonly ALL_GROUPS = -2; |  | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Get cache key for can add discussion WS calls. |      * Get cache key for can add discussion WS calls. | ||||||
| @ -93,7 +86,7 @@ export class AddonModForumProvider { | |||||||
|      * @returns Cache key. |      * @returns Cache key. | ||||||
|      */ |      */ | ||||||
|     protected getCommonCanAddDiscussionCacheKey(forumId: number): string { |     protected getCommonCanAddDiscussionCacheKey(forumId: number): string { | ||||||
|         return ROOT_CACHE_KEY + 'canadddiscussion:' + forumId + ':'; |         return AddonModForumProvider.ROOT_CACHE_KEY + 'canadddiscussion:' + forumId + ':'; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -103,7 +96,7 @@ export class AddonModForumProvider { | |||||||
|      * @returns Cache key. |      * @returns Cache key. | ||||||
|      */ |      */ | ||||||
|     protected getForumDataPrefixCacheKey(forumId: number): string { |     protected getForumDataPrefixCacheKey(forumId: number): string { | ||||||
|         return ROOT_CACHE_KEY + forumId; |         return AddonModForumProvider.ROOT_CACHE_KEY + forumId; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -136,7 +129,7 @@ export class AddonModForumProvider { | |||||||
|      * @returns Cache key. |      * @returns Cache key. | ||||||
|      */ |      */ | ||||||
|     protected getForumDataCacheKey(courseId: number): string { |     protected getForumDataCacheKey(courseId: number): string { | ||||||
|         return ROOT_CACHE_KEY + 'forum:' + courseId; |         return AddonModForumProvider.ROOT_CACHE_KEY + 'forum:' + courseId; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -147,7 +140,7 @@ export class AddonModForumProvider { | |||||||
|      * @returns Cache key. |      * @returns Cache key. | ||||||
|      */ |      */ | ||||||
|     protected getAccessInformationCacheKey(forumId: number): string { |     protected getAccessInformationCacheKey(forumId: number): string { | ||||||
|         return ROOT_CACHE_KEY + 'accessInformation:' + forumId; |         return AddonModForumProvider.ROOT_CACHE_KEY + 'accessInformation:' + forumId; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -158,7 +151,7 @@ export class AddonModForumProvider { | |||||||
|      * @returns Cache key. |      * @returns Cache key. | ||||||
|      */ |      */ | ||||||
|     protected getDiscussionPostsCacheKey(discussionId: number): string { |     protected getDiscussionPostsCacheKey(discussionId: number): string { | ||||||
|         return ROOT_CACHE_KEY + 'discussion:' + discussionId; |         return AddonModForumProvider.ROOT_CACHE_KEY + 'discussion:' + discussionId; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -168,7 +161,7 @@ export class AddonModForumProvider { | |||||||
|      * @returns Cache key. |      * @returns Cache key. | ||||||
|      */ |      */ | ||||||
|     protected getDiscussionsListCommonCacheKey(forumId: number): string { |     protected getDiscussionsListCommonCacheKey(forumId: number): string { | ||||||
|         return ROOT_CACHE_KEY + 'discussions:' + forumId; |         return AddonModForumProvider.ROOT_CACHE_KEY + 'discussions:' + forumId; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -182,7 +175,7 @@ export class AddonModForumProvider { | |||||||
|     protected getDiscussionsListCacheKey(forumId: number, sortOrder: number, groupId?: number): string { |     protected getDiscussionsListCacheKey(forumId: number, sortOrder: number, groupId?: number): string { | ||||||
|         let key = this.getDiscussionsListCommonCacheKey(forumId); |         let key = this.getDiscussionsListCommonCacheKey(forumId); | ||||||
| 
 | 
 | ||||||
|         if (sortOrder != AddonModForumProvider.SORTORDER_LASTPOST_DESC) { |         if (sortOrder !== AddonModForumSortorder.LASTPOST_DESC) { | ||||||
|             key += ':' + sortOrder; |             key += ':' + sortOrder; | ||||||
|         } |         } | ||||||
|         if (groupId) { |         if (groupId) { | ||||||
| @ -257,7 +250,7 @@ export class AddonModForumProvider { | |||||||
|         }; |         }; | ||||||
|         const preSets = { |         const preSets = { | ||||||
|             cacheKey: this.getCanAddDiscussionCacheKey(forumId, groupId), |             cacheKey: this.getCanAddDiscussionCacheKey(forumId, groupId), | ||||||
|             component: AddonModForumProvider.COMPONENT, |             component: ADDON_MOD_FORUM_COMPONENT, | ||||||
|             componentId: options.cmId, |             componentId: options.cmId, | ||||||
|             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 |             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 | ||||||
|         }; |         }; | ||||||
| @ -292,7 +285,7 @@ export class AddonModForumProvider { | |||||||
|      *         - cancreateattachment (boolean) |      *         - cancreateattachment (boolean) | ||||||
|      */ |      */ | ||||||
|     canAddDiscussionToAll(forumId: number, options: CoreCourseCommonModWSOptions = {}): Promise<AddonModForumCanAddDiscussion> { |     canAddDiscussionToAll(forumId: number, options: CoreCourseCommonModWSOptions = {}): Promise<AddonModForumCanAddDiscussion> { | ||||||
|         return this.canAddDiscussion(forumId, AddonModForumProvider.ALL_PARTICIPANTS, options); |         return this.canAddDiscussion(forumId, ADDON_MOD_FORUM_ALL_PARTICIPANTS, options); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -394,9 +387,9 @@ export class AddonModForumProvider { | |||||||
| 
 | 
 | ||||||
|             // Format discussions.
 |             // Format discussions.
 | ||||||
|             discussions.forEach((disc) => { |             discussions.forEach((disc) => { | ||||||
|                 if (disc.groupid == AddonModForumProvider.ALL_PARTICIPANTS) { |                 if (disc.groupid == ADDON_MOD_FORUM_ALL_PARTICIPANTS) { | ||||||
|                     disc.groupname = strAllParts; |                     disc.groupname = strAllParts; | ||||||
|                 } else if (disc.groupid == AddonModForumProvider.ALL_GROUPS) { |                 } else if (disc.groupid == ADDON_MOD_FORUM_ALL_GROUPS) { | ||||||
|                     // Offline discussions only.
 |                     // Offline discussions only.
 | ||||||
|                     disc.groupname = strAllGroups; |                     disc.groupname = strAllGroups; | ||||||
|                 } else { |                 } else { | ||||||
| @ -427,7 +420,7 @@ export class AddonModForumProvider { | |||||||
|         const preSets: CoreSiteWSPreSets = { |         const preSets: CoreSiteWSPreSets = { | ||||||
|             cacheKey: this.getForumDataCacheKey(courseId), |             cacheKey: this.getForumDataCacheKey(courseId), | ||||||
|             updateFrequency: CoreSite.FREQUENCY_RARELY, |             updateFrequency: CoreSite.FREQUENCY_RARELY, | ||||||
|             component: AddonModForumProvider.COMPONENT, |             component: ADDON_MOD_FORUM_COMPONENT, | ||||||
|             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), |             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
| @ -456,7 +449,7 @@ export class AddonModForumProvider { | |||||||
|         const preSets = { |         const preSets = { | ||||||
|             cacheKey: this.getDiscussionPostDataCacheKey(forumId, discussionId, postId), |             cacheKey: this.getDiscussionPostDataCacheKey(forumId, discussionId, postId), | ||||||
|             updateFrequency: CoreSite.FREQUENCY_USUALLY, |             updateFrequency: CoreSite.FREQUENCY_USUALLY, | ||||||
|             component: AddonModForumProvider.COMPONENT, |             component: ADDON_MOD_FORUM_COMPONENT, | ||||||
|             componentId: options.cmId, |             componentId: options.cmId, | ||||||
|             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 |             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 | ||||||
|         }; |         }; | ||||||
| @ -537,7 +530,7 @@ export class AddonModForumProvider { | |||||||
|         }; |         }; | ||||||
|         const preSets = { |         const preSets = { | ||||||
|             cacheKey: this.getAccessInformationCacheKey(forumId), |             cacheKey: this.getAccessInformationCacheKey(forumId), | ||||||
|             component: AddonModForumProvider.COMPONENT, |             component: ADDON_MOD_FORUM_COMPONENT, | ||||||
|             componentId: options.cmId, |             componentId: options.cmId, | ||||||
|             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 |             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 | ||||||
|         }; |         }; | ||||||
| @ -607,7 +600,7 @@ export class AddonModForumProvider { | |||||||
|         }; |         }; | ||||||
|         const preSets = { |         const preSets = { | ||||||
|             cacheKey: this.getDiscussionPostsCacheKey(discussionId), |             cacheKey: this.getDiscussionPostsCacheKey(discussionId), | ||||||
|             component: AddonModForumProvider.COMPONENT, |             component: ADDON_MOD_FORUM_COMPONENT, | ||||||
|             componentId: options.cmId, |             componentId: options.cmId, | ||||||
|             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 |             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 | ||||||
|         }; |         }; | ||||||
| @ -684,7 +677,7 @@ export class AddonModForumProvider { | |||||||
|         const sortOrders = [ |         const sortOrders = [ | ||||||
|             { |             { | ||||||
|                 label: 'addon.mod_forum.discussionlistsortbylastpostdesc', |                 label: 'addon.mod_forum.discussionlistsortbylastpostdesc', | ||||||
|                 value: AddonModForumProvider.SORTORDER_LASTPOST_DESC, |                 value: AddonModForumSortorder.LASTPOST_DESC, | ||||||
|             }, |             }, | ||||||
|         ]; |         ]; | ||||||
| 
 | 
 | ||||||
| @ -692,23 +685,23 @@ export class AddonModForumProvider { | |||||||
|             sortOrders.push( |             sortOrders.push( | ||||||
|                 { |                 { | ||||||
|                     label: 'addon.mod_forum.discussionlistsortbylastpostasc', |                     label: 'addon.mod_forum.discussionlistsortbylastpostasc', | ||||||
|                     value: AddonModForumProvider.SORTORDER_LASTPOST_ASC, |                     value: AddonModForumSortorder.LASTPOST_ASC, | ||||||
|                 }, |                 }, | ||||||
|                 { |                 { | ||||||
|                     label: 'addon.mod_forum.discussionlistsortbycreateddesc', |                     label: 'addon.mod_forum.discussionlistsortbycreateddesc', | ||||||
|                     value: AddonModForumProvider.SORTORDER_CREATED_DESC, |                     value: AddonModForumSortorder.CREATED_DESC, | ||||||
|                 }, |                 }, | ||||||
|                 { |                 { | ||||||
|                     label: 'addon.mod_forum.discussionlistsortbycreatedasc', |                     label: 'addon.mod_forum.discussionlistsortbycreatedasc', | ||||||
|                     value: AddonModForumProvider.SORTORDER_CREATED_ASC, |                     value: AddonModForumSortorder.CREATED_ASC, | ||||||
|                 }, |                 }, | ||||||
|                 { |                 { | ||||||
|                     label: 'addon.mod_forum.discussionlistsortbyrepliesdesc', |                     label: 'addon.mod_forum.discussionlistsortbyrepliesdesc', | ||||||
|                     value: AddonModForumProvider.SORTORDER_REPLIES_DESC, |                     value: AddonModForumSortorder.REPLIES_DESC, | ||||||
|                 }, |                 }, | ||||||
|                 { |                 { | ||||||
|                     label: 'addon.mod_forum.discussionlistsortbyrepliesasc', |                     label: 'addon.mod_forum.discussionlistsortbyrepliesasc', | ||||||
|                     value: AddonModForumProvider.SORTORDER_REPLIES_ASC, |                     value: AddonModForumSortorder.REPLIES_ASC, | ||||||
|                 }, |                 }, | ||||||
|             ); |             ); | ||||||
|         } |         } | ||||||
| @ -727,7 +720,7 @@ export class AddonModForumProvider { | |||||||
| 
 | 
 | ||||||
|         if (this.isDiscussionListSortingAvailable()) { |         if (this.isDiscussionListSortingAvailable()) { | ||||||
|             const preferenceValue = await CoreUtils.ignoreErrors( |             const preferenceValue = await CoreUtils.ignoreErrors( | ||||||
|                 CoreUser.getUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER), |                 CoreUser.getUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER), | ||||||
|             ); |             ); | ||||||
| 
 | 
 | ||||||
|             sortOrderValue = preferenceValue ? parseInt(preferenceValue, 10) : null; |             sortOrderValue = preferenceValue ? parseInt(preferenceValue, 10) : null; | ||||||
| @ -750,7 +743,7 @@ export class AddonModForumProvider { | |||||||
|         forumId: number, |         forumId: number, | ||||||
|         options: AddonModForumGetDiscussionsOptions = {}, |         options: AddonModForumGetDiscussionsOptions = {}, | ||||||
|     ): Promise<{ discussions: AddonModForumDiscussion[]; canLoadMore: boolean }> { |     ): Promise<{ discussions: AddonModForumDiscussion[]; canLoadMore: boolean }> { | ||||||
|         options.sortOrder = options.sortOrder || AddonModForumProvider.SORTORDER_LASTPOST_DESC; |         options.sortOrder = options.sortOrder || AddonModForumSortorder.LASTPOST_DESC; | ||||||
|         options.page = options.page || 0; |         options.page = options.page || 0; | ||||||
| 
 | 
 | ||||||
|         const site = await CoreSites.getSite(options.siteId); |         const site = await CoreSites.getSite(options.siteId); | ||||||
| @ -758,7 +751,7 @@ export class AddonModForumProvider { | |||||||
|         const params: AddonModForumGetForumDiscussionsPaginatedWSParams | AddonModForumGetForumDiscussionsWSParams = { |         const params: AddonModForumGetForumDiscussionsPaginatedWSParams | AddonModForumGetForumDiscussionsWSParams = { | ||||||
|             forumid: forumId, |             forumid: forumId, | ||||||
|             page: options.page, |             page: options.page, | ||||||
|             perpage: AddonModForumProvider.DISCUSSIONS_PER_PAGE, |             perpage: ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (site.wsAvailable('mod_forum_get_forum_discussions')) { |         if (site.wsAvailable('mod_forum_get_forum_discussions')) { | ||||||
| @ -767,7 +760,7 @@ export class AddonModForumProvider { | |||||||
|             (params as AddonModForumGetForumDiscussionsWSParams).sortorder = options.sortOrder; |             (params as AddonModForumGetForumDiscussionsWSParams).sortorder = options.sortOrder; | ||||||
|             (params as AddonModForumGetForumDiscussionsWSParams).groupid = options.groupId; |             (params as AddonModForumGetForumDiscussionsWSParams).groupid = options.groupId; | ||||||
|         } else { |         } else { | ||||||
|             if (options.sortOrder !== AddonModForumProvider.SORTORDER_LASTPOST_DESC) { |             if (options.sortOrder !== AddonModForumSortorder.LASTPOST_DESC) { | ||||||
|                 throw new Error('Sorting not supported with the old WS method.'); |                 throw new Error('Sorting not supported with the old WS method.'); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -777,7 +770,7 @@ export class AddonModForumProvider { | |||||||
| 
 | 
 | ||||||
|         const preSets = { |         const preSets = { | ||||||
|             cacheKey: this.getDiscussionsListCacheKey(forumId, options.sortOrder), |             cacheKey: this.getDiscussionsListCacheKey(forumId, options.sortOrder), | ||||||
|             component: AddonModForumProvider.COMPONENT, |             component: ADDON_MOD_FORUM_COMPONENT, | ||||||
|             componentId: options.cmId, |             componentId: options.cmId, | ||||||
|             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 |             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
 | ||||||
|         }; |         }; | ||||||
| @ -795,7 +788,7 @@ export class AddonModForumProvider { | |||||||
|             if ( |             if ( | ||||||
|                 CoreNetwork.isOnline() || |                 CoreNetwork.isOnline() || | ||||||
|                 method !== 'mod_forum_get_forum_discussions' || |                 method !== 'mod_forum_get_forum_discussions' || | ||||||
|                 options.sortOrder !== AddonModForumProvider.SORTORDER_LASTPOST_DESC |                 options.sortOrder !== AddonModForumSortorder.LASTPOST_DESC | ||||||
|             ) { |             ) { | ||||||
|                 throw error; |                 throw error; | ||||||
|             } |             } | ||||||
| @ -803,7 +796,7 @@ export class AddonModForumProvider { | |||||||
|             const params: AddonModForumGetForumDiscussionsPaginatedWSParams = { |             const params: AddonModForumGetForumDiscussionsPaginatedWSParams = { | ||||||
|                 forumid: forumId, |                 forumid: forumId, | ||||||
|                 page: options.page, |                 page: options.page, | ||||||
|                 perpage: AddonModForumProvider.DISCUSSIONS_PER_PAGE, |                 perpage: ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE, | ||||||
|                 sortby: 'timemodified', |                 sortby: 'timemodified', | ||||||
|                 sortdirection: 'DESC', |                 sortdirection: 'DESC', | ||||||
|             }; |             }; | ||||||
| @ -824,7 +817,7 @@ export class AddonModForumProvider { | |||||||
| 
 | 
 | ||||||
|         return { |         return { | ||||||
|             discussions: response.discussions, |             discussions: response.discussions, | ||||||
|             canLoadMore: response.discussions.length >= AddonModForumProvider.DISCUSSIONS_PER_PAGE, |             canLoadMore: response.discussions.length >= ADDON_MOD_FORUM_DISCUSSIONS_PER_PAGE, | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -930,7 +923,7 @@ export class AddonModForumProvider { | |||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         if (this.isDiscussionListSortingAvailable()) { |         if (this.isDiscussionListSortingAvailable()) { | ||||||
|             promises.push(CoreUser.invalidateUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER)); |             promises.push(CoreUser.invalidateUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return CoreUtils.allPromises(promises); |         return CoreUtils.allPromises(promises); | ||||||
| @ -1008,7 +1001,7 @@ export class AddonModForumProvider { | |||||||
|         return CoreCourseLogHelper.log( |         return CoreCourseLogHelper.log( | ||||||
|             'mod_forum_view_forum', |             'mod_forum_view_forum', | ||||||
|             params, |             params, | ||||||
|             AddonModForumProvider.COMPONENT, |             ADDON_MOD_FORUM_COMPONENT, | ||||||
|             id, |             id, | ||||||
|             siteId, |             siteId, | ||||||
|         ); |         ); | ||||||
| @ -1030,7 +1023,7 @@ export class AddonModForumProvider { | |||||||
|         return CoreCourseLogHelper.log( |         return CoreCourseLogHelper.log( | ||||||
|             'mod_forum_view_forum_discussion', |             'mod_forum_view_forum_discussion', | ||||||
|             params, |             params, | ||||||
|             AddonModForumProvider.COMPONENT, |             ADDON_MOD_FORUM_COMPONENT, | ||||||
|             forumId, |             forumId, | ||||||
|             siteId, |             siteId, | ||||||
|         ); |         ); | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base | |||||||
| import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { AddonModForumModuleHandlerService } from './module'; | import { ADDON_MOD_FORUM_PAGE_NAME } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Handler to treat links to forum review. |  * Handler to treat links to forum review. | ||||||
| @ -66,7 +66,7 @@ export class AddonModForumDiscussionLinkHandlerService extends CoreContentLinksH | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 await CoreNavigator.navigateToSitePath( |                 await CoreNavigator.navigateToSitePath( | ||||||
|                     `${AddonModForumModuleHandlerService.PAGE_NAME}/discussion/${discussionId}`, |                     `${ADDON_MOD_FORUM_PAGE_NAME}/discussion/${discussionId}`, | ||||||
|                     { siteId, params: pageParams }, |                     { siteId, params: pageParams }, | ||||||
|                 ); |                 ); | ||||||
|             }, |             }, | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Injectable, Type } from '@angular/core'; | import { Injectable, Type } from '@angular/core'; | ||||||
| import { AddonModForum, AddonModForumProvider, AddonModForumTracking } from '../forum'; | import { AddonModForum, AddonModForumTracking } from '../forum'; | ||||||
| import { makeSingleton, Translate } from '@singletons'; | import { makeSingleton, Translate } from '@singletons'; | ||||||
| import { CoreEvents } from '@singletons/events'; | import { CoreEvents } from '@singletons/events'; | ||||||
| import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| @ -23,6 +23,7 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand | |||||||
| import { CoreCourseModuleData } from '@features/course/services/course-helper'; | import { CoreCourseModuleData } from '@features/course/services/course-helper'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreUser } from '@features/user/services/user'; | import { CoreUser } from '@features/user/services/user'; | ||||||
|  | import { ADDON_MOD_FORUM_MARK_READ_EVENT, ADDON_MOD_FORUM_PAGE_NAME } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Handler to support forum modules. |  * Handler to support forum modules. | ||||||
| @ -30,11 +31,9 @@ import { CoreUser } from '@features/user/services/user'; | |||||||
| @Injectable({ providedIn: 'root' }) | @Injectable({ providedIn: 'root' }) | ||||||
| export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { | export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { | ||||||
| 
 | 
 | ||||||
|     static readonly PAGE_NAME = 'mod_forum'; |  | ||||||
| 
 |  | ||||||
|     name = 'AddonModForum'; |     name = 'AddonModForum'; | ||||||
|     modName = 'forum'; |     modName = 'forum'; | ||||||
|     protected pageName = AddonModForumModuleHandlerService.PAGE_NAME; |     protected pageName = ADDON_MOD_FORUM_PAGE_NAME; | ||||||
| 
 | 
 | ||||||
|     supportedFeatures = { |     supportedFeatures = { | ||||||
|         [CoreConstants.FEATURE_GROUPS]: true, |         [CoreConstants.FEATURE_GROUPS]: true, | ||||||
| @ -88,7 +87,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const event = CoreEvents.on( |         const event = CoreEvents.on( | ||||||
|             AddonModForumProvider.MARK_READ_EVENT, |             ADDON_MOD_FORUM_MARK_READ_EVENT, | ||||||
|             eventData => { |             eventData => { | ||||||
|                 if (eventData.courseId !== courseId || eventData.moduleId !== module.id) { |                 if (eventData.courseId !== courseId || eventData.moduleId !== module.id) { | ||||||
|                     return; |                     return; | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator'; | |||||||
| import { CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { AddonModForumModuleHandlerService } from './module'; | import { ADDON_MOD_FORUM_PAGE_NAME } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Content links handler for forum new discussion. |  * Content links handler for forum new discussion. | ||||||
| @ -54,7 +54,7 @@ export class AddonModForumPostLinkHandlerService extends CoreContentLinksHandler | |||||||
|                     ); |                     ); | ||||||
| 
 | 
 | ||||||
|                     await CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         `${AddonModForumModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/new/0`, |                         `${ADDON_MOD_FORUM_PAGE_NAME}/${module.course}/${module.id}/new/0`, | ||||||
|                         { siteId, params: { forumId: module.instance } }, |                         { siteId, params: { forumId: module.instance } }, | ||||||
|                     ); |                     ); | ||||||
|                 } finally { |                 } finally { | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler'; | import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler'; | ||||||
| import { AddonModForum, AddonModForumData, AddonModForumPost, AddonModForumProvider } from '../forum'; | import { AddonModForum, AddonModForumData, AddonModForumPost } from '../forum'; | ||||||
| import { CoreSitesReadingStrategy } from '@services/sites'; | import { CoreSitesReadingStrategy } from '@services/sites'; | ||||||
| import { CoreFilepool } from '@services/filepool'; | import { CoreFilepool } from '@services/filepool'; | ||||||
| import { CoreWSFile } from '@services/ws'; | import { CoreWSFile } from '@services/ws'; | ||||||
| @ -25,6 +25,7 @@ import { CoreUtils } from '@services/utils/utils'; | |||||||
| import { AddonModForumSync, AddonModForumSyncResult } from '../forum-sync'; | import { AddonModForumSync, AddonModForumSyncResult } from '../forum-sync'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { CoreCourses } from '@features/courses/services/courses'; | import { CoreCourses } from '@features/courses/services/courses'; | ||||||
|  | import { ADDON_MOD_FORUM_COMPONENT } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Handler to prefetch forums. |  * Handler to prefetch forums. | ||||||
| @ -34,7 +35,7 @@ export class AddonModForumPrefetchHandlerService extends CoreCourseActivityPrefe | |||||||
| 
 | 
 | ||||||
|     name = 'AddonModForum'; |     name = 'AddonModForum'; | ||||||
|     modName = 'forum'; |     modName = 'forum'; | ||||||
|     component = AddonModForumProvider.COMPONENT; |     component = ADDON_MOD_FORUM_COMPONENT; | ||||||
|     updatesNames = /^configuration$|^.*files$|^discussions$/; |     updatesNames = /^configuration$|^.*files$|^discussions$/; | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -23,8 +23,8 @@ import { CoreUrlUtils } from '@services/utils/url'; | |||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| 
 | 
 | ||||||
| import { AddonModForumModuleHandlerService } from './module'; |  | ||||||
| import { isSafeNumber } from '@/core/utils/types'; | import { isSafeNumber } from '@/core/utils/types'; | ||||||
|  | import { ADDON_MOD_FORUM_PAGE_NAME } from '../../constants'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Handler for forum push notifications clicks. |  * Handler for forum push notifications clicks. | ||||||
| @ -80,7 +80,7 @@ export class AddonModForumPushClickHandlerService implements CorePushNotificatio | |||||||
|         ); |         ); | ||||||
| 
 | 
 | ||||||
|         await CoreNavigator.navigateToSitePath( |         await CoreNavigator.navigateToSitePath( | ||||||
|             `${AddonModForumModuleHandlerService.PAGE_NAME}/discussion/${discussionId}`, |             `${ADDON_MOD_FORUM_PAGE_NAME}/discussion/${discussionId}`, | ||||||
|             { siteId: notification.site, params: pageParams }, |             { siteId: notification.site, params: pageParams }, | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user