forked from CIT/Vmeda.Online
		
	MOBILE-3519 forum: Use forumid and courseid from WS
This commit is contained in:
		
							parent
							
								
									4d8697a601
								
							
						
					
					
						commit
						6c894a8abe
					
				| @ -331,6 +331,8 @@ export class AddonModForumDiscussionPage implements OnDestroy { | |||||||
|             return this.forumProvider.getDiscussionPosts(this.discussionId, this.cmId).then((response) => { |             return this.forumProvider.getDiscussionPosts(this.discussionId, this.cmId).then((response) => { | ||||||
|                 onlinePosts = response.posts; |                 onlinePosts = response.posts; | ||||||
|                 ratingInfo = response.ratinginfo; |                 ratingInfo = response.ratinginfo; | ||||||
|  |                 this.courseId = response.courseid; | ||||||
|  |                 this.forumId = response.forumid; | ||||||
|             }).then(() => { |             }).then(() => { | ||||||
|                 // Check if there are responses stored in offline.
 |                 // Check if there are responses stored in offline.
 | ||||||
|                 return this.forumOffline.getDiscussionReplies(this.discussionId).then((replies) => { |                 return this.forumOffline.getDiscussionReplies(this.discussionId).then((replies) => { | ||||||
| @ -371,17 +373,13 @@ export class AddonModForumDiscussionPage implements OnDestroy { | |||||||
|             let posts = offlineReplies.concat(onlinePosts); |             let posts = offlineReplies.concat(onlinePosts); | ||||||
| 
 | 
 | ||||||
|             const startingPost = this.forumProvider.extractStartingPost(posts); |             const startingPost = this.forumProvider.extractStartingPost(posts); | ||||||
|             if (startingPost) { |  | ||||||
|                 // Update discussion data from first post.
 |  | ||||||
|                 this.discussion = Object.assign(this.discussion || {}, startingPost); |  | ||||||
|             } |  | ||||||
| 
 | 
 | ||||||
|             // If sort type is nested, normal sorting is disabled and nested posts will be displayed.
 |             // If sort type is nested, normal sorting is disabled and nested posts will be displayed.
 | ||||||
|             if (this.sort == 'nested') { |             if (this.sort == 'nested') { | ||||||
|                 // Sort first by creation date to make format tree work.
 |                 // Sort first by creation date to make format tree work.
 | ||||||
|                 this.forumProvider.sortDiscussionPosts(posts, 'ASC'); |                 this.forumProvider.sortDiscussionPosts(posts, 'ASC'); | ||||||
| 
 | 
 | ||||||
|                 posts = this.utils.formatTree(posts, 'parent', 'id', this.discussion.id); |                 posts = this.utils.formatTree(posts, 'parent', 'id', this.discussion ? this.discussion.id : startingPost.id); | ||||||
|             } else { |             } else { | ||||||
|                 // Set default reply subject.
 |                 // Set default reply subject.
 | ||||||
|                 const direction = this.sort == 'flat-newest' ? 'DESC' : 'ASC'; |                 const direction = this.sort == 'flat-newest' ? 'DESC' : 'ASC'; | ||||||
| @ -424,6 +422,10 @@ export class AddonModForumDiscussionPage implements OnDestroy { | |||||||
|             }).catch(() => { |             }).catch(() => { | ||||||
|                 // Ignore errors.
 |                 // Ignore errors.
 | ||||||
|             }).then(() => { |             }).then(() => { | ||||||
|  |                 if (startingPost) { | ||||||
|  |                     // Update discussion data from first post.
 | ||||||
|  |                     this.discussion = Object.assign(this.discussion || {}, startingPost); | ||||||
|  |                 } | ||||||
| 
 | 
 | ||||||
|                 if (!this.discussion) { |                 if (!this.discussion) { | ||||||
|                     // The discussion object was not passed as parameter and there is no starting post. Should not happen.
 |                     // The discussion object was not passed as parameter and there is no starting post. Should not happen.
 | ||||||
|  | |||||||
| @ -496,7 +496,8 @@ export class AddonModForumProvider { | |||||||
|      * @param siteId Site ID. If not defined, current site. |      * @param siteId Site ID. If not defined, current site. | ||||||
|      * @return Promise resolved with forum posts and rating info. |      * @return Promise resolved with forum posts and rating info. | ||||||
|      */ |      */ | ||||||
|     getDiscussionPosts(discussionId: number, cmId: number, siteId?: string): Promise<{posts: any[], ratinginfo?: CoreRatingInfo}> { |     getDiscussionPosts(discussionId: number, cmId: number, siteId?: string): Promise<{posts: any[], courseid?: number, | ||||||
|  |             forumid?: number, ratinginfo?: CoreRatingInfo}> { | ||||||
|         const params = { |         const params = { | ||||||
|             discussionid: discussionId |             discussionid: discussionId | ||||||
|         }; |         }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user