MOBILE-3070 forum: Fix finding discussion by Id.

main
Pau Ferrer Ocaña 2019-11-22 14:59:37 +01:00
parent 12ec938594
commit 135e2cd5e3
2 changed files with 4 additions and 2 deletions

View File

@ -599,7 +599,8 @@ export class AddonModForumProvider {
* @param forceCache True to always get the value from cache. false otherwise. * @param forceCache True to always get the value from cache. false otherwise.
* @param siteId Site ID. If not defined, current site. * @param siteId Site ID. If not defined, current site.
* @return Promise resolved with an object with: * @return Promise resolved with an object with:
* - discussions: List of discussions. * - discussions: List of discussions. Note that for every discussion in the list discussion.id is the main post ID but
* discussion ID is discussion.discussion.
* - canLoadMore: True if there may be more discussions to load. * - canLoadMore: True if there may be more discussions to load.
*/ */
getDiscussions(forumId: number, sortOrder?: number, page: number = 0, forceCache?: boolean, siteId?: string): Promise<any> { getDiscussions(forumId: number, sortOrder?: number, page: number = 0, forceCache?: boolean, siteId?: string): Promise<any> {

View File

@ -280,7 +280,8 @@ export class AddonModForumHelperProvider {
const findDiscussion = (page: number): Promise<any> => { const findDiscussion = (page: number): Promise<any> => {
return this.forumProvider.getDiscussions(forumId, undefined, page, false, siteId).then((response) => { return this.forumProvider.getDiscussions(forumId, undefined, page, false, siteId).then((response) => {
if (response.discussions && response.discussions.length > 0) { if (response.discussions && response.discussions.length > 0) {
const discussion = response.discussions.find((discussion) => discussion.id == discussionId); // Note that discussion.id is the main post ID but discussion ID is discussion.discussion.
const discussion = response.discussions.find((discussion) => discussion.discussion == discussionId);
if (discussion) { if (discussion) {
return discussion; return discussion;
} }