MOBILE-3523 tags: Fix click tags in forum
parent
da9d90e650
commit
2dabb6e1b2
|
@ -25,6 +25,7 @@ import { CoreCourseLogHelperProvider } from '@core/course/providers/log-helper';
|
||||||
import { AddonModForumOfflineProvider } from './offline';
|
import { AddonModForumOfflineProvider } from './offline';
|
||||||
import { CoreRatingInfo } from '@core/rating/providers/rating';
|
import { CoreRatingInfo } from '@core/rating/providers/rating';
|
||||||
import { CoreCourseCommonModWSOptions } from '@core/course/providers/course';
|
import { CoreCourseCommonModWSOptions } from '@core/course/providers/course';
|
||||||
|
import { CoreUrlUtils } from '@providers/utils/url';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features for forums.
|
* Service that provides some features for forums.
|
||||||
|
@ -539,15 +540,7 @@ export class AddonModForumProvider {
|
||||||
|
|
||||||
unread: !post.postread,
|
unread: !post.postread,
|
||||||
isprivatereply: !!post.isprivatereply,
|
isprivatereply: !!post.isprivatereply,
|
||||||
tags: (post.tags || []).map((tag) => {
|
tags: post.tags,
|
||||||
return {
|
|
||||||
id: tag.taginstanceid,
|
|
||||||
tagid: tag.id,
|
|
||||||
isstandard: tag.isstandard,
|
|
||||||
displayname: tag.rawname,
|
|
||||||
flag: !!tag.flag,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (post.groupname) {
|
if (post.groupname) {
|
||||||
|
@ -557,6 +550,29 @@ export class AddonModForumProvider {
|
||||||
return newPost;
|
return newPost;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
// For some reason, the new WS doesn't use the tags exporter so it returns a different format than other WebServices.
|
||||||
|
// Convert the new format to the exporter one so it's the same as in other WebServices.
|
||||||
|
const translateTagsFormatToLegacy = (posts: any[]): any[] => {
|
||||||
|
posts.forEach((post) => {
|
||||||
|
post.tags = post.tags.map((tag) => {
|
||||||
|
const viewUrl = (tag.urls && tag.urls.view) || '';
|
||||||
|
const params = CoreUrlUtils.instance.extractUrlParams(viewUrl);
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: tag.tagid,
|
||||||
|
taginstanceid: tag.id,
|
||||||
|
flag: tag.flag ? 1 : 0,
|
||||||
|
isstandard: tag.isstandard,
|
||||||
|
rawname: tag.displayname,
|
||||||
|
name: tag.displayname,
|
||||||
|
tagcollid: params.tc ? Number(params.tc) : undefined,
|
||||||
|
taginstancecontextid: params.from ? Number(params.from) : undefined,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return posts;
|
||||||
|
};
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
discussionid: discussionId,
|
discussionid: discussionId,
|
||||||
|
@ -577,6 +593,8 @@ export class AddonModForumProvider {
|
||||||
|
|
||||||
if (wsName == 'mod_forum_get_forum_discussion_posts') {
|
if (wsName == 'mod_forum_get_forum_discussion_posts') {
|
||||||
response.posts = translateLegacyPostsFormat(response.posts);
|
response.posts = translateLegacyPostsFormat(response.posts);
|
||||||
|
} else {
|
||||||
|
response.posts = translateTagsFormatToLegacy(response.posts);
|
||||||
}
|
}
|
||||||
this.storeUserData(response.posts);
|
this.storeUserData(response.posts);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<ng-container *ngFor="let tag of tags">
|
<ng-container *ngFor="let tag of tags">
|
||||||
<ion-badge (click)="openTag(tag)" class="core-tag-list-tag">{{ tag.displayname }}</ion-badge>
|
<ion-badge (click)="openTag(tag)" class="core-tag-list-tag">{{ tag.rawname }}</ion-badge>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
Loading…
Reference in New Issue