mirror of
https://github.com/flarum/framework.git
synced 2025-06-05 07:24:33 +08:00
Clean up discussion model
This commit is contained in:
@ -3,30 +3,12 @@ import computed from 'flarum/utils/computed';
|
|||||||
import ItemList from 'flarum/utils/item-list';
|
import ItemList from 'flarum/utils/item-list';
|
||||||
|
|
||||||
class Discussion extends Model {
|
class Discussion extends Model {
|
||||||
pushData(newData) {
|
/**
|
||||||
super.pushData(newData);
|
* Remove a post from the discussion's posts relationship.
|
||||||
|
*
|
||||||
// var links = this.data().links;
|
* @param {int} id The ID of the post to remove.
|
||||||
// var posts = links && links.posts;
|
* @return {void}
|
||||||
// if (posts) {
|
*/
|
||||||
// if (newData.removedPosts) {
|
|
||||||
// posts.linkage.forEach((linkage, i) => {
|
|
||||||
// if (newData.removedPosts.indexOf(linkage.id) !== -1) {
|
|
||||||
// posts.linkage.splice(i, 1);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (newData.links && newData.links.addedPosts) {
|
|
||||||
// newData.links.addedPosts.linkage.forEach(linkage => {
|
|
||||||
// if (posts.linkage[posts.linkage.length - 1].id != linkage.id) {
|
|
||||||
// posts.linkage.push(linkage);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
removePost(id) {
|
removePost(id) {
|
||||||
const relationships = this.data().relationships;
|
const relationships = this.data().relationships;
|
||||||
const posts = relationships && relationships.posts;
|
const posts = relationships && relationships.posts;
|
||||||
|
Reference in New Issue
Block a user