MOBILE-3930 course: Mark site plugins as module viewed
This commit is contained in:
		
							parent
							
								
									6c518d55fa
								
							
						
					
					
						commit
						d42bbdf2ca
					
				| @ -21,6 +21,7 @@ import { | |||||||
|     CoreCourseModuleSummaryResult, |     CoreCourseModuleSummaryResult, | ||||||
|     CoreCourseModuleSummaryComponent, |     CoreCourseModuleSummaryComponent, | ||||||
| } from '@features/course/components/module-summary/module-summary'; | } from '@features/course/components/module-summary/module-summary'; | ||||||
|  | import { CoreCourse } from '@features/course/services/course'; | ||||||
| import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; | import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; | ||||||
| import { | import { | ||||||
|     CoreCourseModuleDelegate, |     CoreCourseModuleDelegate, | ||||||
| @ -35,7 +36,7 @@ import { | |||||||
| import { IonRefresher } from '@ionic/angular'; | import { IonRefresher } from '@ionic/angular'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content'; | import { CoreSitePluginsPluginContentComponent, CoreSitePluginsPluginContentLoadedData } from '../plugin-content/plugin-content'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Component that displays the index of a module site plugin. |  * Component that displays the index of a module site plugin. | ||||||
| @ -161,9 +162,12 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C | |||||||
|     /** |     /** | ||||||
|      * Function called when the data of the site plugin content is loaded. |      * Function called when the data of the site plugin content is loaded. | ||||||
|      */ |      */ | ||||||
|     // eslint-disable-next-line @typescript-eslint/no-unused-vars
 |     contentLoaded(data: CoreSitePluginsPluginContentLoadedData): void { | ||||||
|     contentLoaded(refresh: boolean): void { |         if (data.success) { | ||||||
|         return; |             CoreCourse.storeModuleViewed(this.courseId, this.module.id, { | ||||||
|  |                 sectionId: this.module.section, | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -43,7 +43,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { | |||||||
|     @Input() data?: Record<string, unknown>; // Data to pass to the component.
 |     @Input() data?: Record<string, unknown>; // Data to pass to the component.
 | ||||||
|     @Input() preSets?: CoreSiteWSPreSets; // The preSets for the WS call.
 |     @Input() preSets?: CoreSiteWSPreSets; // The preSets for the WS call.
 | ||||||
|     @Input() pageTitle?: string; // Current page title. It can be used by the "new-content" directives.
 |     @Input() pageTitle?: string; // Current page title. It can be used by the "new-content" directives.
 | ||||||
|     @Output() onContentLoaded = new EventEmitter<boolean>(); // Emits an event when the content is loaded.
 |     @Output() onContentLoaded = new EventEmitter<CoreSitePluginsPluginContentLoadedData>(); // Emits event when content is loaded.
 | ||||||
|     @Output() onLoadingContent = new EventEmitter<boolean>(); // Emits an event when starts to load the content.
 |     @Output() onLoadingContent = new EventEmitter<boolean>(); // Emits an event when starts to load the content.
 | ||||||
| 
 | 
 | ||||||
|     content?: string; // Content.
 |     content?: string; // Content.
 | ||||||
| @ -114,11 +114,11 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { | |||||||
|             this.jsData.updateContent = this.updateContent.bind(this); |             this.jsData.updateContent = this.updateContent.bind(this); | ||||||
|             this.jsData.updateModuleCourseContent = this.updateModuleCourseContent.bind(this); |             this.jsData.updateModuleCourseContent = this.updateModuleCourseContent.bind(this); | ||||||
| 
 | 
 | ||||||
|             this.onContentLoaded.emit(refresh); |             this.onContentLoaded.emit({ refresh: !!refresh, success: true }); | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
|             // Make it think it's loaded - otherwise it sticks on 'loading' and stops navigation working.
 |             // Make it think it's loaded - otherwise it sticks on 'loading' and stops navigation working.
 | ||||||
|             this.content = '<div></div>'; |             this.content = '<div></div>'; | ||||||
|             this.onContentLoaded.emit(refresh); |             this.onContentLoaded.emit({ refresh: !!refresh, success: false }); | ||||||
| 
 | 
 | ||||||
|             CoreDomUtils.showErrorModalDefault(error, 'core.errorloadingcontent', true); |             CoreDomUtils.showErrorModalDefault(error, 'core.errorloadingcontent', true); | ||||||
|         } finally { |         } finally { | ||||||
| @ -237,3 +237,8 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | export type CoreSitePluginsPluginContentLoadedData = { | ||||||
|  |     refresh: boolean; | ||||||
|  |     success: boolean; | ||||||
|  | }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user